Add completed oscillation
This commit is contained in:
@ -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>
|
||||
3
CM2030 Graphics Programming/Topic 8/8.2.3 Oscillation/p5.min.js
vendored
Normal file
3
CM2030 Graphics Programming/Topic 8/8.2.3 Oscillation/p5.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@ -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);
|
||||
}
|
||||
Reference in New Issue
Block a user