-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsketch.js
111 lines (93 loc) · 2.93 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
var no_of_points;
var counter = 0;
let cnv;
//let mySound;
let song;
function windowResized() {
cnv=resizeCanvas(windowWidth, windowHeight);
background(0, 0, 0);
// textSize(16);
// let s = 'Hello There!! ';
// fill(1000);
// text(s, 10, 10, 700, 800);
// let s1 = 'This is Sandesh, Welcome to my github account ';
// fill(1000);
// text(s1, 10, 50, 7000, 1000);
// let s2 = 'I am C++ Developer, Working for Car Infotainment Systems at RBEI';
// fill(1000);
// text(s2, 10, 70, 7000, 1000);
// let s3 = 'I am just getting started here!. I look forward to some amazing collaberations ';
// fill(1000);
// text(s3, 10, 90, 7000, 1000);
// let s4 = 'Have a great day';
// fill(1000);
// text(s4, 10, 110, 7000, 1000);
}
function preload() {
soundFormats('mp3');
song = loadSound('maxkomusic-nature');
}
function setup() {
createCanvas(windowWidth, windowHeight);
cnv = createCanvas(windowWidth, windowHeight);
cnv.position(0,0);
cnv.style('z-index','-1');
cnv.mousePressed(canvasPressed);
//background(175);
background(0, 0, 0);
no_of_points = 2 * PI / 300;
// textSize(16);
// let s = 'Hello There!! ';
// fill(1000);
// text(s, 10, 10, 700, 800);
// let s1 = 'This is Sandesh, Welcome to my github account ';
// fill(1000);
// text(s1, 10, 50, 7000, 1000);
// let s2 = 'I am C++ Developer, Working for Car Infotainment Systems at RBEI';
// fill(1000);
// text(s2, 10, 70, 7000, 1000);
// let s3 = 'I am just getting started here!. I look forward to some amazing collaberations ';
// fill(1000);
// text(s3, 10, 90, 7000, 1000);
// let s4 = 'Have a great day';
// fill(1000);
// text(s4, 10, 110, 7000, 1000);
// link = createA('https://github.com/sandeshdevadiga', 'Check my projects here');
// //link want to set color and change text size, Can I do it?
// link.position(10, 130, 7000, 1000);
// link1 = createA('https://www.linkedin.com/in/sandeshdevadiga/', 'Connect');
// link1.position(10, 150, 7000, 1000);
frameRate(4);
stroke(0, 0, 0, 1005);
}
function canvasPressed() {
if (song.isPlaying()) {
song.pause();
}
else {
song.play();
}
}
function draw() {
// draw two random chords each frame
//delayTime(0.11);
randomChord();
randomChord();
}
function randomChord() {
let xpos1 = (windowWidth) / 4 * 3 - windowHeight*2 / 4 + (windowHeight)*2 / 4 * cos(no_of_points);
let ypos1 = (windowHeight) / 2 + (windowHeight) *2/ 4 * sin(no_of_points);
// find another random point on the circle
let angle2 = 2 * no_of_points;
let xpos2 = (windowWidth) / 4 * 3 - windowHeight *2/ 4 + (windowHeight)*2 / 4 * cos(angle2);
let ypos2 = (windowHeight) / 2 + (windowHeight)*2 / 4 * sin(angle2);
// draw a line between them
let R = random(0, 255);
let G = random(0, 255);
let B = random(0, 255);
stroke(R, G, B, 45);
line(xpos1, ypos1, xpos2, ypos2);
no_of_points = no_of_points * 2;
counter++;
//Want to autoplay sound !, How can I do it?
}