@amphore-dev/shades 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +317 -0
- package/dist/classes/ShadesEngine.d.ts +65 -0
- package/dist/classes/ShadesEngine.d.ts.map +1 -0
- package/dist/classes/ShadesEngine.js +386 -0
- package/dist/classes/ShadesEngine.js.map +1 -0
- package/dist/classes/index.d.ts +3 -0
- package/dist/classes/index.d.ts.map +1 -0
- package/dist/classes/index.js +3 -0
- package/dist/classes/index.js.map +1 -0
- package/dist/classes/shapes/BaseShape.d.ts +20 -0
- package/dist/classes/shapes/BaseShape.d.ts.map +1 -0
- package/dist/classes/shapes/BaseShape.js +45 -0
- package/dist/classes/shapes/BaseShape.js.map +1 -0
- package/dist/classes/shapes/CircleShape.d.ts +11 -0
- package/dist/classes/shapes/CircleShape.d.ts.map +1 -0
- package/dist/classes/shapes/CircleShape.js +25 -0
- package/dist/classes/shapes/CircleShape.js.map +1 -0
- package/dist/classes/shapes/ImageShape.d.ts +22 -0
- package/dist/classes/shapes/ImageShape.d.ts.map +1 -0
- package/dist/classes/shapes/ImageShape.js +107 -0
- package/dist/classes/shapes/ImageShape.js.map +1 -0
- package/dist/classes/shapes/SpiralShape.d.ts +11 -0
- package/dist/classes/shapes/SpiralShape.d.ts.map +1 -0
- package/dist/classes/shapes/SpiralShape.js +28 -0
- package/dist/classes/shapes/SpiralShape.js.map +1 -0
- package/dist/classes/shapes/SquaredShape.d.ts +11 -0
- package/dist/classes/shapes/SquaredShape.d.ts.map +1 -0
- package/dist/classes/shapes/SquaredShape.js +25 -0
- package/dist/classes/shapes/SquaredShape.js.map +1 -0
- package/dist/classes/shapes/TextShape.d.ts +16 -0
- package/dist/classes/shapes/TextShape.d.ts.map +1 -0
- package/dist/classes/shapes/TextShape.js +35 -0
- package/dist/classes/shapes/TextShape.js.map +1 -0
- package/dist/classes/shapes/TriangleShape.d.ts +11 -0
- package/dist/classes/shapes/TriangleShape.d.ts.map +1 -0
- package/dist/classes/shapes/TriangleShape.js +46 -0
- package/dist/classes/shapes/TriangleShape.js.map +1 -0
- package/dist/classes/shapes/index.d.ts +8 -0
- package/dist/classes/shapes/index.d.ts.map +1 -0
- package/dist/classes/shapes/index.js +10 -0
- package/dist/classes/shapes/index.js.map +1 -0
- package/dist/constants/CColors.d.ts +6 -0
- package/dist/constants/CColors.d.ts.map +1 -0
- package/dist/constants/CColors.js +35 -0
- package/dist/constants/CColors.js.map +1 -0
- package/dist/constants/CFilters.d.ts +8 -0
- package/dist/constants/CFilters.d.ts.map +1 -0
- package/dist/constants/CFilters.js +15 -0
- package/dist/constants/CFilters.js.map +1 -0
- package/dist/constants/CShades.d.ts +3 -0
- package/dist/constants/CShades.d.ts.map +1 -0
- package/dist/constants/CShades.js +10 -0
- package/dist/constants/CShades.js.map +1 -0
- package/dist/constants/index.d.ts +4 -0
- package/dist/constants/index.d.ts.map +1 -0
- package/dist/constants/index.js +4 -0
- package/dist/constants/index.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/types/TPoints.d.ts +8 -0
- package/dist/types/TPoints.d.ts.map +1 -0
- package/dist/types/TPoints.js +2 -0
- package/dist/types/TPoints.js.map +1 -0
- package/dist/types/TShadeItem.d.ts +6 -0
- package/dist/types/TShadeItem.d.ts.map +1 -0
- package/dist/types/TShadeItem.js +2 -0
- package/dist/types/TShadeItem.js.map +1 -0
- package/dist/types/TShades.d.ts +11 -0
- package/dist/types/TShades.d.ts.map +1 -0
- package/dist/types/TShades.js +10 -0
- package/dist/types/TShades.js.map +1 -0
- package/dist/types/TShadesConfig.d.ts +26 -0
- package/dist/types/TShadesConfig.d.ts.map +1 -0
- package/dist/types/TShadesConfig.js +2 -0
- package/dist/types/TShadesConfig.js.map +1 -0
- package/dist/types/TShapeOptions.d.ts +6 -0
- package/dist/types/TShapeOptions.d.ts.map +1 -0
- package/dist/types/TShapeOptions.js +2 -0
- package/dist/types/TShapeOptions.js.map +1 -0
- package/dist/types/index.d.ts +6 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +6 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/UColors.d.ts +18 -0
- package/dist/utils/UColors.d.ts.map +1 -0
- package/dist/utils/UColors.js +44 -0
- package/dist/utils/UColors.js.map +1 -0
- package/dist/utils/UMaths.d.ts +9 -0
- package/dist/utils/UMaths.d.ts.map +1 -0
- package/dist/utils/UMaths.js +14 -0
- package/dist/utils/UMaths.js.map +1 -0
- package/dist/utils/UShadeUtils.d.ts +8 -0
- package/dist/utils/UShadeUtils.d.ts.map +1 -0
- package/dist/utils/UShadeUtils.js +75 -0
- package/dist/utils/UShadeUtils.js.map +1 -0
- package/dist/utils/index.d.ts +4 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +4 -0
- package/dist/utils/index.js.map +1 -0
- package/package.json +71 -0
|
@@ -0,0 +1,386 @@
|
|
|
1
|
+
import { TextShape, ImageShape } from "./index.js";
|
|
2
|
+
import { SHADES_TYPES_CONSTRUCTORS_LIST, } from "../types/index.js";
|
|
3
|
+
import { HOME_COLORS, MAX_SHADES_NBR } from "../constants/index.js";
|
|
4
|
+
import { genConfig, getRandColors, random } from "../utils/index.js";
|
|
5
|
+
export class ShadesEngine {
|
|
6
|
+
canvas;
|
|
7
|
+
context;
|
|
8
|
+
options;
|
|
9
|
+
// Internal state (previously React useRef equivalents)
|
|
10
|
+
items = [];
|
|
11
|
+
config;
|
|
12
|
+
offset = { x: 0, y: 0 };
|
|
13
|
+
targetOffset = { x: 0, y: 0 };
|
|
14
|
+
genCount = 0;
|
|
15
|
+
fade = {
|
|
16
|
+
isFading: true,
|
|
17
|
+
opacity: 0,
|
|
18
|
+
targetOpacity: 1,
|
|
19
|
+
startOpacity: 0,
|
|
20
|
+
startTime: 0,
|
|
21
|
+
onDone: () => { },
|
|
22
|
+
};
|
|
23
|
+
// Animation
|
|
24
|
+
animationFrameId = null;
|
|
25
|
+
isPlaying = false;
|
|
26
|
+
elapsedTime = 1;
|
|
27
|
+
framesCount = { count: 0, fps: 0 };
|
|
28
|
+
// Event handlers
|
|
29
|
+
boundHandleClick;
|
|
30
|
+
boundHandleMouseMove;
|
|
31
|
+
boundHandleWheel;
|
|
32
|
+
boundHandleResize;
|
|
33
|
+
// Debug
|
|
34
|
+
debug = false;
|
|
35
|
+
debugContainer = null;
|
|
36
|
+
constructor(canvas, options = {}) {
|
|
37
|
+
this.canvas = canvas;
|
|
38
|
+
this.options = options;
|
|
39
|
+
const context = canvas.getContext("2d");
|
|
40
|
+
if (!context) {
|
|
41
|
+
throw new Error("Cannot get 2D context from canvas");
|
|
42
|
+
}
|
|
43
|
+
this.context = context;
|
|
44
|
+
this.config = genConfig(this.options);
|
|
45
|
+
// Initialize startTime and startOpacity for the first fade
|
|
46
|
+
this.fade.startTime = performance.now();
|
|
47
|
+
this.fade.startOpacity = 0;
|
|
48
|
+
// Bind event handlers
|
|
49
|
+
this.boundHandleClick = this.handleClick.bind(this);
|
|
50
|
+
this.boundHandleMouseMove = this.handleMouseMove.bind(this);
|
|
51
|
+
this.boundHandleWheel = this.handleWheel.bind(this);
|
|
52
|
+
this.boundHandleResize = this.handleResize.bind(this);
|
|
53
|
+
this.setupCanvas();
|
|
54
|
+
this.initializeDebug();
|
|
55
|
+
}
|
|
56
|
+
setupCanvas() {
|
|
57
|
+
this.canvas.width = this.canvas.clientWidth;
|
|
58
|
+
this.canvas.height = this.canvas.clientHeight;
|
|
59
|
+
}
|
|
60
|
+
generate() {
|
|
61
|
+
this.attachEventListeners();
|
|
62
|
+
// Wait for fonts to be ready (comme dans le code original)
|
|
63
|
+
if (document.fonts) {
|
|
64
|
+
document.fonts.ready.then(() => {
|
|
65
|
+
this.config = {
|
|
66
|
+
...this.config,
|
|
67
|
+
nbrItemsX: 1,
|
|
68
|
+
nbrItemsY: 1,
|
|
69
|
+
nbrShades: 10,
|
|
70
|
+
gradRatio: 100 / 10,
|
|
71
|
+
width: document.body.clientWidth / 6,
|
|
72
|
+
height: document.body.clientWidth / 6,
|
|
73
|
+
};
|
|
74
|
+
this.genItems(TextShape, HOME_COLORS[random(0, HOME_COLORS.length - 1, true)]);
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
this.initDefaultGeneration();
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
initDefaultGeneration() {
|
|
82
|
+
this.config = {
|
|
83
|
+
...this.config,
|
|
84
|
+
nbrItemsX: 1,
|
|
85
|
+
nbrItemsY: 1,
|
|
86
|
+
nbrShades: 10,
|
|
87
|
+
gradRatio: 100 / 10,
|
|
88
|
+
width: document.body.clientWidth / 6,
|
|
89
|
+
height: document.body.clientWidth / 6,
|
|
90
|
+
};
|
|
91
|
+
this.genItems(TextShape, HOME_COLORS[random(0, HOME_COLORS.length - 1, true)]);
|
|
92
|
+
}
|
|
93
|
+
getConfig() {
|
|
94
|
+
const config = this.config;
|
|
95
|
+
// maybe used later for external config provision, but for now we just return the current config
|
|
96
|
+
return { ...config };
|
|
97
|
+
}
|
|
98
|
+
genItems(constructor, forceColor) {
|
|
99
|
+
const config = this.getConfig();
|
|
100
|
+
const { width, height, spacing, nbrItemsX, nbrItemsY, type, rotationFilter, fillFilter, colors: configColors, mainColor: configMainColor, } = config;
|
|
101
|
+
const items = [];
|
|
102
|
+
// For genCount > 1), ignore configColors and generate new colors
|
|
103
|
+
const colors = this.genCount > 1
|
|
104
|
+
? getRandColors(type)
|
|
105
|
+
: configColors?.length
|
|
106
|
+
? configColors
|
|
107
|
+
: Array.isArray(forceColor)
|
|
108
|
+
? forceColor
|
|
109
|
+
: getRandColors(type);
|
|
110
|
+
const color = forceColor && !Array.isArray(forceColor) ? forceColor : undefined;
|
|
111
|
+
const mainColor = configMainColor ?? colors[random(0, colors.length - 1, true)];
|
|
112
|
+
const ShadeConstructor = constructor ??
|
|
113
|
+
this.options.customShapes?.[type] ??
|
|
114
|
+
SHADES_TYPES_CONSTRUCTORS_LIST[type];
|
|
115
|
+
for (let x = 0; x < nbrItemsX; x++) {
|
|
116
|
+
for (let y = 0; y < nbrItemsY; y++) {
|
|
117
|
+
const index = random(0, colors.length - 1, true);
|
|
118
|
+
const itemColor = colors[index];
|
|
119
|
+
items.push(new ShadeConstructor(x * width + x * spacing, y * height + y * spacing, color ?? itemColor, {
|
|
120
|
+
filled: fillFilter?.(mainColor, color ?? itemColor),
|
|
121
|
+
rotation: rotationFilter?.(mainColor, color ?? itemColor),
|
|
122
|
+
lineCap: config.lineCap,
|
|
123
|
+
...(constructor === ImageShape ? { imageSource: undefined } : {}),
|
|
124
|
+
}));
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
this.config = {
|
|
128
|
+
...this.config,
|
|
129
|
+
...config,
|
|
130
|
+
rotationFilter,
|
|
131
|
+
fillFilter,
|
|
132
|
+
colors,
|
|
133
|
+
mainColor,
|
|
134
|
+
totalWidth: nbrItemsX * width + (nbrItemsX - 1) * spacing,
|
|
135
|
+
totalHeight: nbrItemsY * height + (nbrItemsY - 1) * spacing,
|
|
136
|
+
};
|
|
137
|
+
this.items = items;
|
|
138
|
+
this.genCount++;
|
|
139
|
+
}
|
|
140
|
+
animate() {
|
|
141
|
+
if (!this.isPlaying)
|
|
142
|
+
return;
|
|
143
|
+
const start = performance.now();
|
|
144
|
+
this.context.clearRect(0, 0, this.canvas.width + 2, this.canvas.height + 2);
|
|
145
|
+
this.context.lineWidth = this.config.thickness;
|
|
146
|
+
this.items.forEach((item) => {
|
|
147
|
+
item.draw(this.context, this.config, this.offset);
|
|
148
|
+
});
|
|
149
|
+
// Smooth offset animation
|
|
150
|
+
const step = 0.1;
|
|
151
|
+
this.offset = {
|
|
152
|
+
x: (this.targetOffset.x - this.offset.x) * step + this.offset.x,
|
|
153
|
+
y: (this.targetOffset.y - this.offset.y) * step + this.offset.y,
|
|
154
|
+
};
|
|
155
|
+
if (this.offset.x !== this.targetOffset.x &&
|
|
156
|
+
Math.abs(this.offset.x - this.targetOffset.x) < 1) {
|
|
157
|
+
this.offset.x = this.targetOffset.x;
|
|
158
|
+
}
|
|
159
|
+
if (this.offset.y !== this.targetOffset.y &&
|
|
160
|
+
Math.abs(this.offset.y - this.targetOffset.y) < 1) {
|
|
161
|
+
this.offset.y = this.targetOffset.y;
|
|
162
|
+
}
|
|
163
|
+
// Fade animation
|
|
164
|
+
if (this.fade.isFading) {
|
|
165
|
+
const fadeDuration = (this.options.fadeDuration ?? 1000) / (this.genCount ? 2 : 1); // Speed up fade for subsequent generations (fade duration = fadeIn + fadeOut)
|
|
166
|
+
const currentTime = performance.now();
|
|
167
|
+
const { targetOpacity, startTime, onDone } = this.fade;
|
|
168
|
+
// Calculate progress based on elapsed real time
|
|
169
|
+
const elapsed = currentTime - startTime;
|
|
170
|
+
const progress = Math.min(elapsed / fadeDuration, 1);
|
|
171
|
+
// Interpolate between startOpacity and targetOpacity
|
|
172
|
+
const { startOpacity } = this.fade;
|
|
173
|
+
this.fade.opacity =
|
|
174
|
+
startOpacity + (targetOpacity - startOpacity) * progress;
|
|
175
|
+
// Fade completed
|
|
176
|
+
if (progress >= 1) {
|
|
177
|
+
this.fade.opacity = targetOpacity;
|
|
178
|
+
this.fade.isFading = false;
|
|
179
|
+
if (targetOpacity === 0) {
|
|
180
|
+
onDone();
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
// Apply fade overlay
|
|
185
|
+
this.context.fillStyle = `rgba(0,0,0,${1 - this.fade.opacity})`;
|
|
186
|
+
this.context.fillRect(0, 0, this.canvas.width, this.canvas.height);
|
|
187
|
+
const stop = performance.now();
|
|
188
|
+
this.elapsedTime = stop - start;
|
|
189
|
+
this.framesCount.count++;
|
|
190
|
+
if (this.options.debug) {
|
|
191
|
+
this.updateDebug();
|
|
192
|
+
}
|
|
193
|
+
this.animationFrameId = requestAnimationFrame(() => this.animate());
|
|
194
|
+
}
|
|
195
|
+
getCenter() {
|
|
196
|
+
return {
|
|
197
|
+
x: this.canvas.clientWidth / 2,
|
|
198
|
+
y: this.canvas.clientHeight / 2,
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
handleMouseMove(event) {
|
|
202
|
+
const center = this.getCenter();
|
|
203
|
+
this.targetOffset = {
|
|
204
|
+
x: event.clientX - center.x,
|
|
205
|
+
y: event.clientY - center.y,
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
zoomShades(scale) {
|
|
209
|
+
const nbrShades = this.config.nbrShades;
|
|
210
|
+
let newValue = nbrShades + scale;
|
|
211
|
+
if (newValue < 1)
|
|
212
|
+
newValue = 1;
|
|
213
|
+
else if (newValue > MAX_SHADES_NBR)
|
|
214
|
+
newValue = MAX_SHADES_NBR;
|
|
215
|
+
this.config = {
|
|
216
|
+
...this.config,
|
|
217
|
+
nbrShades: newValue,
|
|
218
|
+
gradRatio: 100 / newValue,
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
handleWheel(event) {
|
|
222
|
+
event.preventDefault();
|
|
223
|
+
const forceScroll = event.deltaY;
|
|
224
|
+
if (forceScroll < 0)
|
|
225
|
+
return this.zoomShades(0.1);
|
|
226
|
+
if (forceScroll > 0)
|
|
227
|
+
return this.zoomShades(-0.1);
|
|
228
|
+
}
|
|
229
|
+
handleClick() {
|
|
230
|
+
if (this.fade.isFading && this.fade.targetOpacity === 0)
|
|
231
|
+
return;
|
|
232
|
+
// Keep current opacity as the starting point for fade out
|
|
233
|
+
const currentOpacity = this.fade.opacity;
|
|
234
|
+
this.fade = {
|
|
235
|
+
...this.fade,
|
|
236
|
+
isFading: true,
|
|
237
|
+
startOpacity: currentOpacity,
|
|
238
|
+
targetOpacity: 0,
|
|
239
|
+
startTime: performance.now(),
|
|
240
|
+
onDone: () => {
|
|
241
|
+
this.fade = {
|
|
242
|
+
...this.fade,
|
|
243
|
+
isFading: true,
|
|
244
|
+
startOpacity: 0,
|
|
245
|
+
targetOpacity: 1,
|
|
246
|
+
startTime: performance.now(),
|
|
247
|
+
onDone: () => { },
|
|
248
|
+
};
|
|
249
|
+
this.config = genConfig(this.options);
|
|
250
|
+
this.genItems();
|
|
251
|
+
},
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
handleResize() {
|
|
255
|
+
this.canvas.width = this.canvas.clientWidth;
|
|
256
|
+
this.canvas.height = this.canvas.clientHeight;
|
|
257
|
+
this.config = {
|
|
258
|
+
...this.config,
|
|
259
|
+
center: this.getCenter(),
|
|
260
|
+
};
|
|
261
|
+
this.offset = { x: 0, y: 0 };
|
|
262
|
+
}
|
|
263
|
+
attachEventListeners() {
|
|
264
|
+
this.canvas.addEventListener("click", this.boundHandleClick);
|
|
265
|
+
this.canvas.addEventListener("wheel", this.boundHandleWheel);
|
|
266
|
+
document.addEventListener("mousemove", this.boundHandleMouseMove);
|
|
267
|
+
window.addEventListener("resize", this.boundHandleResize);
|
|
268
|
+
}
|
|
269
|
+
detachEventListeners() {
|
|
270
|
+
this.canvas.removeEventListener("click", this.boundHandleClick);
|
|
271
|
+
this.canvas.removeEventListener("wheel", this.boundHandleWheel);
|
|
272
|
+
document.removeEventListener("mousemove", this.boundHandleMouseMove);
|
|
273
|
+
window.removeEventListener("resize", this.boundHandleResize);
|
|
274
|
+
}
|
|
275
|
+
// Public API methods for external interaction
|
|
276
|
+
start() {
|
|
277
|
+
if (this.isPlaying)
|
|
278
|
+
return;
|
|
279
|
+
this.isPlaying = true;
|
|
280
|
+
this.animate();
|
|
281
|
+
this.startFPSCounter();
|
|
282
|
+
}
|
|
283
|
+
pause() {
|
|
284
|
+
this.isPlaying = false;
|
|
285
|
+
if (this.animationFrameId) {
|
|
286
|
+
cancelAnimationFrame(this.animationFrameId);
|
|
287
|
+
this.animationFrameId = null;
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
destroy() {
|
|
291
|
+
this.pause();
|
|
292
|
+
this.detachEventListeners();
|
|
293
|
+
// Clean up debug element
|
|
294
|
+
if (this.debugContainer) {
|
|
295
|
+
this.debugContainer.remove();
|
|
296
|
+
this.debugContainer = null;
|
|
297
|
+
}
|
|
298
|
+
// Reset state
|
|
299
|
+
this.items = [];
|
|
300
|
+
this.genCount = 0;
|
|
301
|
+
this.offset = { x: 0, y: 0 };
|
|
302
|
+
this.targetOffset = { x: 0, y: 0 };
|
|
303
|
+
}
|
|
304
|
+
regenerate() {
|
|
305
|
+
this.handleClick();
|
|
306
|
+
}
|
|
307
|
+
getShadesConfig() {
|
|
308
|
+
return { ...this.config };
|
|
309
|
+
}
|
|
310
|
+
getItems() {
|
|
311
|
+
return [...this.items];
|
|
312
|
+
}
|
|
313
|
+
isAnimating() {
|
|
314
|
+
return this.isPlaying;
|
|
315
|
+
}
|
|
316
|
+
zoom(scale) {
|
|
317
|
+
this.zoomShades(scale);
|
|
318
|
+
}
|
|
319
|
+
// Debug methods
|
|
320
|
+
initializeDebug() {
|
|
321
|
+
if (this.options.debug) {
|
|
322
|
+
const debugElement = document.createElement("pre");
|
|
323
|
+
debugElement.className =
|
|
324
|
+
typeof this.options.debug === "object" && this.options.debug.className
|
|
325
|
+
? this.options.debug.className
|
|
326
|
+
: "shades-debug";
|
|
327
|
+
debugElement.style.cssText = `
|
|
328
|
+
position: absolute;
|
|
329
|
+
bottom: 0;
|
|
330
|
+
left: 0;
|
|
331
|
+
z-index: 10;
|
|
332
|
+
color: white;
|
|
333
|
+
text-align: left;
|
|
334
|
+
font-family: monospace;
|
|
335
|
+
font-size: 12px;
|
|
336
|
+
background: rgba(0,0,0,0.5);
|
|
337
|
+
padding: 10px;
|
|
338
|
+
pointer-events: none;
|
|
339
|
+
`;
|
|
340
|
+
// Insert before canvas in DOM
|
|
341
|
+
this.canvas.parentNode?.insertBefore(debugElement, this.canvas);
|
|
342
|
+
this.debugContainer = debugElement;
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
startFPSCounter() {
|
|
346
|
+
setInterval(() => {
|
|
347
|
+
this.framesCount = {
|
|
348
|
+
count: 0,
|
|
349
|
+
fps: this.framesCount.count,
|
|
350
|
+
};
|
|
351
|
+
}, 1000);
|
|
352
|
+
}
|
|
353
|
+
updateDebug() {
|
|
354
|
+
const debugElement = this.debugContainer;
|
|
355
|
+
if (debugElement) {
|
|
356
|
+
debugElement.innerHTML = `
|
|
357
|
+
Width: ${this.canvas.width}
|
|
358
|
+
Height: ${this.canvas.height}
|
|
359
|
+
IsPlaying: ${this.isPlaying}
|
|
360
|
+
Elapsed Time: ${this.elapsedTime.toFixed(2)}ms
|
|
361
|
+
FPS: ${this.framesCount.fps}
|
|
362
|
+
Items: ${this.items.length}
|
|
363
|
+
Generation: ${this.genCount}
|
|
364
|
+
`.trim();
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
getDebugInfo() {
|
|
368
|
+
return {
|
|
369
|
+
genCount: this.genCount,
|
|
370
|
+
config: { ...this.config },
|
|
371
|
+
};
|
|
372
|
+
}
|
|
373
|
+
setDebug(value) {
|
|
374
|
+
this.options.debug = value;
|
|
375
|
+
if (value) {
|
|
376
|
+
this.initializeDebug();
|
|
377
|
+
}
|
|
378
|
+
else {
|
|
379
|
+
const debugElement = document.querySelector(".shades-debug");
|
|
380
|
+
if (debugElement) {
|
|
381
|
+
debugElement.remove();
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
//# sourceMappingURL=ShadesEngine.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ShadesEngine.js","sourceRoot":"","sources":["../../src/classes/ShadesEngine.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,SAAS,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC9D,OAAO,EAIL,8BAA8B,GAG/B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACpE,OAAO,EAAE,SAAS,E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QAAQ,CAAC,aAAa,CAAC,eAAe,CAAC,CAAC;YAC7D,IAAI,YAAY,EAAE,CAAC;gBACjB,YAAY,CAAC,MAAM,EAAE,CAAC;YACxB,CAAC;QACH,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/classes/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/classes/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { TShadeColor, TShadeConfig, TShadeType, TShapeOptions } from "../../types/index.js";
|
|
2
|
+
import { TPoint } from "../../types/TPoints.js";
|
|
3
|
+
/**
|
|
4
|
+
* Base class for all shape types
|
|
5
|
+
*/
|
|
6
|
+
export declare class ShadeItem {
|
|
7
|
+
id: string;
|
|
8
|
+
position: TPoint;
|
|
9
|
+
angle: number;
|
|
10
|
+
rotation: boolean;
|
|
11
|
+
color: TShadeColor;
|
|
12
|
+
type: TShadeType;
|
|
13
|
+
filled: boolean;
|
|
14
|
+
lineCap: "butt" | "round" | "square";
|
|
15
|
+
constructor(x: number, y: number, color: TShadeColor, options?: TShapeOptions);
|
|
16
|
+
draw: (ctx: CanvasRenderingContext2D, config: TShadeConfig, offset: TPoint) => void;
|
|
17
|
+
drawPath: (ctx: CanvasRenderingContext2D) => void;
|
|
18
|
+
setColors: (ctx: CanvasRenderingContext2D, gradRatio: number, i: number) => void;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=BaseShape.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BaseShape.d.ts","sourceRoot":"","sources":["../../../src/classes/shapes/BaseShape.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,YAAY,EACZ,UAAU,EACV,aAAa,EACd,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAEhD;;GAEG;AACH,qBAAa,SAAS;IACpB,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAK;IAClB,QAAQ,EAAE,OAAO,CAAS;IAC1B,KAAK,EAAE,WAAW,CAAC;IACnB,IAAI,EAAE,UAAU,CAAY;IAC5B,MAAM,EAAE,OAAO,CAAS;IACxB,OAAO,EAAE,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAU;gBAG5C,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,KAAK,EAAE,WAAW,EAClB,OAAO,GAAE,aAAkB;IAa7B,IAAI,GACF,KAAK,wBAAwB,EAC7B,QAAQ,YAAY,EACpB,QAAQ,MAAM,UAGd;IAEF,QAAQ,GAAI,KAAK,wBAAwB,UAOvC;IAEF,SAAS,GAAI,KAAK,wBAAwB,EAAE,WAAW,MAAM,EAAE,GAAG,MAAM,UAOtE;CACH"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base class for all shape types
|
|
3
|
+
*/
|
|
4
|
+
export class ShadeItem {
|
|
5
|
+
id;
|
|
6
|
+
position;
|
|
7
|
+
angle = 0;
|
|
8
|
+
rotation = false;
|
|
9
|
+
color;
|
|
10
|
+
type = "circle";
|
|
11
|
+
filled = false;
|
|
12
|
+
lineCap = "butt";
|
|
13
|
+
constructor(x, y, color, options = {}) {
|
|
14
|
+
// random id
|
|
15
|
+
this.id = Math.random().toString(36).slice(2, 10);
|
|
16
|
+
this.position = { x, y };
|
|
17
|
+
this.color = color;
|
|
18
|
+
// Apply options with defaults
|
|
19
|
+
this.filled = options.filled ?? false;
|
|
20
|
+
this.rotation = options.rotation ?? false;
|
|
21
|
+
this.lineCap = options.lineCap ?? "butt";
|
|
22
|
+
}
|
|
23
|
+
draw = (ctx, config, offset) => {
|
|
24
|
+
console.warn("draw method not implemented");
|
|
25
|
+
};
|
|
26
|
+
drawPath = (ctx) => {
|
|
27
|
+
const savedLineCap = ctx.lineCap;
|
|
28
|
+
ctx.lineCap = this.lineCap;
|
|
29
|
+
if (this.filled)
|
|
30
|
+
ctx.fill();
|
|
31
|
+
else
|
|
32
|
+
ctx.stroke();
|
|
33
|
+
ctx.lineCap = savedLineCap;
|
|
34
|
+
};
|
|
35
|
+
setColors = (ctx, gradRatio, i) => {
|
|
36
|
+
if (!this.color)
|
|
37
|
+
return;
|
|
38
|
+
const { r, g, b } = this.color;
|
|
39
|
+
if (this.filled)
|
|
40
|
+
ctx.fillStyle = `rgba(${r}, ${g}, ${b}, ${1 - (gradRatio * i) / 100})`;
|
|
41
|
+
else
|
|
42
|
+
ctx.strokeStyle = `rgba(${r}, ${g}, ${b}, ${1 - (gradRatio * i) / 100})`;
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=BaseShape.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BaseShape.js","sourceRoot":"","sources":["../../../src/classes/shapes/BaseShape.ts"],"names":[],"mappings":"AAQA;;GAEG;AACH,MAAM,OAAO,SAAS;IACpB,EAAE,CAAS;IACX,QAAQ,CAAS;IACjB,KAAK,GAAW,CAAC,CAAC;IAClB,QAAQ,GAAY,KAAK,CAAC;IAC1B,KAAK,CAAc;IACnB,IAAI,GAAe,QAAQ,CAAC;IAC5B,MAAM,GAAY,KAAK,CAAC;IACxB,OAAO,GAAgC,MAAM,CAAC;IAE9C,YACE,CAAS,EACT,CAAS,EACT,KAAkB,EAClB,UAAyB,EAAE;QAE3B,YAAY;QACZ,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC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,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,SAAS,GAAG,CAAC,CAAC,GAAG,GAAG,GAAG,CAAC;IAC7E,CAAC,CAAC;CACH"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { TShadeColor, TShadeConfig, TShapeOptions } from "../../types/index.js";
|
|
2
|
+
import { TPoint } from "../../types/TPoints.js";
|
|
3
|
+
import { ShadeItem } from "./BaseShape.js";
|
|
4
|
+
/**
|
|
5
|
+
* Circle shape implementation
|
|
6
|
+
*/
|
|
7
|
+
export declare class CircleShape extends ShadeItem {
|
|
8
|
+
constructor(x: number, y: number, color: TShadeColor, options?: TShapeOptions);
|
|
9
|
+
draw: (ctx: CanvasRenderingContext2D, config: TShadeConfig, offset: TPoint) => void;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=CircleShape.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CircleShape.d.ts","sourceRoot":"","sources":["../../../src/classes/shapes/CircleShape.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAChF,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C;;GAEG;AACH,qBAAa,WAAY,SAAQ,SAAS;gBAEtC,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,KAAK,EAAE,WAAW,EAClB,OAAO,GAAE,aAAkB;IAM7B,IAAI,GACF,KAAK,wBAAwB,EAC7B,QAAQ,YAAY,EACpB,QAAQ,MAAM,UAwBd;CACH"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ShadeItem } from "./BaseShape.js";
|
|
2
|
+
/**
|
|
3
|
+
* Circle shape implementation
|
|
4
|
+
*/
|
|
5
|
+
export class CircleShape extends ShadeItem {
|
|
6
|
+
constructor(x, y, color, options = {}) {
|
|
7
|
+
super(x, y, color, { filled: true, ...options });
|
|
8
|
+
this.type = "circle";
|
|
9
|
+
}
|
|
10
|
+
draw = (ctx, config, offset) => {
|
|
11
|
+
const { gradRatio, nbrShades, totalWidth, totalHeight, center, width } = config;
|
|
12
|
+
for (let i = 0; i < nbrShades; i++) {
|
|
13
|
+
this.setColors(ctx, gradRatio, i);
|
|
14
|
+
ctx.beginPath();
|
|
15
|
+
ctx.arc(center.x +
|
|
16
|
+
(this.position.x - totalWidth / 2 + width / 2) +
|
|
17
|
+
offset.x * (1 - (gradRatio * i) / 100), center.y +
|
|
18
|
+
(this.position.y - totalHeight / 2 + width / 2) +
|
|
19
|
+
offset.y * (1 - (gradRatio * i) / 100), width / 2, 0, 2 * Math.PI);
|
|
20
|
+
this.drawPath(ctx);
|
|
21
|
+
ctx.closePath();
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=CircleShape.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CircleShape.js","sourceRoot":"","sources":["../../../src/classes/shapes/CircleShape.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C;;GAEG;AACH,MAAM,OAAO,WAAY,SAAQ,SAAS;IACxC,YACE,CAAS,EACT,CAAS,EACT,KAAkB,EAClB,UAAyB,EAAE;QAE3B,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;QACjD,IAAI,CAAC,IAAI,GAAG,QAAQ,CAAC;IACvB,CAAC;IAED,IAAI,GAAG,CACL,GAA6B,EAC7B,MAAoB,EACpB,MAAc,EACd,EAAE;QACF,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,EAAE,KAAK,EAAE,GACpE,MAAM,CAAC;QAET,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,EAAE,CAAC,EAAE,EAAE,CAAC;YACnC,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC;YAElC,GAAG,CAAC,SAAS,EAAE,CAAC;YAChB,GAAG,CAAC,GAAG,CACL,MAAM,CAAC,CAAC;gBACN,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,GAAG,UAAU,GAAG,CAAC,GAAG,KAAK,GAAG,CAAC,CAAC;gBAC9C,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,SAAS,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,EACxC,MAAM,CAAC,CAAC;gBACN,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,GAAG,WAAW,GAAG,CAAC,GAAG,KAAK,GAAG,CAAC,CAAC;gBAC/C,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,SAAS,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,EACxC,KAAK,GAAG,CAAC,EACT,CAAC,EACD,CAAC,GAAG,IAAI,CAAC,EAAE,CACZ,CAAC;YAEF,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;YACnB,GAAG,CAAC,SAAS,EAAE,CAAC;QAClB,CAAC;IACH,CAAC,CAAC;CACH"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { TShadeColor, TShadeConfig, TShapeOptions } from "../../types/index.js";
|
|
2
|
+
import { TPoint } from "../../types/TPoints.js";
|
|
3
|
+
import { ShadeItem } from "./BaseShape.js";
|
|
4
|
+
/**
|
|
5
|
+
* Image shape that displays images (SVG, PNG, JPG, etc.)
|
|
6
|
+
* More flexible than the original LogoShape - accepts image URLs or HTMLImageElement
|
|
7
|
+
*/
|
|
8
|
+
export declare class ImageShape extends ShadeItem {
|
|
9
|
+
image?: HTMLImageElement;
|
|
10
|
+
imageUrl?: string;
|
|
11
|
+
hasImageLoaded: boolean;
|
|
12
|
+
hexColor: string;
|
|
13
|
+
constructor(x: number, y: number, color: TShadeColor, options?: TShapeOptions & {
|
|
14
|
+
imageSource?: string | HTMLImageElement | HTMLElement;
|
|
15
|
+
});
|
|
16
|
+
private loadImage;
|
|
17
|
+
private loadFromUrl;
|
|
18
|
+
private loadFromSVGElement;
|
|
19
|
+
setColors: (ctx: CanvasRenderingContext2D, gradRatio: number, i: number) => void;
|
|
20
|
+
draw: (ctx: CanvasRenderingContext2D, config: TShadeConfig, offset: TPoint) => void;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=ImageShape.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ImageShape.d.ts","sourceRoot":"","sources":["../../../src/classes/shapes/ImageShape.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAChF,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAEhD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C;;;GAGG;AACH,qBAAa,UAAW,SAAQ,SAAS;IACvC,KAAK,CAAC,EAAE,gBAAgB,CAAC;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,OAAO,CAAS;IAChC,QAAQ,EAAE,MAAM,CAAC;gBAGf,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,KAAK,EAAE,WAAW,EAClB,OAAO,GAAE,aAAa,GAAG;QACvB,WAAW,CAAC,EAAE,MAAM,GAAG,gBAAgB,GAAG,WAAW,CAAC;KAClD;IASR,OAAO,CAAC,SAAS;IA+BjB,OAAO,CAAC,WAAW;IAanB,OAAO,CAAC,kBAAkB;IAkB1B,SAAS,GAAI,KAAK,wBAAwB,EAAE,WAAW,MAAM,EAAE,GAAG,MAAM,UAItE;IAEF,IAAI,GACF,KAAK,wBAAwB,EAC7B,QAAQ,YAAY,EACpB,QAAQ,MAAM,UAiCd;CACH"}
|