q5 4.6.0 → 4.6.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@q5/q5",
3
- "version": "4.6.0",
3
+ "version": "4.6.1",
4
4
  "license": "LGPL-3.0-only",
5
5
  "description": "Beginner friendly graphics powered by WebGPU, optimized for interactive art!",
6
6
  "author": "quinton-ashley",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "q5",
3
- "version": "4.6.0",
3
+ "version": "4.6.2",
4
4
  "description": "Beginner friendly graphics powered by WebGPU, optimized for interactive art!",
5
5
  "author": "quinton-ashley",
6
6
  "license": "LGPL-3.0-only",
package/q5.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * q5.js
3
- * @version 4.5
3
+ * @version 4.6
4
4
  * @author quinton-ashley
5
5
  * @contributors evanalulu, Tezumie, keturn, ormaq, bertubi, RedWilly, Dukemz, LingDong-
6
6
  * @license LGPL-3.0
@@ -496,7 +496,7 @@ if (typeof window == 'object') {
496
496
  window.addEventListener('pagehide', cleanup);
497
497
  } else global.window = 0;
498
498
 
499
- Q5.version = Q5.VERSION = '4.5';
499
+ Q5.version = Q5.VERSION = '4.6';
500
500
 
501
501
  if (typeof document == 'object') {
502
502
  document.addEventListener('DOMContentLoaded', () => {
@@ -6309,13 +6309,6 @@ fn fragMain(f: FragParams ) -> @location(0) vec4f {
6309
6309
  }
6310
6310
 
6311
6311
  Q5.device.queue.writeBuffer(imgVertBuff, 0, imgVertStack.subarray(0, imgVertIdx));
6312
-
6313
- $._pass.setVertexBuffer(1, imgVertBuff);
6314
-
6315
- if (vidFrames) {
6316
- $._pass.setPipeline($._pipelines[3]); // video pipeline
6317
- $._pass.setVertexBuffer(1, imgVertBuff);
6318
- }
6319
6312
  }
6320
6313
 
6321
6314
  // prepare to render text
@@ -6415,6 +6408,12 @@ fn fragMain(f: FragParams ) -> @location(0) vec4f {
6415
6408
  curPipelineIndex = drawStack[i];
6416
6409
  pass.setPipeline($._pipelines[curPipelineIndex]);
6417
6410
 
6411
+ if (curPipelineIndex == 2 || curPipelineIndex == 3 || curPipelineIndex >= 2000) {
6412
+ pass.setVertexBuffer(0, imgVertBuff);
6413
+ } else if (curPipelineIndex == 1 || (curPipelineIndex >= 1000 && curPipelineIndex < 2000)) {
6414
+ pass.setVertexBuffer(0, shapesVertBuff);
6415
+ }
6416
+
6418
6417
  if (curPipelineIndex == 5) {
6419
6418
  pass.setIndexBuffer(rectIndexBuffer, 'uint16');
6420
6419
  pass.setBindGroup(1, rectBindGroup);
@@ -7790,7 +7789,7 @@ fn fragMain(f: FragParams) -> @location(0) vec4f {
7790
7789
  vertex: {
7791
7790
  module: imageShader,
7792
7791
  entryPoint: 'vertexMain',
7793
- buffers: [{ arrayStride: 0, attributes: [] }, imgVertBuffLayout]
7792
+ buffers: [imgVertBuffLayout]
7794
7793
  },
7795
7794
  fragment: {
7796
7795
  module: imageShader,
@@ -7809,7 +7808,7 @@ fn fragMain(f: FragParams) -> @location(0) vec4f {
7809
7808
  vertex: {
7810
7809
  module: videoShader,
7811
7810
  entryPoint: 'vertexMain',
7812
- buffers: [{ arrayStride: 0, attributes: [] }, imgVertBuffLayout]
7811
+ buffers: [imgVertBuffLayout]
7813
7812
  },
7814
7813
  fragment: {
7815
7814
  module: videoShader,
@@ -9437,6 +9436,10 @@ const parseLangs = function (data, lang) {
9437
9436
  return map;
9438
9437
  };
9439
9438
 
9439
+ const unaccent = function (s) {
9440
+ return s.normalize('NFD').replace(/[\u0300-\u036f]/g, '');
9441
+ };
9442
+
9440
9443
  Object.defineProperty(Q5, 'lang', {
9441
9444
  get: () => Q5._lang,
9442
9445
  set: (val) => {
@@ -9502,6 +9505,40 @@ for (let l of supportedLangs) {
9502
9505
  }
9503
9506
  }
9504
9507
 
9508
+ Q5.applyLang = function (q, libs, classes) {
9509
+ let val = Q5._lang;
9510
+ if (val == 'en') return;
9511
+
9512
+ let map = parseLangs(libs, val);
9513
+ for (let name in map) {
9514
+ let translatedName = map[name];
9515
+ q[translatedName] = q[name];
9516
+ if (val == 'es') {
9517
+ let unaccentedName = unaccent(translatedName);
9518
+ if (unaccentedName != translatedName) q[unaccentedName] = q[name];
9519
+ }
9520
+ }
9521
+
9522
+ if (!classes) return;
9523
+
9524
+ for (let className in classes) {
9525
+ let target = q[className].prototype;
9526
+ let map = parseLangs(classes[className], val);
9527
+ for (let name in map) {
9528
+ let translatedName = map[name];
9529
+ if (target.hasOwnProperty(translatedName)) continue;
9530
+ Object.defineProperty(target, translatedName, {
9531
+ get: function () {
9532
+ return this[name];
9533
+ },
9534
+ set: function (v) {
9535
+ this[name] = v;
9536
+ }
9537
+ });
9538
+ }
9539
+ }
9540
+ };
9541
+
9505
9542
  Q5.modules.lang = ($) => {
9506
9543
  let userFnsMap = Q5._userFnsMap;
9507
9544
 
@@ -9526,7 +9563,7 @@ Q5.addHook('init', (q) => {
9526
9563
  q[translatedName] = q[name];
9527
9564
 
9528
9565
  if (Q5._lang == 'es') {
9529
- let unaccentedName = translatedName.normalize('NFD').replace(/[\u0300-\u036f]/g, '');
9566
+ let unaccentedName = unaccent(translatedName);
9530
9567
  if (unaccentedName != translatedName) {
9531
9568
  q[unaccentedName] = q[name];
9532
9569
  }
@@ -9560,7 +9597,7 @@ Q5.addHook('predraw', (q) => {
9560
9597
  if (!m[p]) continue;
9561
9598
  q[m[p]] = q[p];
9562
9599
  if (Q5._lang == 'es') {
9563
- let unaccentedName = m[p].normalize('NFD').replace(/[\u0300-\u036f]/g, '');
9600
+ let unaccentedName = unaccent(m[p]);
9564
9601
  if (unaccentedName != m[p]) {
9565
9602
  q[unaccentedName] = q[p];
9566
9603
  }