OK, my first baby steps in Kojo… Purely imperative for now.
val ROUND = 360
val SIDE_NB = 5
val ANGLE = ROUND / SIDE_NB
clear
jumpTo(0, 300)
write("Pentagon")
jumpTo(0, 0)
setAnimationDelay(42)
setPenColor(blue)
setPenThickness(11)
for (n <- -2 until 3)
{
setFillColor(color(0x80 - n * 40, 0xFF, 0x80 + n * 60))
setHeading((2 + n) * ANGLE)
repeat (SIDE_NB)
{
forward(150)
turn(-ANGLE)
}
}
That's mostly an exploration of the API.
I saw no means to specify a translucent fill color. I tried with a 32bit color like 0x8080FF80 but it is still opaque.
There is something that puzzles me: if I replace the for loop with:
var n = 0
repeat (5)
I get an error:
error: missing arguments for method repeat in object Builtins;
follow this method with `_' if you want to treat it as a partially applied function
repeat (5)
^
Not sure if it is to be expected with Scala (ie. if I didn't fully understood the syntax) or if there is a bug in the interpreter.
BTW, if I want to print a number in hexa style, what is the idiom in Scala?