Hello everyone!
I have started to use py5, and I love it, especially the way it’s a python library and the way to handle vectors. Good job and thank you to everyone here who created or contributed to this project.
I have an issue when trying to use the equivalent of pshapes. I tried the examples in the documentation, but encounter the same issue.
def setup():
global s # the Py5Shape object
# creating the Py5Shape as a square. the
# numeric arguments are similar to rect().
s = py5.create_shape(py5.RECT, 0, 0, 50, 50)
s.set_fill("#0000FF")
s.set_stroke(False)
def draw():
py5.shape(s, 25, 25)
This example works fine. The problem appears when I try to use create_shape() without an argument, like in the following example.
s = py5.create_shape()
s.begin_shape(py5.TRIANGLE_STRIP)
s.vertex(30, 75)
s.vertex(40, 20)
s.vertex(50, 75)
s.vertex(60, 20)
s.vertex(70, 75)
s.vertex(80, 20)
s.vertex(90, 75)
s.end_shape()
I get the error that s is not defined, when it’s exactly the same code as the first example.
When I try to declare the shape outside of setup, I get this one:
Traceback (most recent call last):
File “PApplet.java”, line 11139, in processing.core.PApplet.createShape
Exception: Java ExceptionThe above exception was the direct cause of the following exception:
Traceback (most recent call last):
File “F:/xxx/test_pshape.py”, line 29, in
s = py5.create_shape()
File “C:\Users\xxx\anaconda3\envs\py5coding\lib\site-packages\py5_init_.py”, line 5688, in create_shape
return py5sketch.create_shape(*args)
File “C:\Users\xxx\anaconda3\envs\py5coding\lib\site-packages\py5\shape.py”, line 45, in decorated
result = f(self, *args)
File “C:\Users\xxx\anaconda3\envs\py5coding\lib\site-packages\py5\sketch.py”, line 7130, in create_shape
return self._instance.createShape(*args)
java.lang.NullPointerException: java.lang.NullPointerExceptionProcess finished with exit code 1
Could anyone help me? I’m using anaconda and used the command described on the documentation to install an environment.
Info : conda 4.11.0
python 3.9.7
openjdk version “11.0.8” 2020-07-14 LTS
OpenJDK Runtime Environment Zulu11.41+23-CA (build 11.0.8+10-LTS)
OpenJDK 64-Bit Server VM Zulu11.41+23-CA (build 11.0.8+10-LTS, mixed mode)
Windows 10