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
5
+
*/
6
+
functionsetup(){
7
+
createCanvas(710,400);
8
+
pixelDensity(1);
9
+
}
10
+
11
+
functiondraw(){
12
+
loadPixels();
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
+
21
+
letr;
22
+
lettheta;
23
+
letval;
24
+
25
+
letbw;//variable to store grayscale
26
+
leti;
27
+
letj;
28
+
letcols=width;
29
+
letrows=height;
30
+
31
+
for(i=0;i<cols;i+=1){
32
+
y=-h/2;
33
+
for(j=0;j<rows;j+=1){
34
+
r=sqrt(x*x+y*y);// Convert cartesian to polar
35
+
theta=atan2(y,x);// Convert cartesian to polar
36
+
// Compute 2D polar coordinate function
37
+
val=sin(n*cos(r)+5*theta);// Results in a value between -1 and 1
38
+
//var val = cos(r); // Another simple function
39
+
//var val = sin(theta); // Another simple function
* @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
+
*/
6
+
functionsetup(){
7
+
createCanvas(710,400);
8
+
pixelDensity(1);
9
+
}
10
+
11
+
functiondraw(){
12
+
loadPixels();
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
+
21
+
letr;
22
+
lettheta;
23
+
letval;
24
+
25
+
letbw;//variable to store grayscale
26
+
leti;
27
+
letj;
28
+
letcols=width;
29
+
letrows=height;
30
+
31
+
for(i=0;i<cols;i+=1){
32
+
y=-h/2;
33
+
for(j=0;j<rows;j+=1){
34
+
r=sqrt(x*x+y*y);// Convert cartesian to polar
35
+
theta=atan2(y,x);// Convert cartesian to polar
36
+
// Compute 2D polar coordinate function
37
+
val=sin(n*cos(r)+5*theta);// Results in a value between -1 and 1
38
+
//var val = cos(r); // Another simple function
39
+
//var val = sin(theta); // Another simple function
* @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
+
*/
6
+
functionsetup(){
7
+
createCanvas(710,400);
8
+
pixelDensity(1);
9
+
}
10
+
11
+
functiondraw(){
12
+
loadPixels();
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
+
21
+
letr;
22
+
lettheta;
23
+
letval;
24
+
25
+
letbw;//variable to store grayscale
26
+
leti;
27
+
letj;
28
+
letcols=width;
29
+
letrows=height;
30
+
31
+
for(i=0;i<cols;i+=1){
32
+
y=-h/2;
33
+
for(j=0;j<rows;j+=1){
34
+
r=sqrt(x*x+y*y);// Convert cartesian to polar
35
+
theta=atan2(y,x);// Convert cartesian to polar
36
+
// Compute 2D polar coordinate function
37
+
val=sin(n*cos(r)+5*theta);// Results in a value between -1 and 1
38
+
//var val = cos(r); // Another simple function
39
+
//var val = sin(theta); // Another simple function
0 commit comments