From 3beb003f0294586b41bcf5ac937515e398513c95 Mon Sep 17 00:00:00 2001 From: Jim Date: Thu, 31 Oct 2024 18:19:51 -0400 Subject: [PATCH 01/23] more stuff to do for live coding --- py5_jar/src/main/java/py5/core/Sketch.java | 28 +++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/py5_jar/src/main/java/py5/core/Sketch.java b/py5_jar/src/main/java/py5/core/Sketch.java index 6ebe0237..ca2cfdf8 100644 --- a/py5_jar/src/main/java/py5/core/Sketch.java +++ b/py5_jar/src/main/java/py5/core/Sketch.java @@ -126,7 +126,6 @@ public void _resetSyncSketch() { if (savedStyle != null) { style(savedStyle); } - frameRate(60); // reset shaders if (g instanceof PGraphicsOpenGL) { @@ -147,6 +146,33 @@ public void _resetSyncSketch() { hint(DISABLE_BUFFER_READING); hint(DISABLE_KEY_REPEAT); hint(ENABLE_ASYNC_SAVEFRAME); + + // reset random methods + // osNoiseSeed = (long) (Math.random() * Long.MAX_VALUE); + // pnoise seed + // pnoise detail + // random seed (in Python?) + + // reset window settings + frameRate(60); + // windowTitle("Sketch"); + // cursor(ARROW); + + // reset detail settings + // sphere detail + // bezier detail + // curve detail + // curve tightness + // texture mode, texture wrap + + // reset camera settings + // camera, ortho, etc + // clip / no_clip? + + // reset misc settings + // stop threads in Python + // reset print stream? + // changes to run_sketch() params will not work most likely } @Override From 06f14b0de9ed918603df6d30b04b5d46ee20fa4c Mon Sep 17 00:00:00 2001 From: Jim Date: Thu, 31 Oct 2024 19:30:32 -0400 Subject: [PATCH 02/23] reset os noise seed --- py5_jar/src/main/java/py5/core/Sketch.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/py5_jar/src/main/java/py5/core/Sketch.java b/py5_jar/src/main/java/py5/core/Sketch.java index ca2cfdf8..59dcd9ae 100644 --- a/py5_jar/src/main/java/py5/core/Sketch.java +++ b/py5_jar/src/main/java/py5/core/Sketch.java @@ -148,15 +148,14 @@ public void _resetSyncSketch() { hint(ENABLE_ASYNC_SAVEFRAME); // reset random methods - // osNoiseSeed = (long) (Math.random() * Long.MAX_VALUE); + osNoiseSeed = (long) (Math.random() * Long.MAX_VALUE); // pnoise seed // pnoise detail // random seed (in Python?) // reset window settings frameRate(60); - // windowTitle("Sketch"); - // cursor(ARROW); + // cursor(ARROW); // not needed? // reset detail settings // sphere detail From 452820ef6d535eae0d8a7602ec05f92f775ab679 Mon Sep 17 00:00:00 2001 From: Jim Date: Thu, 31 Oct 2024 19:32:26 -0400 Subject: [PATCH 03/23] noise detail --- py5_jar/src/main/java/py5/core/Sketch.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/py5_jar/src/main/java/py5/core/Sketch.java b/py5_jar/src/main/java/py5/core/Sketch.java index 59dcd9ae..aa8fca0d 100644 --- a/py5_jar/src/main/java/py5/core/Sketch.java +++ b/py5_jar/src/main/java/py5/core/Sketch.java @@ -149,8 +149,8 @@ public void _resetSyncSketch() { // reset random methods osNoiseSeed = (long) (Math.random() * Long.MAX_VALUE); - // pnoise seed - // pnoise detail + // pnoise seed - how is this set? + noiseDetail(4, 0.5f); // random seed (in Python?) // reset window settings From 4cbd73f5969941afa7adf12641b7df30ce651283 Mon Sep 17 00:00:00 2001 From: Jim Date: Thu, 31 Oct 2024 23:24:30 -0400 Subject: [PATCH 04/23] noise detail --- py5_jar/src/main/java/py5/core/Sketch.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/py5_jar/src/main/java/py5/core/Sketch.java b/py5_jar/src/main/java/py5/core/Sketch.java index aa8fca0d..f3979065 100644 --- a/py5_jar/src/main/java/py5/core/Sketch.java +++ b/py5_jar/src/main/java/py5/core/Sketch.java @@ -150,7 +150,7 @@ public void _resetSyncSketch() { // reset random methods osNoiseSeed = (long) (Math.random() * Long.MAX_VALUE); // pnoise seed - how is this set? - noiseDetail(4, 0.5f); + noiseDetail(4, 0.5f); // am I sure this is needed? // random seed (in Python?) // reset window settings From 3370ee7710e440ec03db6160494278fd942175cc Mon Sep 17 00:00:00 2001 From: Jim Date: Thu, 31 Oct 2024 23:26:43 -0400 Subject: [PATCH 05/23] fix cursor --- py5_jar/src/main/java/py5/core/Sketch.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/py5_jar/src/main/java/py5/core/Sketch.java b/py5_jar/src/main/java/py5/core/Sketch.java index f3979065..a46065ba 100644 --- a/py5_jar/src/main/java/py5/core/Sketch.java +++ b/py5_jar/src/main/java/py5/core/Sketch.java @@ -155,7 +155,7 @@ public void _resetSyncSketch() { // reset window settings frameRate(60); - // cursor(ARROW); // not needed? + cursor(ARROW); // reset detail settings // sphere detail From 078dcf397807302ca40ae3cf9f724f41faa0af0f Mon Sep 17 00:00:00 2001 From: Jim Date: Thu, 31 Oct 2024 23:31:16 -0400 Subject: [PATCH 06/23] perlin noise reset --- py5_jar/src/main/java/py5/core/Sketch.java | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/py5_jar/src/main/java/py5/core/Sketch.java b/py5_jar/src/main/java/py5/core/Sketch.java index a46065ba..8d62d595 100644 --- a/py5_jar/src/main/java/py5/core/Sketch.java +++ b/py5_jar/src/main/java/py5/core/Sketch.java @@ -20,6 +20,7 @@ package py5.core; import java.io.File; +import java.util.Random; import processing.core.PApplet; import processing.core.PConstants; @@ -149,12 +150,11 @@ public void _resetSyncSketch() { // reset random methods osNoiseSeed = (long) (Math.random() * Long.MAX_VALUE); - // pnoise seed - how is this set? - noiseDetail(4, 0.5f); // am I sure this is needed? - // random seed (in Python?) + noiseSeed((long) (Math.random() * Long.MAX_VALUE)); + noiseDetail(4, 0.5f); // reset window settings - frameRate(60); + frameRate(60); cursor(ARROW); // reset detail settings @@ -168,10 +168,11 @@ public void _resetSyncSketch() { // camera, ortho, etc // clip / no_clip? - // reset misc settings - // stop threads in Python - // reset print stream? - // changes to run_sketch() params will not work most likely + // reset stuff in Python? + // random seed self._rng = np.random.default_rng() + // stop threads + // reset print stream + // document: changes to run_sketch() params will not work } @Override From d14ab3e2a2ede7a400b943930328506e41ee0d21 Mon Sep 17 00:00:00 2001 From: Jim Date: Thu, 31 Oct 2024 23:41:00 -0400 Subject: [PATCH 07/23] sphere detail --- py5_jar/src/main/java/py5/core/Sketch.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/py5_jar/src/main/java/py5/core/Sketch.java b/py5_jar/src/main/java/py5/core/Sketch.java index 8d62d595..f323b016 100644 --- a/py5_jar/src/main/java/py5/core/Sketch.java +++ b/py5_jar/src/main/java/py5/core/Sketch.java @@ -158,7 +158,7 @@ public void _resetSyncSketch() { cursor(ARROW); // reset detail settings - // sphere detail + sphereDetail(30); // bezier detail // curve detail // curve tightness From c368baf86a685f6e96c525e617b03671240ee1be Mon Sep 17 00:00:00 2001 From: Jim Date: Thu, 31 Oct 2024 23:42:52 -0400 Subject: [PATCH 08/23] bezier detail --- py5_jar/src/main/java/py5/core/Sketch.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/py5_jar/src/main/java/py5/core/Sketch.java b/py5_jar/src/main/java/py5/core/Sketch.java index f323b016..be8e2e8b 100644 --- a/py5_jar/src/main/java/py5/core/Sketch.java +++ b/py5_jar/src/main/java/py5/core/Sketch.java @@ -159,7 +159,7 @@ public void _resetSyncSketch() { // reset detail settings sphereDetail(30); - // bezier detail + bezierDetail(20); // curve detail // curve tightness // texture mode, texture wrap From e8ee22d6d05190ba699b36cbeedc95c26a9055d8 Mon Sep 17 00:00:00 2001 From: Jim Date: Thu, 31 Oct 2024 23:44:00 -0400 Subject: [PATCH 09/23] curve detail --- py5_jar/src/main/java/py5/core/Sketch.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/py5_jar/src/main/java/py5/core/Sketch.java b/py5_jar/src/main/java/py5/core/Sketch.java index be8e2e8b..2cbcd38c 100644 --- a/py5_jar/src/main/java/py5/core/Sketch.java +++ b/py5_jar/src/main/java/py5/core/Sketch.java @@ -160,7 +160,7 @@ public void _resetSyncSketch() { // reset detail settings sphereDetail(30); bezierDetail(20); - // curve detail + curveDetail(20); // curve tightness // texture mode, texture wrap From 38537e756511dc14cc5e0d7ba4e99682bbec83ff Mon Sep 17 00:00:00 2001 From: Jim Date: Thu, 31 Oct 2024 23:44:51 -0400 Subject: [PATCH 10/23] curve tightness --- py5_jar/src/main/java/py5/core/Sketch.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/py5_jar/src/main/java/py5/core/Sketch.java b/py5_jar/src/main/java/py5/core/Sketch.java index 2cbcd38c..6474208c 100644 --- a/py5_jar/src/main/java/py5/core/Sketch.java +++ b/py5_jar/src/main/java/py5/core/Sketch.java @@ -161,7 +161,7 @@ public void _resetSyncSketch() { sphereDetail(30); bezierDetail(20); curveDetail(20); - // curve tightness + curveTightness(0f); // texture mode, texture wrap // reset camera settings From 2f2695f5114e69c45deabef7bae4cd554363ef5c Mon Sep 17 00:00:00 2001 From: Jim Date: Thu, 31 Oct 2024 23:47:31 -0400 Subject: [PATCH 11/23] texture mode --- py5_jar/src/main/java/py5/core/Sketch.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/py5_jar/src/main/java/py5/core/Sketch.java b/py5_jar/src/main/java/py5/core/Sketch.java index 6474208c..28e38c7c 100644 --- a/py5_jar/src/main/java/py5/core/Sketch.java +++ b/py5_jar/src/main/java/py5/core/Sketch.java @@ -162,7 +162,8 @@ public void _resetSyncSketch() { bezierDetail(20); curveDetail(20); curveTightness(0f); - // texture mode, texture wrap + textureMode(IMAGE); + // texture wrap // reset camera settings // camera, ortho, etc From 9b1c629101ae4f68db8cf72eac0b2bb076b66008 Mon Sep 17 00:00:00 2001 From: Jim Date: Thu, 31 Oct 2024 23:49:01 -0400 Subject: [PATCH 12/23] texture stuff --- py5_jar/src/main/java/py5/core/Sketch.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/py5_jar/src/main/java/py5/core/Sketch.java b/py5_jar/src/main/java/py5/core/Sketch.java index 28e38c7c..5f84a690 100644 --- a/py5_jar/src/main/java/py5/core/Sketch.java +++ b/py5_jar/src/main/java/py5/core/Sketch.java @@ -128,11 +128,13 @@ public void _resetSyncSketch() { style(savedStyle); } - // reset shaders + // reset shaders and other opengl only stuff if (g instanceof PGraphicsOpenGL) { resetShader(POINTS); resetShader(LINES); resetShader(TRIANGLES); + textureMode(IMAGE); + textureWrap(CLAMP); } // reset hints @@ -162,8 +164,6 @@ public void _resetSyncSketch() { bezierDetail(20); curveDetail(20); curveTightness(0f); - textureMode(IMAGE); - // texture wrap // reset camera settings // camera, ortho, etc From c06bc9bc6c4d9165a13b8e0e3e9a05bcec718932 Mon Sep 17 00:00:00 2001 From: Jim Date: Fri, 1 Nov 2024 00:00:39 -0400 Subject: [PATCH 13/23] deal with clip and no clip --- py5_jar/src/main/java/py5/core/Sketch.java | 13 ++++++++----- .../py5_module/py5_tools/live_coding/syncing.py | 2 -- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/py5_jar/src/main/java/py5/core/Sketch.java b/py5_jar/src/main/java/py5/core/Sketch.java index 5f84a690..9f749b7b 100644 --- a/py5_jar/src/main/java/py5/core/Sketch.java +++ b/py5_jar/src/main/java/py5/core/Sketch.java @@ -128,6 +128,9 @@ public void _resetSyncSketch() { style(savedStyle); } + // in case user doesn't call background in setup + background(204); + // reset shaders and other opengl only stuff if (g instanceof PGraphicsOpenGL) { resetShader(POINTS); @@ -158,6 +161,7 @@ public void _resetSyncSketch() { // reset window settings frameRate(60); cursor(ARROW); + noClip(); // reset detail settings sphereDetail(30); @@ -165,15 +169,14 @@ public void _resetSyncSketch() { curveDetail(20); curveTightness(0f); - // reset camera settings - // camera, ortho, etc - // clip / no_clip? - // reset stuff in Python? // random seed self._rng = np.random.default_rng() // stop threads // reset print stream - // document: changes to run_sketch() params will not work + + // things to document + // changes to run_sketch() params will not work + // issues if you add a call to clip() } @Override diff --git a/py5_resources/py5_module/py5_tools/live_coding/syncing.py b/py5_resources/py5_module/py5_tools/live_coding/syncing.py index 4ddcee51..c87d1176 100644 --- a/py5_resources/py5_module/py5_tools/live_coding/syncing.py +++ b/py5_resources/py5_module/py5_tools/live_coding/syncing.py @@ -362,8 +362,6 @@ def pre_draw_hook(self, s): s._instance._resetSyncSketch() UserFunctionWrapper.looping_state = ANIMATION_LOOPING UserFunctionWrapper.freeze_frame_count = None - # in case user doesn't call background in setup - s.background(204) self.functions["setup"]() self.run_setup_again = False From c6125bb0a83034430b587308b13071b75c02bc77 Mon Sep 17 00:00:00 2001 From: Jim Date: Fri, 1 Nov 2024 00:02:03 -0400 Subject: [PATCH 14/23] camera stuff --- py5_jar/src/main/java/py5/core/Sketch.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/py5_jar/src/main/java/py5/core/Sketch.java b/py5_jar/src/main/java/py5/core/Sketch.java index 9f749b7b..7cbf4754 100644 --- a/py5_jar/src/main/java/py5/core/Sketch.java +++ b/py5_jar/src/main/java/py5/core/Sketch.java @@ -138,6 +138,11 @@ public void _resetSyncSketch() { resetShader(TRIANGLES); textureMode(IMAGE); textureWrap(CLAMP); + + if (g.is3D()) { + camera(); + perspective(); + } } // reset hints From 48c85cd99d2a338489864f6c9daa42005ddb1e2e Mon Sep 17 00:00:00 2001 From: Jim Date: Fri, 1 Nov 2024 00:14:39 -0400 Subject: [PATCH 15/23] init print stream method --- py5_resources/py5_module/py5/sketch.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/py5_resources/py5_module/py5/sketch.py b/py5_resources/py5_module/py5/sketch.py index 6b1f7050..2bb6f1fb 100644 --- a/py5_resources/py5_module/py5/sketch.py +++ b/py5_resources/py5_module/py5/sketch.py @@ -318,11 +318,7 @@ def _run_sketch( _osx_alt_run_method: bool = True, ) -> None: self._environ = _environ.Environment() - self.set_println_stream( - _DisplayPubPrintlnStream() - if self._environ.in_jupyter_zmq_shell - else _DefaultPrintlnStream() - ) + self._init_print_stream() self._py5_bridge = Py5Bridge(self) self._py5_bridge.set_caller_locals_globals(_caller_locals, _caller_globals) @@ -438,6 +434,13 @@ def _terminate_sketch(self): self._shutdown_initiated = True self._shutdown() + def _init_print_stream(self): + self.set_println_stream( + _DisplayPubPrintlnStream() + if self._environ.in_jupyter_zmq_shell + else _DefaultPrintlnStream() + ) + def _add_pre_hook(self, method_name, hook_name, function): if self._py5_bridge is None: self._pre_hooks_to_add.append((method_name, hook_name, function)) From 516856525bf767cc2c36705242db38c293f99cb5 Mon Sep 17 00:00:00 2001 From: Jim Date: Fri, 1 Nov 2024 00:15:04 -0400 Subject: [PATCH 16/23] reset things on Python side --- py5_resources/py5_module/py5_tools/live_coding/syncing.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/py5_resources/py5_module/py5_tools/live_coding/syncing.py b/py5_resources/py5_module/py5_tools/live_coding/syncing.py index c87d1176..f59c31ec 100644 --- a/py5_resources/py5_module/py5_tools/live_coding/syncing.py +++ b/py5_resources/py5_module/py5_tools/live_coding/syncing.py @@ -24,6 +24,7 @@ import zipfile from pathlib import Path +import numpy as np import stackprinter from .import_hook import activate_py5_live_coding_import_hook @@ -360,8 +361,13 @@ def post_setup_hook(self, s): def pre_draw_hook(self, s): if self.run_setup_again: s._instance._resetSyncSketch() + s._rng = np.random.default_rng() + s.stop_all_threads(wait=False) + s._init_print_stream() + UserFunctionWrapper.looping_state = ANIMATION_LOOPING UserFunctionWrapper.freeze_frame_count = None + self.functions["setup"]() self.run_setup_again = False From 045a1caadd047410c8a9b8066dc3b02bd7efce6b Mon Sep 17 00:00:00 2001 From: Jim Date: Fri, 1 Nov 2024 00:15:50 -0400 Subject: [PATCH 17/23] clean up comments --- py5_jar/src/main/java/py5/core/Sketch.java | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/py5_jar/src/main/java/py5/core/Sketch.java b/py5_jar/src/main/java/py5/core/Sketch.java index 7cbf4754..9b72d147 100644 --- a/py5_jar/src/main/java/py5/core/Sketch.java +++ b/py5_jar/src/main/java/py5/core/Sketch.java @@ -174,14 +174,10 @@ public void _resetSyncSketch() { curveDetail(20); curveTightness(0f); - // reset stuff in Python? - // random seed self._rng = np.random.default_rng() - // stop threads - // reset print stream - // things to document // changes to run_sketch() params will not work // issues if you add a call to clip() + // issues with threads not stopping } @Override From 48efd7eb17cf9f538febe837518189b056cc60fe Mon Sep 17 00:00:00 2001 From: Jim Date: Fri, 1 Nov 2024 00:23:36 -0400 Subject: [PATCH 18/23] put print stream stuff back --- py5_resources/py5_module/py5/sketch.py | 13 +++++-------- .../py5_module/py5_tools/live_coding/syncing.py | 1 - 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/py5_resources/py5_module/py5/sketch.py b/py5_resources/py5_module/py5/sketch.py index 2bb6f1fb..6b1f7050 100644 --- a/py5_resources/py5_module/py5/sketch.py +++ b/py5_resources/py5_module/py5/sketch.py @@ -318,7 +318,11 @@ def _run_sketch( _osx_alt_run_method: bool = True, ) -> None: self._environ = _environ.Environment() - self._init_print_stream() + self.set_println_stream( + _DisplayPubPrintlnStream() + if self._environ.in_jupyter_zmq_shell + else _DefaultPrintlnStream() + ) self._py5_bridge = Py5Bridge(self) self._py5_bridge.set_caller_locals_globals(_caller_locals, _caller_globals) @@ -434,13 +438,6 @@ def _terminate_sketch(self): self._shutdown_initiated = True self._shutdown() - def _init_print_stream(self): - self.set_println_stream( - _DisplayPubPrintlnStream() - if self._environ.in_jupyter_zmq_shell - else _DefaultPrintlnStream() - ) - def _add_pre_hook(self, method_name, hook_name, function): if self._py5_bridge is None: self._pre_hooks_to_add.append((method_name, hook_name, function)) diff --git a/py5_resources/py5_module/py5_tools/live_coding/syncing.py b/py5_resources/py5_module/py5_tools/live_coding/syncing.py index f59c31ec..03feefea 100644 --- a/py5_resources/py5_module/py5_tools/live_coding/syncing.py +++ b/py5_resources/py5_module/py5_tools/live_coding/syncing.py @@ -363,7 +363,6 @@ def pre_draw_hook(self, s): s._instance._resetSyncSketch() s._rng = np.random.default_rng() s.stop_all_threads(wait=False) - s._init_print_stream() UserFunctionWrapper.looping_state = ANIMATION_LOOPING UserFunctionWrapper.freeze_frame_count = None From c6ac78103634fd5419c61b1a729468b49b823b06 Mon Sep 17 00:00:00 2001 From: Jim Date: Fri, 1 Nov 2024 00:24:45 -0400 Subject: [PATCH 19/23] minor --- py5_jar/src/main/java/py5/core/Sketch.java | 1 + 1 file changed, 1 insertion(+) diff --git a/py5_jar/src/main/java/py5/core/Sketch.java b/py5_jar/src/main/java/py5/core/Sketch.java index 9b72d147..da3aa487 100644 --- a/py5_jar/src/main/java/py5/core/Sketch.java +++ b/py5_jar/src/main/java/py5/core/Sketch.java @@ -178,6 +178,7 @@ public void _resetSyncSketch() { // changes to run_sketch() params will not work // issues if you add a call to clip() // issues with threads not stopping + // don't mess with print stream } @Override From ded7bbb60f945bc60d76eb778b4b889df7594fa8 Mon Sep 17 00:00:00 2001 From: Jim Date: Fri, 1 Nov 2024 00:30:55 -0400 Subject: [PATCH 20/23] clean up math reset --- py5_resources/py5_module/py5/mixins/math.py | 3 +++ py5_resources/py5_module/py5_tools/live_coding/syncing.py | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/py5_resources/py5_module/py5/mixins/math.py b/py5_resources/py5_module/py5/mixins/math.py index 5aa91bee..7403e42f 100644 --- a/py5_resources/py5_module/py5/mixins/math.py +++ b/py5_resources/py5_module/py5/mixins/math.py @@ -45,6 +45,9 @@ class MathMixin: def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self._instance = kwargs["instance"] + self._init_math_mixin() + + def _init_math_mixin(self): self._rng = np.random.default_rng() # *** BEGIN METHODS *** diff --git a/py5_resources/py5_module/py5_tools/live_coding/syncing.py b/py5_resources/py5_module/py5_tools/live_coding/syncing.py index 03feefea..55eb5a59 100644 --- a/py5_resources/py5_module/py5_tools/live_coding/syncing.py +++ b/py5_resources/py5_module/py5_tools/live_coding/syncing.py @@ -361,7 +361,7 @@ def post_setup_hook(self, s): def pre_draw_hook(self, s): if self.run_setup_again: s._instance._resetSyncSketch() - s._rng = np.random.default_rng() + s._init_math_mixin() s.stop_all_threads(wait=False) UserFunctionWrapper.looping_state = ANIMATION_LOOPING From e3ee72bd7a8d3bb07f04652008f94aaac9f46d74 Mon Sep 17 00:00:00 2001 From: Jim Date: Fri, 1 Nov 2024 00:33:19 -0400 Subject: [PATCH 21/23] remove comments --- py5_jar/src/main/java/py5/core/Sketch.java | 6 ------ 1 file changed, 6 deletions(-) diff --git a/py5_jar/src/main/java/py5/core/Sketch.java b/py5_jar/src/main/java/py5/core/Sketch.java index da3aa487..9d733032 100644 --- a/py5_jar/src/main/java/py5/core/Sketch.java +++ b/py5_jar/src/main/java/py5/core/Sketch.java @@ -173,12 +173,6 @@ public void _resetSyncSketch() { bezierDetail(20); curveDetail(20); curveTightness(0f); - - // things to document - // changes to run_sketch() params will not work - // issues if you add a call to clip() - // issues with threads not stopping - // don't mess with print stream } @Override From 9d1c9b195f14089dcb8e91d91bd138dc54249ae9 Mon Sep 17 00:00:00 2001 From: Jim Date: Fri, 1 Nov 2024 21:20:10 -0400 Subject: [PATCH 22/23] move 3d settings code --- py5_jar/src/main/java/py5/core/Sketch.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/py5_jar/src/main/java/py5/core/Sketch.java b/py5_jar/src/main/java/py5/core/Sketch.java index 9d733032..a1cec082 100644 --- a/py5_jar/src/main/java/py5/core/Sketch.java +++ b/py5_jar/src/main/java/py5/core/Sketch.java @@ -138,11 +138,12 @@ public void _resetSyncSketch() { resetShader(TRIANGLES); textureMode(IMAGE); textureWrap(CLAMP); + } - if (g.is3D()) { - camera(); - perspective(); - } + // reset 3D settings + if (g.is3D()) { + camera(); + perspective(); } // reset hints From 2fa8062bc0f0f439b00a58569c24eec64100f481 Mon Sep 17 00:00:00 2001 From: Jim Date: Fri, 1 Nov 2024 21:35:07 -0400 Subject: [PATCH 23/23] move code around --- py5_jar/src/main/java/py5/core/Sketch.java | 26 +++++++++++----------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/py5_jar/src/main/java/py5/core/Sketch.java b/py5_jar/src/main/java/py5/core/Sketch.java index a1cec082..a21e96af 100644 --- a/py5_jar/src/main/java/py5/core/Sketch.java +++ b/py5_jar/src/main/java/py5/core/Sketch.java @@ -128,8 +128,16 @@ public void _resetSyncSketch() { style(savedStyle); } - // in case user doesn't call background in setup - background(204); + // reset window settings + frameRate(60); + cursor(ARROW); + noClip(); + + // reset 3D settings + if (g.is3D()) { + camera(); + perspective(); + } // reset shaders and other opengl only stuff if (g instanceof PGraphicsOpenGL) { @@ -140,12 +148,6 @@ public void _resetSyncSketch() { textureWrap(CLAMP); } - // reset 3D settings - if (g.is3D()) { - camera(); - perspective(); - } - // reset hints hint(ENABLE_DEPTH_TEST); hint(DISABLE_DEPTH_SORT); @@ -159,16 +161,14 @@ public void _resetSyncSketch() { hint(DISABLE_KEY_REPEAT); hint(ENABLE_ASYNC_SAVEFRAME); + // in case user doesn't call background in setup + background(204); + // reset random methods osNoiseSeed = (long) (Math.random() * Long.MAX_VALUE); noiseSeed((long) (Math.random() * Long.MAX_VALUE)); noiseDetail(4, 0.5f); - // reset window settings - frameRate(60); - cursor(ARROW); - noClip(); - // reset detail settings sphereDetail(30); bezierDetail(20);