q5 4.8.0 → 4.8.2
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/deno.json +1 -1
- package/package.json +1 -1
- package/q5.d.ts +4 -0
- package/q5.js +34 -10
package/deno.json
CHANGED
package/package.json
CHANGED
package/q5.d.ts
CHANGED
|
@@ -4586,6 +4586,10 @@ declare global {
|
|
|
4586
4586
|
interface Image {
|
|
4587
4587
|
width: number;
|
|
4588
4588
|
height: number;
|
|
4589
|
+
defaultWidth: number;
|
|
4590
|
+
defaultHeight: number;
|
|
4591
|
+
mirrorX: boolean;
|
|
4592
|
+
mirrorY: boolean;
|
|
4589
4593
|
copy(): Q5.Image;
|
|
4590
4594
|
get(x: number, y: number, w?: number, h?: number): Q5.Image | number[];
|
|
4591
4595
|
set(x: number, y: number, val: any): void;
|
package/q5.js
CHANGED
|
@@ -1551,14 +1551,15 @@ Q5.renderers.c2d.image = ($, q) => {
|
|
|
1551
1551
|
drawable = img._tintImg.canvas;
|
|
1552
1552
|
}
|
|
1553
1553
|
|
|
1554
|
-
|
|
1554
|
+
let mirrored = img.mirrorX || img.mirrorY;
|
|
1555
|
+
if (mirrored) {
|
|
1555
1556
|
$.ctx.save();
|
|
1556
1557
|
$.ctx.translate(dx + dw, 0);
|
|
1557
|
-
$.ctx.scale(-1, 1);
|
|
1558
|
+
$.ctx.scale(img.mirrorX ? -1 : 1, img.mirrorY ? -1 : 1);
|
|
1558
1559
|
dx = 0;
|
|
1559
1560
|
}
|
|
1560
1561
|
$.ctx.drawImage(drawable, sx * pd, sy * pd, sw, sh, dx, dy, dw, dh);
|
|
1561
|
-
if (
|
|
1562
|
+
if (mirrored) $.ctx.restore();
|
|
1562
1563
|
};
|
|
1563
1564
|
|
|
1564
1565
|
$.filter = (type, value) => {
|
|
@@ -1800,6 +1801,8 @@ Q5.Image = class {
|
|
|
1800
1801
|
let scale = $._pixelDensity * $._defaultImageScale;
|
|
1801
1802
|
$.defaultWidth = w * scale;
|
|
1802
1803
|
$.defaultHeight = h * scale;
|
|
1804
|
+
$.mirrorX = false;
|
|
1805
|
+
$.mirrorY = false;
|
|
1803
1806
|
delete $.createCanvas;
|
|
1804
1807
|
$._loop = false;
|
|
1805
1808
|
|
|
@@ -3387,7 +3390,7 @@ Q5.modules.dom = ($, q) => {
|
|
|
3387
3390
|
function extendVideo(vid) {
|
|
3388
3391
|
vid.playsinline = vid.autoplay = true;
|
|
3389
3392
|
if (flipped) {
|
|
3390
|
-
vid.
|
|
3393
|
+
vid.mirrorX = true;
|
|
3391
3394
|
vid.style.transform = 'scale(-1, 1)';
|
|
3392
3395
|
}
|
|
3393
3396
|
vid.loadPixels = () => {
|
|
@@ -3658,9 +3661,20 @@ Q5.modules.input = ($, q) => {
|
|
|
3658
3661
|
$._updateMouse(e);
|
|
3659
3662
|
$.mouseReleased(e);
|
|
3660
3663
|
}
|
|
3661
|
-
if
|
|
3662
|
-
|
|
3663
|
-
|
|
3664
|
+
// if pointer is a touch or the event type is pointercancel or mousecancel
|
|
3665
|
+
if (e.pointerType == 'touch' || e.type.at(-1) == 'l') {
|
|
3666
|
+
removePointer(e);
|
|
3667
|
+
}
|
|
3668
|
+
};
|
|
3669
|
+
|
|
3670
|
+
function removePointer(e) {
|
|
3671
|
+
let p = $.pointers.find((p) => p.id === e.pointerId);
|
|
3672
|
+
if (p) p._ended = true;
|
|
3673
|
+
}
|
|
3674
|
+
|
|
3675
|
+
$._onpointerleave = (e) => {
|
|
3676
|
+
if (e.pointerType == 'pen') {
|
|
3677
|
+
removePointer(e);
|
|
3664
3678
|
}
|
|
3665
3679
|
};
|
|
3666
3680
|
|
|
@@ -3800,6 +3814,7 @@ Q5.modules.input = ($, q) => {
|
|
|
3800
3814
|
l(pointer + 'move', (e) => $._onpointermove(e), false);
|
|
3801
3815
|
l(pointer + 'up', (e) => $._onpointerup(e));
|
|
3802
3816
|
l(pointer + 'cancel', (e) => $._onpointerup(e));
|
|
3817
|
+
l(pointer + 'leave', (e) => $._onpointerleave(e));
|
|
3803
3818
|
l('touchstart', (e) => $._updateTouches(e));
|
|
3804
3819
|
l('touchmove', (e) => $._updateTouches(e));
|
|
3805
3820
|
l('touchend', (e) => $._updateTouches(e));
|
|
@@ -8035,7 +8050,6 @@ fn fragMain(f: FragParams) -> @location(0) vec4f {
|
|
|
8035
8050
|
if (img._texture == undefined) {
|
|
8036
8051
|
isVideo = img.tagName == 'VIDEO';
|
|
8037
8052
|
if (!isVideo || !img.currentTime) return;
|
|
8038
|
-
if (img.flipped) $.scale(-1, 1);
|
|
8039
8053
|
}
|
|
8040
8054
|
|
|
8041
8055
|
if (matrixDirty) saveMatrix();
|
|
@@ -8075,6 +8089,18 @@ fn fragMain(f: FragParams) -> @location(0) vec4f {
|
|
|
8075
8089
|
u1 = (sx + sw) / w,
|
|
8076
8090
|
v1 = (sy + sh) / h;
|
|
8077
8091
|
|
|
8092
|
+
if (img.mirrorX) {
|
|
8093
|
+
let temp = u0;
|
|
8094
|
+
u0 = u1;
|
|
8095
|
+
u1 = temp;
|
|
8096
|
+
}
|
|
8097
|
+
|
|
8098
|
+
if (img.mirrorY) {
|
|
8099
|
+
let temp = v0;
|
|
8100
|
+
v0 = v1;
|
|
8101
|
+
v1 = temp;
|
|
8102
|
+
}
|
|
8103
|
+
|
|
8078
8104
|
let ti = matrixIdx,
|
|
8079
8105
|
ci = tintIdx,
|
|
8080
8106
|
ia = globalAlpha;
|
|
@@ -8109,8 +8135,6 @@ fn fragMain(f: FragParams) -> @location(0) vec4f {
|
|
|
8109
8135
|
);
|
|
8110
8136
|
|
|
8111
8137
|
drawStack.push(videoPL, $._textureBindGroups.length - 1);
|
|
8112
|
-
|
|
8113
|
-
if (img.flipped) $.scale(-1, 1);
|
|
8114
8138
|
}
|
|
8115
8139
|
};
|
|
8116
8140
|
|