canvasframework 0.4.9 → 0.4.10
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/core/CanvasFramework.js +36 -8
- package/core/WebGLCanvasAdapter.js +1351 -1334
- package/package.json +1 -1
package/core/CanvasFramework.js
CHANGED
|
@@ -213,7 +213,7 @@ class CanvasFramework {
|
|
|
213
213
|
// NOUVELLE OPTION: choisir entre Canvas 2D et WebGL
|
|
214
214
|
this.useWebGL = options.useWebGL !== false; // true par défaut
|
|
215
215
|
// Initialiser le contexte approprié
|
|
216
|
-
if (this.useWebGL) {
|
|
216
|
+
/*if (this.useWebGL) {
|
|
217
217
|
try {
|
|
218
218
|
this.ctx = new WebGLCanvasAdapter(this.canvas);
|
|
219
219
|
} catch (e) {
|
|
@@ -222,7 +222,7 @@ class CanvasFramework {
|
|
|
222
222
|
}
|
|
223
223
|
} else {
|
|
224
224
|
this.ctx = this.canvas.getContext('2d');
|
|
225
|
-
}
|
|
225
|
+
}*/
|
|
226
226
|
// Calcule FPS
|
|
227
227
|
this.fps = 0;
|
|
228
228
|
this._frames = 0;
|
|
@@ -478,7 +478,17 @@ class CanvasFramework {
|
|
|
478
478
|
requestAnimationFrame(fade);
|
|
479
479
|
} else {
|
|
480
480
|
this._splashFinished = true;
|
|
481
|
-
|
|
481
|
+
// ✅ AJOUTER : Réinitialiser complètement le contexte
|
|
482
|
+
this.ctx.clearRect(0, 0, this.width, this.height);
|
|
483
|
+
this.ctx.globalAlpha = 1;
|
|
484
|
+
this.ctx.textAlign = 'start'; // ← IMPORTANT
|
|
485
|
+
this.ctx.textBaseline = 'alphabetic'; // ← IMPORTANT
|
|
486
|
+
this.ctx.font = '10px sans-serif'; // Valeur par défaut
|
|
487
|
+
this.ctx.fillStyle = '#000000';
|
|
488
|
+
this.ctx.strokeStyle = '#000000';
|
|
489
|
+
this.ctx.lineWidth = 1;
|
|
490
|
+
this.ctx.lineCap = 'butt';
|
|
491
|
+
this.ctx.lineJoin = 'miter';
|
|
482
492
|
}
|
|
483
493
|
};
|
|
484
494
|
|
|
@@ -856,12 +866,13 @@ class CanvasFramework {
|
|
|
856
866
|
this.canvas.style.height = this.height + 'px';
|
|
857
867
|
|
|
858
868
|
// Échelle uniquement pour Canvas 2D
|
|
859
|
-
|
|
869
|
+
this.ctx.scale(this.dpr, this.dpr);
|
|
870
|
+
/*if (!this.useWebGL) {
|
|
860
871
|
this.ctx.scale(this.dpr, this.dpr);
|
|
861
872
|
} else {
|
|
862
873
|
// WebGL gère le DPR automatiquement via la matrice de projection
|
|
863
874
|
this.ctx.updateProjectionMatrix();
|
|
864
|
-
}
|
|
875
|
+
}*/
|
|
865
876
|
}
|
|
866
877
|
|
|
867
878
|
setupEventListeners() {
|
|
@@ -1573,8 +1584,25 @@ class CanvasFramework {
|
|
|
1573
1584
|
}
|
|
1574
1585
|
return Math.max(0, maxY - this.height + 50);
|
|
1575
1586
|
}*/
|
|
1576
|
-
|
|
1577
|
-
|
|
1587
|
+
|
|
1588
|
+
handleResize() {
|
|
1589
|
+
if (this.resizeTimeout) clearTimeout(this.resizeTimeout);
|
|
1590
|
+
|
|
1591
|
+
this.resizeTimeout = setTimeout(() => {
|
|
1592
|
+
this.width = window.innerWidth;
|
|
1593
|
+
this.height = window.innerHeight;
|
|
1594
|
+
this.setupCanvas(); // ← Fait déjà tout le boulot
|
|
1595
|
+
|
|
1596
|
+
for (const comp of this.components) {
|
|
1597
|
+
if (comp._resize) {
|
|
1598
|
+
comp._resize(this.width, this.height);
|
|
1599
|
+
}
|
|
1600
|
+
}
|
|
1601
|
+
this._maxScrollDirty = true;
|
|
1602
|
+
}, 150);
|
|
1603
|
+
}
|
|
1604
|
+
|
|
1605
|
+
/*handleResize() {
|
|
1578
1606
|
if (this.resizeTimeout) clearTimeout(this.resizeTimeout); // ✅ AJOUTER
|
|
1579
1607
|
|
|
1580
1608
|
this.resizeTimeout = setTimeout(() => { // ✅ AJOUTER
|
|
@@ -1591,7 +1619,7 @@ class CanvasFramework {
|
|
|
1591
1619
|
this._maxScrollDirty = true; // ✅ AJOUTER
|
|
1592
1620
|
}
|
|
1593
1621
|
}, 150); // ✅ AJOUTER (throttle 150ms)
|
|
1594
|
-
}
|
|
1622
|
+
}*/
|
|
1595
1623
|
|
|
1596
1624
|
add(component) {
|
|
1597
1625
|
this.components.push(component);
|