Add completed additive synthesis with noise
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.3.1 Additive Synthesis/p5.min.js
vendored
Normal file
3
CM2030 Graphics Programming/Topic 8/8.3.1 Additive Synthesis/p5.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@ -0,0 +1,24 @@
|
|||||||
|
function setup()
|
||||||
|
{
|
||||||
|
createCanvas(900, 600);
|
||||||
|
angleMode(DEGREES);
|
||||||
|
}
|
||||||
|
|
||||||
|
function draw()
|
||||||
|
{
|
||||||
|
background(0);
|
||||||
|
translate(0, height/2);
|
||||||
|
|
||||||
|
stroke(255);
|
||||||
|
noFill();
|
||||||
|
|
||||||
|
beginShape();
|
||||||
|
for (var x = 0; x <= width; ++x)
|
||||||
|
{
|
||||||
|
let wave1 = sin(x + frameCount) * height/4;
|
||||||
|
let wave2 = sin(x * 10 + frameCount) * height/20;
|
||||||
|
let wave3 = noise(x/10 + frameCount/100) * 150;
|
||||||
|
vertex(x, wave3 + wave2 + wave1);
|
||||||
|
}
|
||||||
|
endShape();
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user