You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* @description Graphics the following equation: sin(n*cos(r) + 5*theta) where n is a function of horizontal mouse location. Original by Daniel Shiffman
4
+
* @description Graphics the following equation: sin(n*cos(r) + 5*theta) where n is a function of horizontal mouse location. Original by Daniel Shiffman
5
5
*/
6
6
functionsetup(){
7
7
createCanvas(710,400);
@@ -10,17 +10,17 @@ function setup() {
10
10
11
11
functiondraw(){
12
12
loadPixels();
13
-
varn=(mouseX*10.0)/width;
14
-
varw=16.0;// 2D space width
15
-
varh=16.0;// 2D space height
16
-
vardx=w/width;// Increment x this amount per pixel
17
-
vardy=h/height;// Increment y this amount per pixel
18
-
varx=-w/2;// Start x at -1 * width / 2
19
-
vary;
13
+
letn=(mouseX*10.0)/width;
14
+
constw=16.0;// 2D space width
15
+
consth=16.0;// 2D space height
16
+
constdx=w/width;// Increment x this amount per pixel
17
+
constdy=h/height;// Increment y this amount per pixel
18
+
letx=-w/2;// Start x at -1 * width / 2
19
+
lety;
20
20
21
-
varr;
22
-
vartheta;
23
-
varval;
21
+
letr;
22
+
lettheta;
23
+
letval;
24
24
25
25
letbw;//variable to store grayscale
26
26
leti;
@@ -30,25 +30,23 @@ function draw() {
30
30
31
31
for(i=0;i<cols;i+=1){
32
32
y=-h/2;
33
-
34
33
for(j=0;j<rows;j+=1){
35
-
r=sqrt((x*x)+(y*y));// Convert cartesian to polar
34
+
r=sqrt(x*x+y*y);// Convert cartesian to polar
36
35
theta=atan2(y,x);// Convert cartesian to polar
37
36
// Compute 2D polar coordinate function
38
37
val=sin(n*cos(r)+5*theta);// Results in a value between -1 and 1
39
38
//var val = cos(r); // Another simple function
40
39
//var val = sin(theta); // Another simple function
0 commit comments