How to draw smooth quad mesh with Processing?

I am trying to draw a mesh composed of several squares using splines in Processing, so far I have tried it

mesh = (
    [100, 100],[150, 100],[200, 100],[250, 100],[300, 100],[350, 100],[400, 100],[450, 100],[500, 100],
    [100, 150],[150, 150],[200, 150],[250, 150],[300, 150],[350, 150],[400, 150],[450, 150],[500, 150],
    [100, 200],[150, 200],[200, 200],[250, 200],[300, 200],[350, 200],[400, 200],[450, 200],[500, 200],
    [100, 250],[150, 250],[200, 250],[250, 250],[300, 250],[350, 250],[400, 250],[450, 250],[500, 250],
    [100, 300],[150, 300],[200, 300],[250, 300],[300, 300],[350, 300],[400, 300],[450, 300],[500, 300],
    [100, 350],[150, 350],[200, 350],[250, 350],[300, 350],[350, 350],[400, 350],[450, 350],[500, 350],
)

def draw():
    clear()
    background(255)
    stroke(0)
    strokeWeight(1.2)
    beginShape()
    for p in mesh:
        curveVertex(*p)
    endShape()
    stroke(*POINT_COLOR)
    strokeWeight(POINT_RADIUS)
    for p in mesh:
        point(*p)

where mesh is the matrix of all vertices. I want to draw all 4 edges of all squares, how can I do it using splines? Later I will allow users to drag vertices to change mesh shape and I want that shape to be smooth. The final result would be something like below but on 2D plane:

enter image description here



Read more here: https://stackoverflow.com/questions/67377271/how-to-draw-smooth-quad-mesh-with-processing

Content Attribution

This content was originally published by hldev at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: