Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion py5_jar/src/main/java/py5/core/Sketch.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
package py5.core;

import java.io.File;
import java.util.Random;

import processing.core.PApplet;
import processing.core.PConstants;
Expand Down Expand Up @@ -126,13 +127,25 @@ public void _resetSyncSketch() {
if (savedStyle != null) {
style(savedStyle);
}

// reset window settings
frameRate(60);
cursor(ARROW);
noClip();

// reset 3D settings
if (g.is3D()) {
camera();
perspective();
}

// 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
Expand All @@ -147,6 +160,20 @@ public void _resetSyncSketch() {
hint(DISABLE_BUFFER_READING);
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 detail settings
sphereDetail(30);
bezierDetail(20);
curveDetail(20);
curveTightness(0f);
}

@Override
Expand Down
3 changes: 3 additions & 0 deletions py5_resources/py5_module/py5/mixins/math.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 ***
Expand Down
7 changes: 5 additions & 2 deletions py5_resources/py5_module/py5_tools/live_coding/syncing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -360,10 +361,12 @@ def post_setup_hook(self, s):
def pre_draw_hook(self, s):
if self.run_setup_again:
s._instance._resetSyncSketch()
s._init_math_mixin()
s.stop_all_threads(wait=False)

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

Expand Down