I would use visualvm to find the bottleneck. Otherwise you can do random attempts at optimizing, but you may or may not find the bottleneck.
Random ideas:
- Check how many vertices each brick has. Maybe they are too detailed.
- Does the computer have good CPU and GPU?
- Do you need
stroke()in the bricks? That involves more work than justfill() - Calling
color()each time is not necessary if the color doesn’t change (for instance you could storecolor(255)in a variable called white. - I believe calling
.setStroke()and.setFill()iterates over each vertex and changes its properties. Using a shader to affect rendering might be faster (if the bottleneck is CPU bound).