q5 3.8.0 → 3.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/q5.js CHANGED
@@ -912,6 +912,7 @@ Q5.renderers.c2d.canvas = ($, q) => {
912
912
 
913
913
  $.strokeWeight = (n) => {
914
914
  if (!n) $._doStroke = false;
915
+ else $._doStroke = true;
915
916
  $.ctx.lineWidth = $._strokeWeight = n || 0.0001;
916
917
  };
917
918
 
@@ -5575,10 +5576,10 @@ fn fragMain(f: FragParams ) -> @location(0) vec4f {
5575
5576
 
5576
5577
  $.strokeWeight = (v) => {
5577
5578
  if (v === undefined) return sw;
5578
- if (!v) {
5579
- doStroke = false;
5580
- return;
5581
- }
5579
+
5580
+ if (!v) return (doStroke = false);
5581
+ else doStroke = true;
5582
+
5582
5583
  v = Math.abs(v);
5583
5584
  sw = v;
5584
5585
  hsw = v / 2;
@@ -8502,9 +8503,11 @@ Q5.WebGPU = async function (scope, parent) {
8502
8503
  await q.ready;
8503
8504
  return q;
8504
8505
  };
8506
+ const supportedLangs = ['es'];
8507
+
8505
8508
  const libLangs = `
8506
8509
  # core
8507
- createCanvas -> es:crearLienzo ja:キャンバスを作成する
8510
+ createCanvas -> es:crearLienzo
8508
8511
  log -> es:log
8509
8512
 
8510
8513
  # color
@@ -8802,6 +8805,18 @@ mouseWheel -> es:ruedaRatón
8802
8805
  `;
8803
8806
 
8804
8807
  const classLangs = {
8808
+ Q5: `
8809
+ Image -> es:Imagen
8810
+ version -> es:versión
8811
+ disableFriendlyErrors -> es:deshabilitarErroresAmigables
8812
+ errorTolerant -> es:toleranteErrores
8813
+ supportsHDR -> es:soportaHDR
8814
+ canvasOptions -> es:opcionesLienzo
8815
+ MAX_ELLIPSES -> es:MAX_ELIPSES
8816
+ MAX_TRANSFORMS -> es:MAX_TRANSFORMACIONES
8817
+ MAX_CHARS -> es:MAX_CARACTERES
8818
+ MAX_TEXTS -> es:MAX_TEXTOS
8819
+ `,
8805
8820
  Vector: `
8806
8821
  add -> es:sumar
8807
8822
  sub -> es:restar
@@ -8865,31 +8880,14 @@ Object.defineProperty(Q5, 'lang', {
8865
8880
  return;
8866
8881
  }
8867
8882
 
8868
- let m = parseLangs(libLangs, val);
8869
-
8870
- if (typeof window == 'object') {
8871
- window[m.createCanvas] = createCanvas;
8872
- }
8873
-
8874
- let userFnsMap = parseLangs(userLangs, val);
8875
-
8876
- for (let name in userFnsMap) {
8877
- let translatedName = userFnsMap[name];
8878
- if (Q5.hasOwnProperty(translatedName)) continue;
8879
- Object.defineProperty(Q5, translatedName, {
8880
- get: () => Q5[name],
8881
- set: (fn) => (Q5[name] = fn)
8882
- });
8883
- }
8884
-
8885
8883
  for (let className in classLangs) {
8886
- if (Q5[className]) {
8884
+ let target = className == 'Q5' ? Q5 : Q5[className] ? Q5[className].prototype : null;
8885
+ if (target) {
8887
8886
  let map = parseLangs(classLangs[className], val);
8888
- let proto = Q5[className].prototype;
8889
8887
  for (let name in map) {
8890
8888
  let translatedName = map[name];
8891
- if (proto.hasOwnProperty(translatedName)) continue;
8892
- Object.defineProperty(proto, translatedName, {
8889
+ if (target.hasOwnProperty(translatedName)) continue;
8890
+ Object.defineProperty(target, translatedName, {
8893
8891
  get: function () {
8894
8892
  return this[name];
8895
8893
  },
@@ -8901,14 +8899,38 @@ Object.defineProperty(Q5, 'lang', {
8901
8899
  }
8902
8900
  }
8903
8901
 
8904
- Q5._libMap = m;
8905
- Q5._userFnsMap = userFnsMap;
8906
- Q5._userFns.push(...Object.values(userFnsMap));
8902
+ Q5._libMap = parseLangs(libLangs, val);
8903
+ Q5._userFnsMap = parseLangs(userLangs, val);
8904
+ Q5._userFns.push(...Object.values(Q5._userFnsMap));
8907
8905
  }
8908
8906
  });
8909
8907
 
8910
8908
  Q5.lang = 'en';
8911
8909
 
8910
+ for (let l of supportedLangs) {
8911
+ if (typeof window == 'object') {
8912
+ let m = parseLangs(libLangs.slice(0, libLangs.indexOf('\n', 8)), l);
8913
+ window[m.createCanvas] = function () {
8914
+ Q5.lang = l;
8915
+ return createCanvas(...arguments);
8916
+ };
8917
+ }
8918
+
8919
+ let userFnsMap = parseLangs(userLangs, l);
8920
+
8921
+ for (let name in userFnsMap) {
8922
+ let translatedName = userFnsMap[name];
8923
+ if (Q5.hasOwnProperty(translatedName)) continue;
8924
+ Object.defineProperty(Q5, translatedName, {
8925
+ get: () => Q5[name],
8926
+ set: (fn) => {
8927
+ Q5.lang = l;
8928
+ Q5[name] = fn;
8929
+ }
8930
+ });
8931
+ }
8932
+ }
8933
+
8912
8934
  Q5.modules.lang = ($) => {
8913
8935
  let userFnsMap = Q5._userFnsMap;
8914
8936
 
@@ -8941,15 +8963,18 @@ Q5.addHook('predraw', (q) => {
8941
8963
 
8942
8964
  if (!m.mouseX) return;
8943
8965
 
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;
8966
+ let props = [
8967
+ 'frameCount',
8968
+ 'mouseX',
8969
+ 'mouseY',
8970
+ 'mouseIsPressed',
8971
+ 'mouseButton',
8972
+ 'key',
8973
+ 'keyIsPressed',
8974
+ 'touches',
8975
+ 'pointers'
8976
+ ];
8977
+
8978
+ // sync properties
8979
+ for (let p of props) q[m[p]] = q[p];
8955
8980
  });