Last active
February 16, 2018 13:26
-
-
Save jacopocolo/e8e035468f8df7a231913e76ff670a8a 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 xspacing = 16; | |
var w; | |
var theta = 0.0; | |
var amplitude = 75.0; | |
var period = 500.0; | |
var dx; | |
var yvalues; | |
function setup() { | |
createCanvas(400, 300); | |
w = width+16; | |
dx = (TWO_PI / period) * xspacing; | |
yvalues = new Array(floor(w/xspacing)); | |
} | |
function draw() { | |
background(0); | |
calcWave(); | |
renderWave(); | |
} | |
function calcWave() { | |
theta += 0.02; | |
var x = theta; | |
for (var i = 0; i < yvalues.length; i++) { | |
yvalues[i] = sin(x)*amplitude; | |
x+=dx; | |
} | |
} | |
function renderWave() { | |
noStroke(); | |
fill(255); | |
for (var x = 0; x < yvalues.length; x++) { | |
ellipse(x*xspacing, height/2+yvalues[x], 16, 16); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi
is it possible to transform elipse in a star?