A new version of Kojo is out. Highlights:
New transformations to help with painting
The following new transformations are available to help with painting:
- hue(factor) – increases or decreases hue
- sat(factor) – increases or decreases saturation
- brit(factor) – increases or decreases brightness
- opac(factor) – increases or decreases opacity
Look at the examples under the Samples -> Pictures menu item for a demonstration of how to use this feature (the output of one of the examples is shown below).
Color related functions
There’s a new function to create colors out of HSB values:
ColorHSB(h,s,b)
And there are some new functions to modify colors (each of these functions returns a new (modified) color):
- hueMod(color)
- satMod(color)
- britMod(color)
A protractor tool
There’s a new Protractor tool (accessible via the Turtle Canvas context menu) – to allow angle measurements. The tool can be moved around the canvas and rotated via a mouse-drag and a Shift-mouse-drag respectively.
Easier picture creation
Now, any turtle code can be easily converted to a picture:
def square(n: Int) = Picture { repeat (4) { forward(n) right() } }
The earlier way of doing this was:
def square(n: Int) = pict { t => import t._ repeat (4) { forward(n) right() } }
The new method is especially useful when you want to call a command from your picture making code.
// pre picture code def square(n: Int) { repeat (4) { forward(n) right() } } def psquare(n: Int) = Picture { square(n) }
Vs
// pre-picture code needs to be retrofitted // with the extra t argument def square2(t: Turtle, n: Int) { import t._ repeat (4) { forward(n) right() } } def psquare2(n: Int) = pict { t => square2(t, n) }
A cleanup of the Turtle module
The Turtle module has been cleaned up to get rid of a lot of historical baggage. For the most part, Turtle drawing should behave in the same way as earlier. The following are a couple of differences:
- Multiple Turtles don’t run semi-concurrently any more. If you want multiple turtles to work together, you need to explicitly use the runInBackground command. You can look at the multiple turtle samples to see how this can be done (a couple of these are Samples -> Advanced -> Ferris Wheel and Samples -> Turtle Art -> Rangoli).
- The Undo feature is gone.
As always, the new version is available from the Kojo Download Page.
Enjoy!