File tree Expand file tree Collapse file tree
py5_jar/src/main/java/py5/core Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2020package py5 .core ;
2121
2222import java .io .File ;
23+ import java .util .Random ;
2324
2425import processing .core .PApplet ;
2526import processing .core .PConstants ;
@@ -126,13 +127,25 @@ public void _resetSyncSketch() {
126127 if (savedStyle != null ) {
127128 style (savedStyle );
128129 }
130+
131+ // reset window settings
129132 frameRate (60 );
133+ cursor (ARROW );
134+ noClip ();
135+
136+ // reset 3D settings
137+ if (g .is3D ()) {
138+ camera ();
139+ perspective ();
140+ }
130141
131- // reset shaders
142+ // reset shaders and other opengl only stuff
132143 if (g instanceof PGraphicsOpenGL ) {
133144 resetShader (POINTS );
134145 resetShader (LINES );
135146 resetShader (TRIANGLES );
147+ textureMode (IMAGE );
148+ textureWrap (CLAMP );
136149 }
137150
138151 // reset hints
@@ -147,6 +160,20 @@ public void _resetSyncSketch() {
147160 hint (DISABLE_BUFFER_READING );
148161 hint (DISABLE_KEY_REPEAT );
149162 hint (ENABLE_ASYNC_SAVEFRAME );
163+
164+ // in case user doesn't call background in setup
165+ background (204 );
166+
167+ // reset random methods
168+ osNoiseSeed = (long ) (Math .random () * Long .MAX_VALUE );
169+ noiseSeed ((long ) (Math .random () * Long .MAX_VALUE ));
170+ noiseDetail (4 , 0.5f );
171+
172+ // reset detail settings
173+ sphereDetail (30 );
174+ bezierDetail (20 );
175+ curveDetail (20 );
176+ curveTightness (0f );
150177 }
151178
152179 @ Override
Original file line number Diff line number Diff line change @@ -45,6 +45,9 @@ class MathMixin:
4545 def __init__ (self , * args , ** kwargs ):
4646 super ().__init__ (* args , ** kwargs )
4747 self ._instance = kwargs ["instance" ]
48+ self ._init_math_mixin ()
49+
50+ def _init_math_mixin (self ):
4851 self ._rng = np .random .default_rng ()
4952
5053 # *** BEGIN METHODS ***
Original file line number Diff line number Diff line change 2424import zipfile
2525from pathlib import Path
2626
27+ import numpy as np
2728import stackprinter
2829
2930from .import_hook import activate_py5_live_coding_import_hook
@@ -360,10 +361,12 @@ def post_setup_hook(self, s):
360361 def pre_draw_hook (self , s ):
361362 if self .run_setup_again :
362363 s ._instance ._resetSyncSketch ()
364+ s ._init_math_mixin ()
365+ s .stop_all_threads (wait = False )
366+
363367 UserFunctionWrapper .looping_state = ANIMATION_LOOPING
364368 UserFunctionWrapper .freeze_frame_count = None
365- # in case user doesn't call background in setup
366- s .background (204 )
369+
367370 self .functions ["setup" ]()
368371 self .run_setup_again = False
369372
You can’t perform that action at this time.
0 commit comments