-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsketch.js
116 lines (92 loc) · 2.1 KB
/
sketch.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/*
code taken from http://ibiblio.org/e-notes/html5/lis/lissa5.htm
*/
var aS = [];
var rad = 199;
var Max = 3*360, m1 = Max-1, m2 = Max/2;
var iXo = 0, iYo = m2/2;
//var parN = 2, parM = 1;
var parN = 1, parM = 1;
var sel;
var arr = [1,2,3,4,5,6,7];
var fr;
function setup() {
frameRate(fr);
createCanvas(640, 480);
textSize(15);
// slider = createSlider( 0, TWO_PI, PI);
nSlider = createSlider(1, 7, 1), nSlider.position( 500, 100);
mSlider = createSlider(1, 6, 1), mSlider.position( 500, 300);
// slider.position( 500, 100);
background(200);
// selectorN();
// selectorM();
sf = sin(3.14159265/m2);
cf = cos(3.14159265/m2);
s = -sf;
c = cf;
for (var i = 0; i < m2; i++) {
s1 = s*cf + c*sf;
c = c*cf - s*sf; s = s1;
aS[i] = round(rad*(1.0+s))+1;
aS[i+m2] = round(rad*(1.0-s))+1;
}
}
function draw() {
var n = nSlider.value(), parN = parseInt(n);
var m = mSlider.value(); parM = parseInt(m);
background(200);
noFill();
strokeWeight(4);
// stroke(100, 120);
stroke(100);
translate(width/10, height/8);
Xo = aS[iXo];
Yo = aS[iYo];
for (var j = Max; j > 0; j--) {
iX = (iXo + parM) % Max;
iY = (iYo + parN) % m1;
X = aS[iX];
Y = aS[iY];
point(X, Y);
// if(frameCount%30 == 0) console.log(X + " " + Y);
iXo = iX;
iYo = iY;
Xo = X;
Yo = Y;
}
// if(frameCount%30 == 0) console.log( slider.value() );
}
/*
function sliderVal() {
var N = slider.value()
if(frameCount%30 == 0) console.log( (slider).value() );
parN = parseInt (N);
}
*/
/*
function selectorN() {
// textAlign(CENTER);
sel = createSelect();
sel.position(60, 10);
for(var N = 0; N < arr.length; N++) sel.option(arr[N]);
sel.changed(selectN);
}
function selectN() {
var N = sel.value();
console.log("N = " + N);
parN = parseInt(N);
}
function selectorM() {
// textAlign(CENTER);
sel = createSelect();
sel.position(60, 40);
for(var M = 0; M < arr.length - 1; M++) sel.option(arr[M]);
sel.changed(selectM);
}
function selectM() {
var M = sel.value();
console.log("M = " + M);
parM = parseInt(M);
}
*/