Last active
April 28, 2017 17:03
-
-
Save villares/45345a8a68fce2feca0e0a5ce64fa133 to your computer and use it in GitHub Desktop.
OO with bandeirinhas
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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