We are about to switch to a new forum software. Until then we have removed the registration on this forum.
(Please forgive me for asking a lot of questions recently, I'm just trying to be as efficient as possible while learning Processing.)
I'm drawing multiple ellipses that I would like to convert to PGraphics objects. The goal here is to later apply a blur effect to each object without having the frame rate dropping too much.
Ellipses look like this:
When converting them to PG objects I encounter different problems:
There must be something I'm doing wrong but can't figure out what exactely.
Snippet (from line 28 to 35):
pg.beginDraw() pg.noStroke() for b in balls: pg.ellipse(b.x, b.y, b.r, b.r) pg.fill(b.color,b.color,b.color) image(pg, b.x, b.y) b.update() pg.endDraw()
colors = [[255,20, 20], [20,255,255], [250,255,20]] count = 0 rdm_count = 1 balls =  def setup(): global origin, pg size(800, 600, P2D) pg = createGraphics(10, 10) noStroke() def draw(): global origin, count, rdm_count background(30, 60, 100) if count == rdm_count: balls.append(Ball()) count = 0 rdm_count = 3 + floor(random(1) * 5) # for b in balls: # ellipse(b.x, b.y, b.r, b.r) # fill(b.color,b.color,b.color) # b.update() pg.beginDraw() pg.noStroke() for b in balls: pg.ellipse(b.x, b.y, b.r, b.r) pg.fill(b.color,b.color,b.color) image(pg, b.x, b.y) b.update() pg.endDraw() removeBall() count += 1 def removeBall(): for i, b in enumerate(balls): if b.x + b.r < 0 or b.x - b.r > width or b.y + b.r < 0 or b.y - b.r > height or b.r <= 0: del balls[i] class Ball(object): def __init__(self): self.x = random(width) self.y = random(height) self.angle = PI * 2 * random(1) self.vx = (1.3 + random(1) * .3) * cos(self.angle) self.vy = (1.3 + random(1) * .3) * sin(self.angle) self.r = 6 + 3 * random(1) self.color = colors[int(random(len(colors)))] def update(self): self.x += self.vx self.y += self.vy self.r -= .01