Custom Colors explainer

The aim of this puzzle: Draw one box that is colored magenta.
Walkthrough of the solution: Magenta is not a color that the grasshopper concept drawBox() recognizes. However, you can still create magenta by using a Red, Green, Blue (RGB) object inside drawBox(). Red, green and blue can have any value between 0 and 255; adjusting them you can create almost any color you could think of, including magenta. To create magenta you need red and blue to be at their maximum values (255) and green to have no value (0).
Sample code solution:
(Tap below to reveal)

var someCustomColor = {
  red : 255,  
  green : 0,
  blue : 255

JavaScript Concepts: Calling Functions, Identifiers, Variable Declaration, Data Structures (object), Code Block (object)
Grasshopper Concepts: drawBox()

I feel that this topic missed some important information. I didn’t understand how the values were passed into the drawbox routine, so in the following quiz I got it totally wrong. I think that the explanation would have better suited the learning stage, not the quiz answer.


What’s the concept behind this quiz,
Is it an object?
What does those numbers depict?
Why they need to be equal?
Is drawbox a predefined function?

Why this combination gives black?

You actually have very dark red there. Each value, R, G, and B, represent how much of each to mix. 0 is the least, 255 is the most. 0, 0, 0 is black, and 255, 255, 255 is white. 5, 0, 0 is very near 0, 0, 0, and so appears nearly black. The reddest Red is 255, 0 , 0. Magenta has maximum Red plus maximum Blue, and no Green at all, so its RGB code is 255, 0, 255. Hope that helps!


It is not working anyway!!!

I’m doing it right and they are saying set blue from 225 to 225!!!

1 Like

If you look closely, it’s asking you to set the value to two-hundred fifty-five.

This number comes from being 1 less than 256 which is 2 to the 8th power (2⁸). This is the number of ways you can choose 1 and 0 if you choose eight 1’s and 0’s. Since our first combination represents 0, our second combination represents 1, our final representation (the two-hundred fifty-sixth one) represents 255.




Whoops, I screwed that up. I did 225 instead of 255. Sorry about that!


With most programming languages they aren’t very forgiving. Sometimes just stepping away for a bit or just looking at it with a different angle helps you solve the problem. Just with more practice you get better but even the greatest minds can make simple mistakes. Don’t let that discourage you but motivate you to do better. Have fun coding :slight_smile:


In that situation maybe is showing an error, but the color is correct? I mean i wrote as well 5 for green 255 for blue and red, and the color was correct, but generelly of course was that solution not correct.

So… my question is: why? :face_with_monocle::nerd_face:

And one question more :raising_hand_woman:t3:‍♀️
Im trying to understand var, const and let obejects. And the difference between all of them.

So what is an var object in that example? The colors? Which i can change or put more than that one because is the var object?

Probably i mixed all new informations…
Im looking forward for your help :massage_woman:t3:‍♀️
Thank u!!!

This puzzle is looking for a box whose color is exactly: 255 Red, 0 Green, and 255 Blue. Changing any of those values, even by 1, will give you a different color although it may look very similar.

We could create a puzzle, or modify this one to accept a larger range of colors. For example, instead of looking for exactly (255, 0, 255), we could check if the red and blue parts are greater than 200 and the green is less than 50. Many other of the puzzle are more lenient in this way, but we chose to look for a very specific color here.


1 Like

We don’t have any puzzle that talk about const yet, but in Fundamentals II there are lessons about the differences between var and let.

In this puzzle, you wouldn’t see a difference between var, let, or const. They create a variable called someCustomColor that stores an object. The object is all the data between the curly brackets {}. An object is a list of properties. Each property has a Name and Value. In the someCustomColor object, there are 3 properties, named red, green, and blue. And the values of each property are the numbers you entered, either 0 or 255.

It’s common to refer to a variable as being identical to the value its storing. So if we have var x = 10, we can say, "x is a number". Other examples:

let y = 'abc';
"y is a string"

let o = {
  a: 22,
  b: 11

"o is an object with 2 properties: a and b"



Thank u Frankie for your help!

1 Like



Hey there, it looks like you’ve got the number 225 in the blue property. Try changing it to 255.

Hope this helps!

It is 225 can I talk to a real person?!?

Right, change it from 225 to 255.

Me too! I don’t get this and I can’t pass this level.23%20PM