-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsketch.js
104 lines (81 loc) · 3.27 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
//ripples
let v = 40; //growth speed
let ripples = [];
let newRipples = [];
var r = 60; //radius
let alpha = 'fybslmsolohsqrxlobolwcvqfubntrytndypuctudyfsegtshsfmevfxkvgrytrkslmzyglahelmcyfyhvgeylvbrfwacptadofmcolcbspcrlsbelmevpfxhcfmyotzdcqcnlodalsyxqlrbotwrmctudegnrludstwayqlchatnnlvhsqnrfebrfmsaptskstwaufehcpyrlsbnlraspfsbzfnytrdrgeelckztmcugfedelnrlykompcrtxbctmysgfsbmytwastrdygectudrlmcogtskxlwaofxhzgszlahelwvsptzdulcufsbzgaslnkztsurgfvbvfwyzlzkzqnytcwhxtmyxgtubxlwyntckoqeztrdulwraqfobvfovtxhapncfxhrlwvxpfvhxflnxlskngcztahelmyvglybctmcefehuqoetrdutwzaglakxlmuetskuqzrfehvtmcnptohufwnytuwdugyefebrlweuqfedvlweyfekrpsomtubufwvuptndntwootekaqaufsdvtwuxqlzdvtmvclvhnqxstnhulwseqfzdrtseolykygnotykolwsegtykotmovtndegcotsbslwueqtodyfwuofchaqertobstwrcpfadsfmezfskzqyxfrkxtmysqtobzlwyalnbugortnhofwevpfekylmevfshrqoytndatmsuptnkyfwsztzbnpyztxkclwecqlshnfwvxlxhxgmxmztvbvtmoxpfckrfmvrtydvpocteknfmerqtcbulwxcfadzpcytabztmxnqfrdztmxsfyhzqrzfzdslmrvqtyhrfwrofrbuqvotxhalmszqtsdzfwzstobuqxrtcbvfwrcqtskotmxrfudsqeufxdztmncplubxfmaafrdrqeetukulfssgtckylmxutzkrgsolsdofsyqfydztwzvlrkrgustsdufmacqlohctwsntudagrylrhzlwayplydyfmnrlybzpszfcbufmuxqlakefwsvfudagzslvhofmnyqlvkvfwcvlcdnqyzlahxfwcuqtvbnlmsylskapcxlvdntwospfshefwxxfxdeqavlobotweoqfrbzfwacloknpculchvtmrxpfsdelwvelohrgyxlxbvtmeyg';
let counter = 0;
let s = 1;
let myFont;
function preload() {
myFont = loadFont('CloisterBlack.ttf');
}
function setup() {
var myCanvas = createCanvas(windowWidth / 2, windowHeight - 200);
myCanvas.parent("canvasdiv");
}
class Ripple {
constructor() {
this.x = mouseX;
this.y = mouseY;
this.r = r;
}
grow() {
this.r += v;
}
}
function draw() {
background(255);
let xgap = 18;
let ygap = 23;
let counter = 0
// Loop as long as there is space on the canvas
for (let y = 40; y < windowHeight - 250; y += ygap) {
for (let x = 20; x < (windowWidth/ 2) - 20; x += xgap) {
let letter = alpha[counter];
fill(0)
textFont(myFont)
textAlign(CENTER, BASELINE);
if (dist(x, y, mouseX, mouseY) < r) {
textSize(17), textFont('Times New Roman'), textStyle(ITALIC), fill(0);
}
// else if (dist(x ,y, mouseX, mouseY) >= r && dist(x,y, mouseX, mouseY) <= r + 60) {
// fill(0), textSize(18), textFont('Times New Roman'), textStyle(NORMAL);
// }
else {
textSize(25)
}
for (let i = 0; i < ripples.length; i++) {
if (dist(x, y, ripples[i].x, ripples[i].y) < ripples[i].r && dist(x, y, ripples[i].x, ripples[i].y) > ripples[i].r - 40){
fill(0), textSize(17), textFont('Times New Roman'), textStyle(NORMAL), fill(0);
}
}
// Draw the letter
text(letter, x, y);
// move to next letter
counter++
}
}
if (mouseIsPressed) {
append(ripples, new Ripple());
// console.log(ripples.length);
}
for (let i = 0; i < ripples.length; i++) {
ripples[i].grow();
// console.log(ripples[i].r)
}
for (let i = 0; i < ripples.length; i++) {
if (ripples[i].r <= 1200) {
append(newRipples, ripples[i])
}
}
ripples = newRipples;
newRipples = [];
}
function mouseClicked() {
append(ripples, new Ripple());
// console.log(ripples.length);
}
function windowResized() {
resizeCanvas(windowWidth, windowHeight);
}