Last active
August 12, 2016 08:16
-
-
Save antonhornquist/d699b3d5f7909e1e1da91e092b0865bf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
( | |
var plotpath, update, plotxy, position, size, alpha; | |
plotpath = { |to| | |
var steps = 5; | |
var delta = (to - position) / steps; | |
fork { | |
steps.do { | |
position = position + delta; | |
update.(); | |
0.025.wait; | |
}; | |
position = to; | |
update.(); | |
} | |
}; | |
update = { plotxy.(position, size, alpha) }; | |
plotxy = { |where, spread, transparency| | |
var levels = Array.fill(8) { |gridy| | |
Array.fill(8) { |gridx| | |
var distance; | |
distance = (gridx@gridy) dist: where; | |
15-(distance*((100-spread)/100*15)).round.clip(0, 15); | |
} | |
}.flat; | |
SerialOSCGrid.ledLevelMap(0, 0, (levels * (1-(transparency/100)))); | |
}; | |
position = (8.rand)@(8.rand); | |
size = 50; | |
alpha = 0; | |
SerialOSCClient.init { update.() }; | |
SerialOSCGrid.addDependant { |thechanged, what| | |
if (what == 'default') { update.() }; | |
}; | |
GridKeydef.press(\position, { |x, y| plotpath.(x@y) }); | |
EncDeltadef(\size, { |n, delta| | |
size = (size + (delta/2)).clip(0, 100); | |
update.(); | |
}, 0); | |
EncDeltadef(\transparency, { |n, delta| | |
alpha = (alpha + (delta/2)).clip(0, 100); | |
update.(); | |
}, 1); | |
SerialOSCGrid.clearLeds; | |
update.(); | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment