Skip to content

Instantly share code, notes, and snippets.

@fengyfei
Created March 23, 2021 10:33
Show Gist options
  • Save fengyfei/447d26ad568d032645bbda01aff8a90d to your computer and use it in GitHub Desktop.
Save fengyfei/447d26ad568d032645bbda01aff8a90d to your computer and use it in GitHub Desktop.
[P5][Sin]
let x = 0;
const xAxis = 480;
const yAxis = 360;
function setup() {
createCanvas(xAxis, yAxis);
stroke('purple');
strokeWeight(4);
frameRate(16);
}
function draw() {
background('grey');
x = x + 5;
if (x > xAxis) {
x = 0;
}
for (let i = 0; i < x ; i = i + 1) {
point(i, yAxis/2 * (1 - Math.sin(2 * i * Math.PI/xAxis)))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment