-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
213 lines (201 loc) · 5.35 KB
/
script.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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
document.addEventListener("DOMContentLoaded", () => {
particlesJS("particles-js", {
particles: {
number: {
value: 50,
density: {
enable: true,
value_area: 800,
},
},
color: {
value: "#ffffff",
},
shape: {
type: "circle",
},
opacity: {
value: 0.5,
random: false,
anim: {
enable: false,
},
},
size: {
value: 3,
random: true,
anim: {
enable: false,
},
},
line_linked: {
enable: true,
distance: 150,
color: "#ffffff",
opacity: 0.4,
width: 1,
},
move: {
enable: true,
speed: 2,
direction: "none",
random: false,
straight: false,
out_mode: "out",
bounce: false,
attract: {
enable: false,
rotateX: 600,
rotateY: 1200,
},
},
},
interactivity: {
detect_on: "canvas",
events: {
onhover: {
enable: true,
mode: "repulse",
},
onclick: {
enable: true,
mode: "push",
},
resize: true,
},
modes: {
grab: {
distance: 400,
line_linked: {
opacity: 1,
},
},
bubble: {
distance: 400,
size: 40,
duration: 2,
opacity: 8,
speed: 3,
},
repulse: {
distance: 200,
duration: 0.4,
},
push: {
particles_nb: 4,
},
remove: {
particles_nb: 2,
},
},
},
retina_detect: true,
});
});
const quotes = [
{
text: "The purpose of art is washing the dust of daily life off our souls.",
author: "Pablo Picasso",
},
{ text: "Creativity takes courage.", author: "Henri Matisse" },
{
text: "Art is not what you see, but what you make others see.",
author: "Edgar Degas",
},
{
text: "Art is the lie that enables us to realize the truth.",
author: "Pablo Picasso",
},
{ text: "Great art picks up where nature ends.", author: "Marc Chagall" },
];
function generateRandomQuote() {
const randomIndex = Math.floor(Math.random() * quotes.length);
const quote = quotes[randomIndex];
document.querySelector(".quote-text").innerText = quote.text;
document.querySelector(".quote-author").innerText = `- ${quote.author}`;
document.querySelector(".quote-text").style.display = "block";
document.querySelector(".quote-author").style.display = "block";
}
const userArt = [
{
title: "Sunset Dream",
creator: "Alice Wonderland",
imageURL: "https://example.com/images/sunset_dream.jpg",
},
{
title: "Urban Jungle",
creator: "Bob Smith",
imageURL: "https://example.com/images/urban_jungle.jpg",
},
{
title: "Ocean Serenity",
creator: "Charlie Brown",
imageURL: "https://example.com/images/ocean_serenity.jpg",
},
];
function generateRandomArt() {
const canvas = document.getElementById("artCanvas");
const ctx = canvas.getContext("2d");
ctx.clearRect(0, 0, canvas.width, canvas.height);
const shapeCount = Math.floor(Math.random() * 10) + 5;
for (let i = 0; i < shapeCount; i++) {
const randomShape = Math.floor(Math.random() * 3);
const randomColor = "#" + Math.floor(Math.random() * 16777215).toString(16);
ctx.fillStyle = randomColor;
switch (randomShape) {
case 0:
const x = Math.random() * canvas.width;
const y = Math.random() * canvas.height;
const radius = Math.random() * 50 + 10;
ctx.beginPath();
ctx.arc(x, y, radius, 0, 2 * Math.PI);
ctx.fill();
break;
case 1:
const width = Math.random() * 100 + 10;
const height = Math.random() * 100 + 10;
const xPos = Math.random() * (canvas.width - width);
const yPos = Math.random() * (canvas.height - height);
ctx.fillRect(xPos, yPos, width, height);
break;
case 2:
const sideLength = Math.random() * 100 + 10;
const x1 = Math.random() * (canvas.width - sideLength);
const y1 = Math.random() * (canvas.height - sideLength);
ctx.beginPath();
ctx.moveTo(x1, y1);
ctx.lineTo(x1 + sideLength / 2, y1 - sideLength / 2);
ctx.lineTo(x1 + sideLength, y1);
ctx.closePath();
ctx.fill();
break;
}
}
}
function setDailyColor() {
const today = new Date();
const dayOfYear = Math.floor(
(today - new Date(today.getFullYear(), 0, 0)) / (1000 * 60 * 60 * 24)
);
const hue = Math.floor((dayOfYear / 365) * 360);
const dailyColor = `hsl(${hue}, 50%, 60%)`;
// Display the color
const colorElement = document.querySelector(".color-of-the-day");
colorElement.textContent = dailyColor;
colorElement.style.backgroundColor = dailyColor;
}
function copyColorToClipboard() {
const color = document.querySelector(".color-of-the-day").textContent;
const tempInput = document.createElement("input");
document.body.appendChild(tempInput);
tempInput.value = color;
tempInput.select();
document.execCommand("copy");
document.body.removeChild(tempInput);
alert(`Copied the color ${color} to your clipboard!`);
}
function init() {
setDailyColor();
generateRandomArt();
}
document.addEventListener("DOMContentLoaded", init);