Skip to content

Instantly share code, notes, and snippets.

@villares
Last active April 28, 2017 17:03
Show Gist options
  • Save villares/45345a8a68fce2feca0e0a5ce64fa133 to your computer and use it in GitHub Desktop.
Save villares/45345a8a68fce2feca0e0a5ce64fa133 to your computer and use it in GitHub Desktop.
OO with bandeirinhas
def setup():
""" Code called once by Processing """
size(100, 100)
bandeirinha(50, 50)
def bandeirinha(px, py, flag_size=50):
""" Draws a small flag at px, py, default size 50px """
half_flag = flag_size / 2
with pushMatrix(): # preserve the original coordinate system
translate(px, py) # change the origin
beginShape() # start a shape/polygon
vertex(-half_flag, -half_flag)
vertex(-half_flag, half_flag)
vertex(0, 0)
vertex(half_flag, half_flag)
vertex(half_flag, -half_flag)
endShape(CLOSE) # ends the polygon, closing on 1st vertex
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment