ControlP5 Demo #606
Replies: 2 comments 18 replies
-
That works well! I see you are explicitly calling The thing that doesn't work (that as you demonstrated is not actually necessary) is how to get ControlP5 to automatically update Python variables as the controls change. That's something that does work in Processing-Java. Theoretically it might be possible for that to work in py5, but it would require some code changes to ControlP5 to adapt it to Python's needs. |
Beta Was this translation helpful? Give feedback.
-
😄 import py5
import py5_tools
# on module mode you have to import py5 before other Java based libraries.
from controlP5 import ControlP5 # jars on jars sub-directory
def setup():
global slider
global picker
py5.size(500, 500, py5.P3D)
#py5.hint(py5.ENABLE_DEPTH_SORT) # kind of trouble
#py5.hint(py5.ENABLE_DEPTH_TEST)
py5.window_title("3D Demo")
cp5 = ControlP5(py5.get_current_sketch())
slider = cp5.addSlider("slider", 0, 255, 150, 30, 10, 200, 20)
picker = cp5.addColorPicker("picker", 270, 10, 100, 20)
picker.setColorValue(py5.color(50, 155, 110))
# This works but doesn't record the widgets! (can be useful!)
#py5_tools.animated_gif(f'out.gif', duration=0.1, frame_numbers=range(1, 360, 15))
def draw():
py5.background(209)
py5.lights()
s = slider.getValue()
c = picker.getColorValue()
with py5.push_matrix():
py5.translate(py5.width / 2, py5.height / 2)
py5.rotate_y(py5.radians(py5.frame_count))
py5.fill(c)
py5.box(s)
py5.run_sketch() |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Demonstrates using cp5 controls in py5. A copy of controlP5.jar must be in 'jars' folder in sketch folder. Jar file on MacOS is at this path: Documents/Processing/libraries/controlP5/library/controlP5.jar
Output:

Beta Was this translation helpful? Give feedback.
All reactions