The aim of this puzzle: Create the Gabonese flag.
Walkthrough of the solution: The Gabonese flag has three horizontal stripes; the top stripe is green, the middle stripe is yellow and the bottom stripe is blue. To re-create the flag there needs to be 9 boxes — 3 boxes tall and 3 boxes wide.
drawBox(green) will draw one green box (updating the color will change the color of the box).
newLine() is used to make boxes appear below other boxes.
Sample code solution:
(Tap below to reveal)
Grasshopper Concepts: drawBox(), newLine()
Whenever you press the green play button, all of the code inside of the “Your Code” section gets run, line by line from top to bottom. You need to create a list of commands that create a specific pattern when you read it from the first line to the last. In this puzzle, that pattern is the Gabonese Flag with has three horizontal stripes (green, yellow, and blue). You can see in the “Example Solution” section of the app that each stripe is three boxes wide.
To create a green stripe, you would need to draw three green boxes in a row which can be done by writing:
To move the grasshopper down to the next row for your next stripe, you use
newLine(). Then you can use the same pattern to create a different colored stripe, like yellow.
After you have a green and yellow stripe, you can move the grasshopper to a
newLine() again and create the last row of three blue boxes.
Hope this is helpful. If there are any parts that are unclear, feel free to ask me about them!
So the drawbox meathead draws a box. To tell the script (drawbox) you say the color that the code wants you to do.
How does the drawBox() function know to draw horizontal long box as with Gabonese flag or a small box as with French Flag
All of the boxes are the same size. By calling the function 3 times with the same color, the 3 boxes look like a stripe.
are you from welch Newnan GA
no sorry l’am from africa
chrome 78 beta - numerous errors prevent proper function for buttons. unable to complete lesson due to errors… plz fix in meantime i have to use older browser versions or FFox.
Hey there, those warnings are unrelated. They are warning that a future version of Chrome is going to make some slight changes to how cookies work on websites.
Can you describe the issue you are having?
– resolved – was my mistake
Duh with cheese and stuff, me too
Hi, beginning to understand at the very early stages of coding could you enlighten me on some other aspects that may be needed to start to be able to build my own and thank you so much you’re very self-explanatory and it’s clear and concise appreciate that Dixie Nunley/ Longoria
I tried to use drawBox() function in vs code and other online compilers but it is not working. So, how can I use this function?
drawBox() is a custom function that we created just for use within Grasshopper. You can read more about Grasshopper’s custom functions here.
Hope this helps!
hey there i am new and i want to meet everyone but sometimes i do some work here from my lyberary teacher
hey how do you code the 2 flag.
you just follow instructions and you’ll be fine.
Hi, i am new to coding. is this the right place for me to learn coding?