Skip to content

Instantly share code, notes, and snippets.

View nadar71's full-sized avatar
🏠
Working from home

Simone Mapelli nadar71

🏠
Working from home
View GitHub Profile
@nadar71
nadar71 / dragitemscrollview.lua
Created January 26, 2017 12:17 — forked from HoraceBury/dragitemscrollview.lua
Provides a scrollview widget which can have items dragged off it.
local widget = require("widget")
local function angleOf( ax, ay, bx, by, adjust, positive )
local angle = math.atan2( by-ay, bx-ax ) * 180/math.pi
if (adjust) then
if (type(adjust) ~= "number") then adjust = -90 end
angle = angle - adjust
if (angle < -180) then angle=angle+360 end
if (angle > 180) then angle=angle-360 end
@nadar71
nadar71 / wordz.lua
Created October 7, 2016 08:52 — forked from jstrahan/wordz.lua
wordz.lua is used to check for acceptable words for word games like scrabble and others.
This file has been truncated, but you can view the full file.
local M = {}
local wordz = {}
wordz[1] = nil
wordz[2] = { 'aa','ab','ad','ae','ag','ah','ai','al','am','an','ar','as','at','aw','ax','ay','ba','be','bi','bo','by','de','do','ed','ef','eh','el','em','en','er','es','et','ex','fa','go','ha','he','hi','hm','ho','id','if','in','is','it','jo','ka','la','li','lo','ma','me','mi','mm','mo','mu','my','na','ne','no','nu','od','oe','of','oh','om','on','op','or','os','ow','ox','oy','pa','pe','pi','re','sh','si','so','ta','ti','to','uh','um','un','up','us','ut','we','wo','xi','xu','ya','ye','yo' }
@nadar71
nadar71 / colorTransition.lua
Created October 7, 2016 08:48 — forked from rdaniel0/colorTransition.lua
A colour transition function for CoronaSDK in lua
function TransitionColor(displayObj, params)
if(params and params.startColor and params.endColor) then
local length = params.time or 300
local startTime = system.getTimer()
local easingFunc = params.transition or easing.linear
local function colorInterpolate(a,b,i,t)
colourTable = {
easingFunc(i,t,a[1],b[1]-a[1]),
local function makeGenerator()
local kernel = {
category = "generator",
name = "stars",
isTimeDependent = false
}
kernel.vertexData = {
{
@nadar71
nadar71 / simple drag and rotate demo.lua
Created October 7, 2016 08:20 — forked from HoraceBury/simple drag and rotate demo.lua
This code was an answer to a forum question asking for a touch to drag an object but a tap-touch to rotate the object. I kept it simple and without reference to my mathlib.lua for the sake of brevity.
local function angleOnTarget( e )
local a = math.atan2( e.y-e.target.y, e.x-e.target.x ) * 180 / (4*math.atan(1))
if (a<0) then a=a+360 end
return a
end
local function tap(e)
e.target.touchMode = "drag"
print("drag mode")
e.target.dragtimer = timer.performWithDelay( 400, function()
@nadar71
nadar71 / flood.lua
Created October 7, 2016 08:18 — forked from HoraceBury/flood.lua
Flood fill a display object with a Gfx2.0 gradient fill. Can be used to provide the Android Material Design button interaction animation, eg: http://www.google.com/design/spec/components/buttons.html#buttons-flat-raised-buttons
-- ref: http://docs.coronalabs.com/daily/guide/graphics/effects.html#generator.radialgradient
local back, outer, inner = {0,1,0,1}, {0,.9,0,.05}, {0,1,0,.05}
-- backing colour rect
display.newRect( display.actualCenterX*.5, display.actualContentHeight*.25, 220, 220 ).fill = back
-- radial fill rect
local r = display.newRect( display.actualCenterX*.5, display.actualContentHeight*.25, 200, 200 )
local function getRadius( r, xOffset, yOffset )
@nadar71
nadar71 / shadow.lua
Created July 8, 2016 07:56 — forked from HoraceBury/shadow.lua
Create a drop shadow
local function shadow( width, height, size )
local g = display.newGroup()
g.x, g.y = display.contentCenterX, display.contentCenterY
display.newRect( g, 0, 0, width+size, height+size ).fill = {1,1,1,0}
display.newRect( g, 0, 0, width, height ).fill = {0,0,0}
local c = display.capture( g )
g = display.remove( g )
display.setDefault("background", 0.2, 0.2, 0.4 )
-- Keep track of time in seconds
local secondsLeft = 20 * 60 -- 20 minutes * 60 seconds
local clockText = display.newText("20:00", display.contentCenterX, 80, native.systemFontBold, 80)
clockText:setFillColor( 0.7, 0.7, 1 )
local function updateTime()
-- decrement the number of seconds
-- polygon concave test
require("mathlib")
stage = display.getCurrentStage()
local text = display.newText{ text="- - -", x=display.contentCenterX, y=100, fontSize=24 }
lines = display.newGroup()
lines:insert(display.newGroup())
-- swipe library
--[[ Libraries ]]--
local composer = require("composer")
--[[ Fields ]]--
local mainstage = display.getCurrentStage()
local stage = composer.stage