I dug up some code @Tnology made a while back, found it interesting, and so put a little more into it to make it a pretty drawing thing. I thought it was fun, so I shared it here.
displayMode(OVERLAY)
supportedOrientations(LANDSCAPE_ANY)
function setup()
q=Linedrawer()
end
function draw()
background(0)
q:draw()
end
function touched(t)
q:touched(t)
end
Linedrawer=class()
function Linedrawer:init()
self.m, self.ps = mesh(), {}
grzzzzzzxyfmblpooootqrssszvgrwbgfw = self
parameter.action("newdraw", function() grzzzzzzxyfmblpooootqrssszvgrwbgfw.i=1 end)
parameter.action("Eliminate_Leftovers", function() for x=self.i,#self.ps do
tween(.5, self.ps[x], {d=0}, tween.easing.quadInOut)
end end)
parameter.color("colors",color(255))
self.i=1
for b=0,1000 do
self:addline(vec2(b^2%WIDTH,HEIGHT+10),vec2(b^2%WIDTH+1,HEIGHT+5))
end
self.i=1
local xnorp = math.random(WIDTH)
self:addline(vec2(xnorp,HEIGHT+10),vec2(xnorp,HEIGHT+5),.1)
self.i=1
end
function Linedrawer:draw()
self.m:clear()
for i,v in ipairs(self.ps) do
self.m:addRect(v.x, v.y, v.d, 2, v.a)
for b=0,5 do
self.m:color(i*6-b,v.r,v.g,v.b)
end
end
self.m:draw()
end
function Linedrawer:touched(touch)
self.p = vec2(touch.x, touch.y)
if touch.state == BEGAN then
self.sp= self.p
elseif touch.state == ENDED or (self.sp-self.p):len() > 10 then
self:addline(self.sp, self.p)
self.sp = self.p
end
if touch.state == ENDED then
--for x=self.i,#self.ps do
-- tween(.5, self.ps[x], {d=0}, tween.easing.quadInOut)
--end
end
end
function Linedrawer:addline(a,b,twtime)
local time = twtime or 3
local v = b - a
local p = a + v*.5
p = {x=p.x, y=p.y,d=v:len(),a=-v:angleBetween(vec2(1,0)),r=colors.r,g=colors.g,b=colors.b}
if self.ps[self.i] then
tween(time, self.ps[self.i], p, tween.easing.quadInOut)
else
table.insert(self.ps, p)
end
self.i = self.i + 1
end