Skip to content

Instantly share code, notes, and snippets.

@ramalho
Created October 22, 2017 16:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ramalho/b102eda83341c3bdb5f82bdaee8c8e99 to your computer and use it in GitHub Desktop.
Save ramalho/b102eda83341c3bdb5f82bdaee8c8e99 to your computer and use it in GitHub Desktop.
Bandeira do Brasil
stroke 0
# Start by drawing a green background.
background "#009b3a"
# We'll draw the yellow diamond as two triangles: a top, and a bottom.
color "#fedf00"
move -200
polygon 0, 0, 200, -130, 400, 0 # Top Half
polygon 0, 0, 200, 130, 400, 0 # Bottom Half
# A big blue circle for the middle.
move 200
color "#002776"
circle 80
# We can use an ARC to make the curved white line
move -33, 108
color null # Null means no colour
stroke 14, white
arc 138,-0.2,1.4
# We can't write curved text, so we'll use a green line instead!
stroke 5, setTransparency "#009b3a", 50 # Transparency let's us make the green a little lighter
arc 138,-0.2,1.4
# There's a lot of messy lines over our circle - let's use a MASK to hide them!
stroke 15, "#fedf00"
moveTo 250,250
circle 80
# You just coded the Brazilian Flag!
# ---------------------------------------------------------------------------#
# Extension Task!
# There are 27 stars on the flag of Brazil. Can you add them all?
# ---------------------------------------------------------------------------#
# We can make the task quicker by using a FUNCTION.
# This is like making a machine that can make things based on certain settings.
# Change the X and Y values to move the star around the canvas.
# Change the S value to make the star bigger or smaller.
drawStar = (x,y,s) ->
font s # Set the size of the star
color white
moveTo x,y # Move the star left, right, up, or down
text "⋆"
# Here we'll use our function to create each and every star!
drawStar(280,234,37)
drawStar(194,255,37)
drawStar(269,256,25)
drawStar(192,288,25)
drawStar(208,284,37)
drawStar(220,269,15)
drawStar(226,288,23)
drawStar(221,296,17)
drawStar(236,303,25)
drawStar(308,281,17)
drawStar(295,285,23)
drawStar(299,292,21)
drawStar(291,300,20)
drawStar(282,304,17)
drawStar(274,307,19)
drawStar(274,316,17)
drawStar(274,295,17)
drawStar(265,301,17)
drawStar(259,292,16)
drawStar(250,309,10)
drawStar(250,279,34)
drawStar(250,258,26)
drawStar(238,264,20)
drawStar(258,264,20)
drawStar(244,265,10)
# Phew! That was a lot of stars! Amazing work - you're a Make Art Master.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment