Hi all,
I’ve been making some really simple, noobish programs and haven’t had any issues until writing one that uses the P2D renderer. I’ve been searching online and have found folks having similar issues, but I can’t seem to resolve it in processing.py. I am having two main issues: issue #1 is that when I am using a keyPressed() function to saveFrame(), when I hit the specified key, it exits the display window instead of saving the frame. Sometimes copying and pasting all of my code into a new file seems to fix the issue, and the frames will save, but then I wind up with issue #2.
Issue #2 is that when saveFrame() is “working”, the frames are outputting as a black image, instead of the actual frame. Once it starts putting out a black frame, I can’t get anything else. I have been running similar sketches that don’t use the P2D renderer, and I have zero issues.
Here is my code:
rstroke = 12
def setup():
size(800,800, P2D)
def draw():
size(800,800, P2D)
noLoop()
img = loadImage("starpattern.JPG")
background(255)
def gn():
return random(100,600)
a = gn()
b = gn()
c = gn()
d = gn()
beginShape()
texture(img)
vertex(a,b,a,b)
vertex(c,b,c,b)
vertex(c,d,c,d)
vertex(a,d,a,d)
endShape(CLOSE)
strokeWeight(random(rstroke))
noFill()
circle(gn(),gn(),gn())
strokeWeight(random(rstroke))
line(gn(),gn(),gn(),gn())
strokeWeight(random(rstroke))
line(gn(),gn(),gn(),gn())
def mouseClicked():
loop()
def keyPressed():
if key == 's':
saveFrame("design-####.png")
If anyone has some insight as to what I might be doing wrong, or whether there is some sort of workaround, I would be super grateful!