kopia lustrzana https://github.com/villares/sketch-a-day
main
rodzic
7dd172b55d
commit
e23707f1a5
Plik binarny nie jest wyświetlany.
Plik binarny nie jest wyświetlany.
|
Po Szerokość: | Wysokość: | Rozmiar: 827 KiB |
|
|
@ -0,0 +1,35 @@
|
|||
# Based on an example by @vsquared from this discussion:
|
||||
# https://github.com/py5coding/py5generator/discussions/606#discussioncomment-12267883
|
||||
|
||||
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():
|
||||
py5.size(500, 500, py5.P3D)
|
||||
global slider
|
||||
global picker
|
||||
#py5.hint(py5.ENABLE_DEPTH_SORT)
|
||||
#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))
|
||||
step = 15
|
||||
# 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, step))
|
||||
|
||||
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()
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
# Example by @vsquared from this discussion:
|
||||
# https://github.com/py5coding/py5generator/discussions/606#discussioncomment-12267883
|
||||
|
||||
# Uses Imported mode for py5
|
||||
from controlP5 import ControlP5
|
||||
|
||||
this = get_current_sketch()
|
||||
print(this)
|
||||
|
||||
def settings():
|
||||
size(400,200)
|
||||
|
||||
def setup():
|
||||
global btn1
|
||||
|
||||
window_title("Button cp5 Demo")
|
||||
cp5 = ControlP5(this)
|
||||
btn1 = cp5.addButton("btn1").setValue(0).setPosition(100,40).setSize(100,20)
|
||||
|
||||
# Never called
|
||||
def btn1(value):
|
||||
print("a button event from btn1: " + value);
|
||||
|
||||
# Never called
|
||||
def controlEvent(e):
|
||||
print(e.getController().getName())
|
||||
|
||||
# This works
|
||||
def mouse_pressed(e):
|
||||
if(btn1.isPressed()):
|
||||
print("btn1 was pressed.")
|
||||
|
|
@ -22,6 +22,16 @@ If you appreciate what I have been doing, you may also support my artistic work,
|
|||
|
||||
---
|
||||
|
||||
### sketch_2025_02_20
|
||||
|
||||

|
||||
|
||||
[sketch_2025_02_20](https://github.com/villares/sketch-a-day/tree/main/2025/sketch_2025_02_20) [[py5](https://py5coding.org/)]
|
||||
|
||||
#ControlP5 example. This is a Processing Java library, but it can be used with py5 :)
|
||||
|
||||
---
|
||||
|
||||
### sketch_2025_02_19
|
||||
|
||||

|
||||
|
|
|
|||
Ładowanie…
Reference in New Issue