Blue Filter Helper explainer

Aim of the puzzle: To only draw the box rgbObject creates if it’s blue value is greater than 200.
Walk through of solution: The first thing you need to do to solve this puzzle is create an if statement, to allow you to control whether to draw a box or not. Inside the test of the if statement (i.e. the parentheses of the if statement) you need to access the blue key’s value within the object rgbObject. You can access an object’s key’s value using a dot, so for example print(rgbObject.red) will print out the number value that the red key inside rgbObject is holding. In this case you want to access the blue value and check if it’s greater than 200, which you can do via rgbObject.blue > 200. The final step is to add a drawBox() function inside the block {} of the if statement, so that a box is only drawn if the statement rgbObject.blue > 200 is true.
Sample code solution:
(Tap below to reveal)

if (rgbObject.blue > 200) {
    drawBox(rgbObject);
}

Javascript Concepts: Comparison operators, If Statement, Block Statements, Object Expressions, Member Expressions
Grasshopper Concepts: drawBox()

1 Like