Skip to content

Instantly share code, notes, and snippets.

@jacopocolo
Last active February 16, 2018 13:26
Show Gist options
  • Save jacopocolo/e8e035468f8df7a231913e76ff670a8a to your computer and use it in GitHub Desktop.
Save jacopocolo/e8e035468f8df7a231913e76ff670a8a to your computer and use it in GitHub Desktop.
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);
}
}
@rlm23rain
Copy link

Hi
is it possible to transform elipse in a star?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment