i’m begging to use Py5Graphics with the command:
pg = py5.create_graphics( 500, 500, ‘P3D’)
and later when i begin to draw into this window, i get the error:
“The P3D renderer is not in the class path”
How is the class path specified?
thank you.
svan
2
This runs without error in Thonny:
import py5
def setup():
global pg
py5.size(400, 400, py5.P2D)
pg = py5.create_graphics(40, 40, py5.P3D)
py5.run_sketch()
Documentation is here if you haven’t already seen it:
2 Likes
We’re supposed to use the already-defined constant P3D
for the renderer parameter:
Which corresponds to the string 'processing.opengl.PGraphics3D'
; not 'P3D'
:
pg = py5.create_graphics(500, 500, py5.P3D)
1 Like
ok, but when i use:
pg = py5.create_graphics(600,600, py5.P3D)
then when it gets to the code:
pg.rotate_x(rx)
i get the error:
rotateX() can only be used with a renderer that supports 3D, such as P3D
can you tell what i’m doing wrong from this?
1 Like
In order to create_graphics() w/ constant P3D, it’s also required to call size() w/ P3D or P2D:
1 Like
glv
6
Hello @larrycuba ,
A working example using a rotation in the PGraphic and outside of it:
import py5
global pg
global counter
global angle
def setup():
py5.size(200, 200, py5.P3D)
global counter
global angle
counter = 0
angle = 0
global pg
pg = py5.create_graphics(60, 60, py5.P3D)
pg.begin_draw()
pg.background(100, 0)
pg.lights()
pg.no_stroke()
pg.fill(255, 0, 0)
pg.translate(30, 30)
pg.rotate(py5.TAU / 8, 0, 1, 0)
pg.box(25)
pg.end_draw()
def draw():
global counter
global angle
py5.background(200)
py5.translate(py5.width / 2, py5.height / 2)
py5.image_mode(py5.CENTER)
counter += 1
angle = counter * (py5.TAU / 360)
py5.rotate(angle, 0, 1, 0)
py5.image(pg, 0, 0)
py5.run_sketch()
This is the environment I am using:
:)
1 Like