-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
64 lines (56 loc) · 1.04 KB
/
main.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
let x,y;
let first = 1;
let rotationMode = 0;
let changeModeCount = 0;
let space = 5;
let countLimit = 1;
let countTempLimit = 0;
let endNum = 100;
let fontSize = 4;
let canvasSize = 700;
function setup() {
createCanvas(canvasSize, canvasSize);
background(0);
x = width / 2;
y = height / 2;
}
function isPrime(val) {
for(let i = 2; i <= sqrt(val);i++ ){
if(val%i==0) return false;
}
return true;
}
function draw() {
strokeWeight(fontSize);
textAlign(CENTER, CENTER);
stroke(255);
if(isPrime(first)){
point(x,y);
}
if(countTempLimit == countLimit){
rotationMode += 1;
countTempLimit = 0;
changeModeCount += 1;
if(changeModeCount == 2){
countLimit += 1;
changeModeCount = 0;
}
}
switch(rotationMode % 4){
case 0:
x += space;
break;
case 1:
y -= space;
break;
case 2:
x -= space;
break;
case 3:
y += space;
break;
}
countTempLimit += 1;
first += 1;
if(first == endNum*endNum + 1) noLoop();
}