q5 4.5.4 → 4.6.1

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/README.md CHANGED
@@ -17,13 +17,13 @@ circle(0, 0, 80);
17
17
 
18
18
  ## Documentation
19
19
 
20
- The [q5 learn pages](https://q5js.org/learn) are organized into sections with interactive mini-examples.
20
+ The [q5 learn pages](https://q5js.org/learn) have interactive mini-examples.
21
21
 
22
22
  See the [wiki](https://github.com/q5js/q5.js/wiki) for extended documentation.
23
23
 
24
24
  ## Support q5 💙
25
25
 
26
- q5 is open source and anyone can use it for free under the terms of the LGPL. 🎉
26
+ q5 is open source. Anyone can use it for free under the terms of the LGPL. 🎉
27
27
 
28
28
  We need your support though! If you enjoy using q5, please donate via [GitHub Sponsors](https://github.com/sponsors/quinton-ashley), [ko-fi](https://ko-fi.com/q5play), or [Patreon](https://www.patreon.com/q5play).
29
29
 
package/deno.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@q5/q5",
3
- "version": "4.5.4",
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,15 +1,8 @@
1
1
  {
2
2
  "name": "q5",
3
- "version": "4.5.4",
3
+ "version": "4.6.1",
4
4
  "description": "Beginner friendly graphics powered by WebGPU, optimized for interactive art!",
5
5
  "author": "quinton-ashley",
6
- "contributors": [
7
- "evanalulu",
8
- "Tezumie",
9
- "ormaq",
10
- "Dukemz",
11
- "LingDong-"
12
- ],
13
6
  "license": "LGPL-3.0-only",
14
7
  "homepage": "https://q5js.org/home",
15
8
  "types": "q5.d.ts",
package/q5.js CHANGED
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * q5.js
3
- * @version 4.5
3
+ * @version 4.6
4
4
  * @author quinton-ashley
5
- * @contributors evanalulu, Tezumie, ormaq, Dukemz, LingDong-
5
+ * @contributors evanalulu, Tezumie, keturn, ormaq, bertubi, RedWilly, Dukemz, LingDong-
6
6
  * @license LGPL-3.0
7
7
  * @class Q5
8
8
  */
@@ -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', () => {
@@ -9611,25 +9611,7 @@ const runPython = async function () {
9611
9611
  async def __run(q):
9612
9612
  ${code}
9613
9613
 
9614
- _state_vars = ["mouseX", "mouseY", "pmouseX", "pmouseY", "width", "height", "frameCount", "deltaTime", "mouseIsPressed", "mouseButton", "keyIsPressed", "key", "keyCode", "touches", "movedX", "movedY"]
9615
-
9616
- _usr_fns = ["update", "draw", "postProcess", "mousePressed", "mouseReleased", "mouseMoved", "mouseDragged", "mouseClicked", "doubleClicked", "mouseWheel", "keyPressed", "keyReleased", "keyTyped", "touchStarted", "touchMoved", "touchEnded", "windowResized"]
9617
-
9618
- def _sync_and_call(fn):
9619
- def _wrapper(*args):
9620
- try:
9621
- for var in _state_vars:
9622
- if hasattr(q, var):
9623
- ns[var] = getattr(q, var)
9624
- return fn(*args)
9625
- except Exception as e:
9626
- window._pyErr(_err())
9627
- if not window.Q5.errorTolerant: noLoop()
9628
- return _wrapper
9629
-
9630
- for fn_name in _usr_fns:
9631
- if fn_name in locals():
9632
- setattr(window, fn_name, _sync_and_call(locals()[fn_name]))
9614
+ _wrap_fns(q, locals(), ns)
9633
9615
  `;
9634
9616
 
9635
9617
  window._pyErr = (err, lineNum) => {
@@ -9676,11 +9658,35 @@ from browser import window, aio
9676
9658
  import traceback
9677
9659
  import io
9678
9660
 
9661
+ _state_vars = ["frameCount", "deltaTime", "width", "height", "halfWidth", "halfHeight", "windowWidth", "windowHeight", "mouseX", "mouseY", "pmouseX", "pmouseY", "movedX", "movedY", "mouseIsPressed", "mouseButton", "keyIsPressed", "key", "keyCode", "touches", "recording"]
9662
+
9663
+ _usr_fns = ["update", "draw", "postProcess", "mousePressed", "mouseReleased", "mouseMoved", "mouseDragged", "mouseClicked", "doubleClicked", "mouseWheel", "keyPressed", "keyReleased", "keyTyped", "touchStarted", "touchMoved", "touchEnded", "windowResized"]
9664
+
9679
9665
  def _err():
9680
9666
  f = io.StringIO()
9681
9667
  traceback.print_exc(file=f)
9682
9668
  return f.getvalue()
9683
9669
 
9670
+ def _sync_state(q, ns):
9671
+ for var in _state_vars:
9672
+ if hasattr(q, var):
9673
+ ns[var] = getattr(q, var)
9674
+
9675
+ def _sync_and_call(q, fn, ns):
9676
+ def _wrapper(*args):
9677
+ try:
9678
+ _sync_state(q, ns)
9679
+ return fn(*args)
9680
+ except Exception as e:
9681
+ window._pyErr(_err(), None, q)
9682
+ if not window.Q5.errorTolerant: q.noLoop()
9683
+ return _wrapper
9684
+
9685
+ def _wrap_fns(q, locs, ns):
9686
+ for fn_name in _usr_fns:
9687
+ if fn_name in locs:
9688
+ setattr(q, fn_name, _sync_and_call(q, locs[fn_name], ns))
9689
+
9684
9690
  async def _run_py(q, code):
9685
9691
  ns = globals().copy()
9686
9692
  ns['ns'] = ns
@@ -9693,17 +9699,24 @@ async def _run_py(q, code):
9693
9699
  except Exception:
9694
9700
  pass
9695
9701
 
9702
+ _orig_Canvas = ns['Canvas']
9703
+ async def _canvas_wrapper(*args):
9704
+ result = await _orig_Canvas(*args)
9705
+ _sync_state(q, ns)
9706
+ return result
9707
+ ns['Canvas'] = ns['createCanvas'] = _canvas_wrapper
9708
+
9696
9709
  try:
9697
9710
  exec(code, ns)
9698
9711
  except SyntaxError as e:
9699
- return window._pyErr(_err(), e.lineno)
9712
+ return window._pyErr(_err(), e.lineno, q)
9700
9713
  except Exception as e:
9701
- return window._pyErr(_err())
9702
-
9714
+ return window._pyErr(_err(), 0, q)
9715
+
9703
9716
  try:
9704
9717
  await ns["__run"](q)
9705
9718
  except Exception as e:
9706
- window._pyErr(_err())
9719
+ window._pyErr(_err(), 0, q)
9707
9720
 
9708
9721
  window._runPy = _run_py
9709
9722
  `);