Add completed oscillation

This commit is contained in:
Lev
2021-07-16 01:22:23 -05:00
parent a0200fc21f
commit f2b408d184
3 changed files with 42 additions and 0 deletions

View File

@ -0,0 +1,14 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script src="p5.min.js"></script>
<script src="sketch.js"></script>
</body>
</html>

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,25 @@
function setup()
{
createCanvas(900, 600);
angleMode(DEGREES);
background(0);
}
function draw()
{
background(0);
translate(width/2, height/2);
stroke(255);
fill(255);
let amp = width / 2;
let period = 360;
let phase = 0;
let freq = 0.5;
let yamp = height /2;
//let x = sin(360 * frameCount/period + phase) * amp;
let x = sin(frameCount * 6 * freq + phase) * amp;
//let y = cos(frameCount * 6 * freq) * yamp;
ellipse(x, 0, 30, 30);
}