Created
March 23, 2021 10:33
-
-
Save fengyfei/447d26ad568d032645bbda01aff8a90d to your computer and use it in GitHub Desktop.
[P5][Sin]
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
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