g = love.graphics draw, line, circ, pt, color = g.draw, g.line, g.circle, g.points, g.setColor abs,min,max = math.abs, math.min, math.max audio = love.audio.newSource if od == nil then od,ou,omp,omr,okp,okr = love.draw, love.update, love.mousepressed, love.mousereleased, love.keypressed, love.keyreleased end W,H = g.getDimensions() -- visuals cs, N = {}, 100 function sq(x) return x*x end function dist2(x1,y1, x2,y2) return sq(x2-x1) + sq(y2-y1) end -- audio ts = {} function love.draw() -- od() for _,c in pairs(cs) do circ(c[1],c[2]) end end function circ(cx,cy) for x=cx-N,cx+N do for y=cy-N,cy+N do local dist = dist2(cx,cy, x,y) if dist < N*N then color(abs(x-cx)/N, abs(y-cy)/N, 0.5) --, dist/N/N) pt(x,y) end end end end function love.update(dt) ou(dt) local touches = love.touch.getTouches() for _,id in ipairs(touches) do if cs[id] then cs[id][1], cs[id][2] = love.touch.getPosition(id) ts[id]:setPitch(pitch(cs[id][2])) end end end function pitch(y) if y <= H/2 then return 2 - y*2/H -- vary pitch from 2 to 1 else return 1.5 - y/H -- vary pitch from 1 to 0.5 end end function love.keypressed(key, ...) okp(key, ...) escape() end function love.touchpressed(id, x,y, ...) cs[id] = {x,y} ts[id] = audio('ivanish/MaternalBowedGuitar.mp3', 'static') ts[id]:setLooping(true) ts[id]:play() end function love.touchreleased(id, ...) cs[id] = nil if ts[id] then ts[id]:stop() end ts[id] = nil end function escape() error('StopScript') end