q5 3.4.0 → 3.5.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.
Files changed (5) hide show
  1. package/deno.json +1 -1
  2. package/package.json +3 -3
  3. package/q5.d.ts +434 -334
  4. package/q5.js +18 -7
  5. package/q5.min.js +2 -2
package/q5.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * q5.js
3
- * @version 3.4
3
+ * @version 3.5
4
4
  * @author quinton-ashley
5
5
  * @contributors evanalulu, Tezumie, ormaq, Dukemz, LingDong-
6
6
  * @license LGPL-3.0
@@ -426,12 +426,14 @@ Q5.prototype.registerPreloadMethod = (n, fn) => (Q5.preloadMethods[n] = fn[n]);
426
426
  function createCanvas(w, h, opt) {
427
427
  if (Q5._hasGlobal) return;
428
428
 
429
- if (w == 'webgpu' || h == 'webgpu' || opt == 'webgpu' || opt?.renderer == 'webgpu') {
430
- return Q5.WebGPU().then((q) => q.createCanvas(w, h, opt));
431
- } else {
429
+ let useC2D = w == 'c2d' || h == 'c2d' || opt == 'c2d' || opt?.renderer == 'c2d' || !Q5._esm;
430
+
431
+ if (useC2D) {
432
432
  let q = new Q5();
433
433
  let c = q.createCanvas(w, h, opt);
434
434
  return q.ready.then(() => c);
435
+ } else {
436
+ return Q5.WebGPU().then((q) => q.createCanvas(w, h, opt));
435
437
  }
436
438
  }
437
439
 
@@ -440,14 +442,21 @@ if (Q5._server) global.p5 ??= global.Q5 = Q5;
440
442
  if (typeof window == 'object') {
441
443
  window.p5 ??= window.Q5 = Q5;
442
444
  window.createCanvas = createCanvas;
443
- window.GPU = window.WEBGPU = 'webgpu';
445
+ window.C2D = 'c2d';
446
+ window.WEBGPU = 'webgpu';
444
447
  } else global.window = 0;
445
448
 
446
- Q5.version = Q5.VERSION = '3.4';
449
+ Q5.version = Q5.VERSION = '3.5';
447
450
 
448
451
  if (typeof document == 'object') {
449
452
  document.addEventListener('DOMContentLoaded', () => {
450
- if (!Q5._hasGlobal) new Q5('auto');
453
+ if (!Q5._hasGlobal) {
454
+ if (Q5.setup || Q5.update || Q5.draw) {
455
+ Q5.WebGPU();
456
+ } else {
457
+ new Q5('auto');
458
+ }
459
+ }
451
460
  });
452
461
  }
453
462
  Q5.modules.canvas = ($, q) => {
@@ -2286,6 +2295,7 @@ Q5.modules.color = ($, q) => {
2286
2295
  pink: [255, 192, 203],
2287
2296
  purple: [128, 0, 128],
2288
2297
  red: [255, 0, 0],
2298
+ silver: [192, 192, 192],
2289
2299
  skyblue: [135, 206, 235],
2290
2300
  tan: [210, 180, 140],
2291
2301
  turquoise: [64, 224, 208],
@@ -8128,6 +8138,7 @@ Q5.initWebGPU = async () => {
8128
8138
  return false;
8129
8139
  }
8130
8140
  if (!Q5.requestedGPU) {
8141
+ Q5.requestedGPU = true;
8131
8142
  let adapter = await navigator.gpu.requestAdapter();
8132
8143
  if (!adapter) {
8133
8144
  console.warn('q5 WebGPU could not start! No appropriate GPUAdapter found, Vulkan may need to be enabled.');