Array of extruded shapes is too slow

"""
 Discourse.Processing.org/t/array-of-extruded-shapes-is-too-slow/3414/10
 Mod: GoToLoop (2018-Sep-10)
"""

add_library('extruder')
add_library('peasycam')

CIRCLES = 20
STEP_X, STEP_Y = 10, 20

RANGE_X = tuple(range(0, CIRCLES*STEP_X, STEP_X))
RANGE_Y = tuple(range(0, CIRCLES*STEP_Y, STEP_Y))

def setup():
    size(600, 600, P3D)
    smooth(8)

    fill(0xffFFFF00)
    stroke(0)
    strokeWeight(1.0)

    cam = PeasyCam(this, width)
    cam.setMinimumDistance(100)
    cam.setMaximumDistance(width<<2)
    cam.lookAt(width>>2, height>>2, 0, 500)

    global cylinder

    circle = createShape(ELLIPSE, 10, 10, 20, 20)
    cylinder = extruder(this).extrude(circle, 100, 'box')[0]


def draw():
    background(-1)

    for y in RANGE_Y:
        for x in RANGE_X: shape(cylinder, x, y)
2 Likes