q5 3.7.6 → 3.8.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/defs/q5-c2d-es.d.ts +926 -174
- package/defs/q5-c2d.d.ts +9 -9
- package/defs/q5-es.d.ts +963 -207
- package/deno.json +1 -1
- package/package.json +1 -1
- package/q5.d.ts +9 -9
- package/q5.js +130 -26
- package/q5.min.js +2 -2
package/deno.json
CHANGED
package/package.json
CHANGED
package/q5.d.ts
CHANGED
|
@@ -545,7 +545,7 @@ declare global {
|
|
|
545
545
|
/** 🌆
|
|
546
546
|
* Array of pixel color data from a canvas or image.
|
|
547
547
|
*
|
|
548
|
-
* Empty by default,
|
|
548
|
+
* Empty by default, get the data by running `loadPixels`.
|
|
549
549
|
*
|
|
550
550
|
* Each pixel is represented by four consecutive values in the array,
|
|
551
551
|
* corresponding to its red, green, blue, and alpha channels.
|
|
@@ -677,13 +677,6 @@ declare global {
|
|
|
677
677
|
*/
|
|
678
678
|
function createGraphics(w: number, h: number, opt?: any): Q5;
|
|
679
679
|
|
|
680
|
-
namespace Q5 {
|
|
681
|
-
interface Image {
|
|
682
|
-
width: number;
|
|
683
|
-
height: number;
|
|
684
|
-
}
|
|
685
|
-
}
|
|
686
|
-
|
|
687
680
|
// 📘 text
|
|
688
681
|
|
|
689
682
|
/** 📘
|
|
@@ -3168,7 +3161,7 @@ declare global {
|
|
|
3168
3161
|
* @example
|
|
3169
3162
|
* createCanvas(200, 100);
|
|
3170
3163
|
*
|
|
3171
|
-
* let sel = createSelect('Select
|
|
3164
|
+
* let sel = createSelect('Select an option');
|
|
3172
3165
|
* sel.option('Red', '#f55').option('Green', '#5f5');
|
|
3173
3166
|
*
|
|
3174
3167
|
* sel.addEventListener('change', () => {
|
|
@@ -3954,6 +3947,13 @@ declare global {
|
|
|
3954
3947
|
|
|
3955
3948
|
}
|
|
3956
3949
|
|
|
3950
|
+
namespace Q5 {
|
|
3951
|
+
interface Image {
|
|
3952
|
+
width: number;
|
|
3953
|
+
height: number;
|
|
3954
|
+
}
|
|
3955
|
+
}
|
|
3956
|
+
|
|
3957
3957
|
}
|
|
3958
3958
|
|
|
3959
3959
|
export {};
|
package/q5.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* q5.js
|
|
3
|
-
* @version 3.
|
|
3
|
+
* @version 3.8
|
|
4
4
|
* @author quinton-ashley
|
|
5
5
|
* @contributors evanalulu, Tezumie, ormaq, Dukemz, LingDong-
|
|
6
6
|
* @license LGPL-3.0
|
|
@@ -464,7 +464,7 @@ if (typeof window == 'object') {
|
|
|
464
464
|
window.WEBGPU = 'webgpu';
|
|
465
465
|
} else global.window = 0;
|
|
466
466
|
|
|
467
|
-
Q5.version = Q5.VERSION = '3.
|
|
467
|
+
Q5.version = Q5.VERSION = '3.8';
|
|
468
468
|
|
|
469
469
|
if (typeof document == 'object') {
|
|
470
470
|
document.addEventListener('DOMContentLoaded', () => {
|
|
@@ -619,8 +619,6 @@ Q5.modules.canvas = ($, q) => {
|
|
|
619
619
|
|
|
620
620
|
c.w = w = Math.ceil(w);
|
|
621
621
|
c.h = h = Math.ceil(h);
|
|
622
|
-
q.halfWidth = c.hw = w / 2;
|
|
623
|
-
q.halfHeight = c.hh = h / 2;
|
|
624
622
|
|
|
625
623
|
// changes the actual size of the canvas
|
|
626
624
|
c.width = Math.ceil(w * $._pixelDensity);
|
|
@@ -628,6 +626,17 @@ Q5.modules.canvas = ($, q) => {
|
|
|
628
626
|
|
|
629
627
|
q.width = w;
|
|
630
628
|
q.height = h;
|
|
629
|
+
q.halfWidth = c.hw = w / 2;
|
|
630
|
+
q.halfHeight = c.hh = h / 2;
|
|
631
|
+
|
|
632
|
+
let m = Q5._libMap;
|
|
633
|
+
|
|
634
|
+
if (m.width) {
|
|
635
|
+
q[m.width] = w;
|
|
636
|
+
q[m.height] = h;
|
|
637
|
+
q[m.halfWidth] = q.halfWidth;
|
|
638
|
+
q[m.halfHeight] = q.halfHeight;
|
|
639
|
+
}
|
|
631
640
|
|
|
632
641
|
if ($.displayMode && !c.displayMode) $.displayMode();
|
|
633
642
|
else $._adjustDisplay(true);
|
|
@@ -1583,7 +1592,13 @@ Q5.renderers.c2d.image = ($, q) => {
|
|
|
1583
1592
|
$.ctx.clearRect(0, 0, c.width, c.height);
|
|
1584
1593
|
$.ctx.drawImage(o, 0, 0, c.width, c.height);
|
|
1585
1594
|
|
|
1586
|
-
$.
|
|
1595
|
+
$._retint = true;
|
|
1596
|
+
|
|
1597
|
+
if ($._owner?._makeDrawable) {
|
|
1598
|
+
$._texture.destroy();
|
|
1599
|
+
delete $._texture;
|
|
1600
|
+
$._owner._makeDrawable($);
|
|
1601
|
+
}
|
|
1587
1602
|
};
|
|
1588
1603
|
}
|
|
1589
1604
|
|
|
@@ -1752,6 +1767,26 @@ Q5.Image = class {
|
|
|
1752
1767
|
$.defaultHeight = h * scale;
|
|
1753
1768
|
delete $.createCanvas;
|
|
1754
1769
|
$._loop = false;
|
|
1770
|
+
|
|
1771
|
+
let libMap = Q5._libMap;
|
|
1772
|
+
let imgFns = [
|
|
1773
|
+
'copy',
|
|
1774
|
+
'filter',
|
|
1775
|
+
'get',
|
|
1776
|
+
'set',
|
|
1777
|
+
'resize',
|
|
1778
|
+
'mask',
|
|
1779
|
+
'trim',
|
|
1780
|
+
'inset',
|
|
1781
|
+
'pixels',
|
|
1782
|
+
'loadPixels',
|
|
1783
|
+
'updatePixels',
|
|
1784
|
+
'smooth',
|
|
1785
|
+
'noSmooth'
|
|
1786
|
+
];
|
|
1787
|
+
for (let name of imgFns) {
|
|
1788
|
+
if (libMap[name]) $[libMap[name]] = $[name];
|
|
1789
|
+
}
|
|
1755
1790
|
}
|
|
1756
1791
|
get w() {
|
|
1757
1792
|
return this.width;
|
|
@@ -8608,8 +8643,8 @@ shearX -> es:cizallarX
|
|
|
8608
8643
|
shearY -> es:cizallarY
|
|
8609
8644
|
applyMatrix -> es:aplicarMatriz
|
|
8610
8645
|
resetMatrix -> es:reiniciarMatriz
|
|
8611
|
-
push -> es:
|
|
8612
|
-
pop -> es:
|
|
8646
|
+
push -> es:apilar
|
|
8647
|
+
pop -> es:desapilar
|
|
8613
8648
|
pushMatrix -> es:guardarMatriz
|
|
8614
8649
|
popMatrix -> es:recuperarMatriz
|
|
8615
8650
|
|
|
@@ -8731,6 +8766,7 @@ RIGHT -> es:DERECHA
|
|
|
8731
8766
|
TOP -> es:ARRIBA
|
|
8732
8767
|
BOTTOM -> es:ABAJO
|
|
8733
8768
|
BASELINE -> es:LINEA_BASE
|
|
8769
|
+
MIDDLE -> es:MEDIO
|
|
8734
8770
|
RGB -> es:RGB
|
|
8735
8771
|
OKLCH -> es:OKLCH
|
|
8736
8772
|
HSL -> es:HSL
|
|
@@ -8743,6 +8779,9 @@ PIXELATED -> es:PIXELADO
|
|
|
8743
8779
|
TWO_PI -> es:DOS_PI
|
|
8744
8780
|
HALF_PI -> es:MEDIO_PI
|
|
8745
8781
|
QUARTER_PI -> es:CUARTO_PI
|
|
8782
|
+
|
|
8783
|
+
# vector
|
|
8784
|
+
createVector -> es:crearVector
|
|
8746
8785
|
`;
|
|
8747
8786
|
|
|
8748
8787
|
const userLangs = `
|
|
@@ -8762,6 +8801,45 @@ touchMoved -> es:alMoverToque
|
|
|
8762
8801
|
mouseWheel -> es:ruedaRatón
|
|
8763
8802
|
`;
|
|
8764
8803
|
|
|
8804
|
+
const classLangs = {
|
|
8805
|
+
Vector: `
|
|
8806
|
+
add -> es:sumar
|
|
8807
|
+
sub -> es:restar
|
|
8808
|
+
mult -> es:multiplicar
|
|
8809
|
+
div -> es:dividir
|
|
8810
|
+
mag -> es:magnitud
|
|
8811
|
+
magSq -> es:magnitudCuad
|
|
8812
|
+
dist -> es:distancia
|
|
8813
|
+
normalize -> es:normalizar
|
|
8814
|
+
limit -> es:limitar
|
|
8815
|
+
setMag -> es:establecerMagnitud
|
|
8816
|
+
heading -> es:rumbo
|
|
8817
|
+
rotate -> es:rotar
|
|
8818
|
+
lerp -> es:interpolar
|
|
8819
|
+
array -> es:arreglo
|
|
8820
|
+
copy -> es:copiar
|
|
8821
|
+
dot -> es:punto
|
|
8822
|
+
cross -> es:cruz
|
|
8823
|
+
angleBetween -> es:anguloEntre
|
|
8824
|
+
reflect -> es:reflejar
|
|
8825
|
+
`,
|
|
8826
|
+
Sound: `
|
|
8827
|
+
load -> es:cargar
|
|
8828
|
+
play -> es:reproducir
|
|
8829
|
+
stop -> es:parar
|
|
8830
|
+
pause -> es:pausar
|
|
8831
|
+
loop -> es:bucle
|
|
8832
|
+
setVolume -> es:establecerVolumen
|
|
8833
|
+
setPan -> es:establecerPan
|
|
8834
|
+
setLoop -> es:establecerBucle
|
|
8835
|
+
isLoaded -> es:estaCargado
|
|
8836
|
+
isPlaying -> es:estaReproduciendo
|
|
8837
|
+
isPaused -> es:estaPausado
|
|
8838
|
+
isLooping -> es:estaEnBucle
|
|
8839
|
+
onended -> es:alTerminar
|
|
8840
|
+
`
|
|
8841
|
+
};
|
|
8842
|
+
|
|
8765
8843
|
const parseLangs = function (data, lang) {
|
|
8766
8844
|
let map = {};
|
|
8767
8845
|
for (let l of data.split('\n')) {
|
|
@@ -8773,8 +8851,6 @@ const parseLangs = function (data, lang) {
|
|
|
8773
8851
|
return map;
|
|
8774
8852
|
};
|
|
8775
8853
|
|
|
8776
|
-
Q5._lang = 'en';
|
|
8777
|
-
|
|
8778
8854
|
Object.defineProperty(Q5, 'lang', {
|
|
8779
8855
|
get: () => Q5._lang,
|
|
8780
8856
|
set: (val) => {
|
|
@@ -8784,15 +8860,15 @@ Object.defineProperty(Q5, 'lang', {
|
|
|
8784
8860
|
|
|
8785
8861
|
if (val == 'en') {
|
|
8786
8862
|
// reset to English only user functions
|
|
8787
|
-
Q5._userFns = Q5._userFns.slice(0,
|
|
8863
|
+
Q5._userFns = Q5._userFns.slice(0, 19);
|
|
8788
8864
|
Q5._libMap = Q5._userFnsMap = {};
|
|
8789
8865
|
return;
|
|
8790
8866
|
}
|
|
8791
8867
|
|
|
8792
|
-
let
|
|
8868
|
+
let m = parseLangs(libLangs, val);
|
|
8793
8869
|
|
|
8794
8870
|
if (typeof window == 'object') {
|
|
8795
|
-
window[
|
|
8871
|
+
window[m.createCanvas] = createCanvas;
|
|
8796
8872
|
}
|
|
8797
8873
|
|
|
8798
8874
|
let userFnsMap = parseLangs(userLangs, val);
|
|
@@ -8806,12 +8882,33 @@ Object.defineProperty(Q5, 'lang', {
|
|
|
8806
8882
|
});
|
|
8807
8883
|
}
|
|
8808
8884
|
|
|
8809
|
-
|
|
8885
|
+
for (let className in classLangs) {
|
|
8886
|
+
if (Q5[className]) {
|
|
8887
|
+
let map = parseLangs(classLangs[className], val);
|
|
8888
|
+
let proto = Q5[className].prototype;
|
|
8889
|
+
for (let name in map) {
|
|
8890
|
+
let translatedName = map[name];
|
|
8891
|
+
if (proto.hasOwnProperty(translatedName)) continue;
|
|
8892
|
+
Object.defineProperty(proto, translatedName, {
|
|
8893
|
+
get: function () {
|
|
8894
|
+
return this[name];
|
|
8895
|
+
},
|
|
8896
|
+
set: function (v) {
|
|
8897
|
+
this[name] = v;
|
|
8898
|
+
}
|
|
8899
|
+
});
|
|
8900
|
+
}
|
|
8901
|
+
}
|
|
8902
|
+
}
|
|
8903
|
+
|
|
8904
|
+
Q5._libMap = m;
|
|
8810
8905
|
Q5._userFnsMap = userFnsMap;
|
|
8811
8906
|
Q5._userFns.push(...Object.values(userFnsMap));
|
|
8812
8907
|
}
|
|
8813
8908
|
});
|
|
8814
8909
|
|
|
8910
|
+
Q5.lang = 'en';
|
|
8911
|
+
|
|
8815
8912
|
Q5.modules.lang = ($) => {
|
|
8816
8913
|
let userFnsMap = Q5._userFnsMap;
|
|
8817
8914
|
|
|
@@ -8823,29 +8920,36 @@ Q5.modules.lang = ($) => {
|
|
|
8823
8920
|
});
|
|
8824
8921
|
}
|
|
8825
8922
|
|
|
8826
|
-
let
|
|
8923
|
+
let m = Q5._libMap;
|
|
8827
8924
|
|
|
8828
|
-
if (
|
|
8829
|
-
$[
|
|
8925
|
+
if (m.createCanvas) {
|
|
8926
|
+
$[m.createCanvas] = $.createCanvas;
|
|
8830
8927
|
}
|
|
8831
8928
|
};
|
|
8832
8929
|
|
|
8833
8930
|
Q5.addHook('init', (q) => {
|
|
8834
|
-
let
|
|
8931
|
+
let m = Q5._libMap;
|
|
8835
8932
|
|
|
8836
|
-
for (let name in
|
|
8837
|
-
let translatedName =
|
|
8933
|
+
for (let name in m) {
|
|
8934
|
+
let translatedName = m[name];
|
|
8838
8935
|
q[translatedName] = q[name];
|
|
8839
8936
|
}
|
|
8840
8937
|
});
|
|
8841
8938
|
|
|
8842
8939
|
Q5.addHook('predraw', (q) => {
|
|
8843
|
-
let
|
|
8940
|
+
let m = Q5._libMap;
|
|
8844
8941
|
|
|
8845
|
-
|
|
8846
|
-
|
|
8847
|
-
|
|
8848
|
-
|
|
8849
|
-
|
|
8850
|
-
|
|
8942
|
+
if (!m.mouseX) return;
|
|
8943
|
+
|
|
8944
|
+
q[m.frameCount] = q.frameCount;
|
|
8945
|
+
|
|
8946
|
+
// update user input
|
|
8947
|
+
q[m.mouseX] = q.mouseX;
|
|
8948
|
+
q[m.mouseY] = q.mouseY;
|
|
8949
|
+
q[m.mouseIsPressed] = q.mouseIsPressed;
|
|
8950
|
+
q[m.mouseButton] = q.mouseButton;
|
|
8951
|
+
q[m.key] = q.key;
|
|
8952
|
+
q[m.keyIsPressed] = q.keyIsPressed;
|
|
8953
|
+
q[m.touches] = q.touches;
|
|
8954
|
+
q[m.pointers] = q.pointers;
|
|
8851
8955
|
});
|