I’m pleased to announce a new release of Kojo. Highlights include:
- Improvements to the PicShape.circle() and PicShape.arc() functions. The earlier versions of these functions were shortcuts for how you would create the corresponding shape within a Picture using the forward and right/left turtle commands. These functions now create a single circular shape under the covers instead of many (360 in the case of a circle) linear shapes. This results in the following improvements:
- Smoother visual appearance (no jaggies).
- Much faster drawing.
Try running the code below to see that in action:
val size = 100 def S = PicShape.circle(100) def stem = scale(0.13, 1) * penColor(noColor) * fillColor(black) -> S clear() setBackground(Color(255, 170, 29)) invisible() def drawing(n: Int): Picture = { if (n == 1) stem else GPics(stem, trans(0, size-5) * brit(0.05) -> GPics( rot(25) * scale(0.72) -> drawing(n-1), rot(-50) * scale(0.55) -> drawing(n-1) ) ) } val pic = trans(0, -100) -> drawing(10) draw(pic)
The new versions of the shapes continue to participate in collision detection. Try the code below to see that in action:
def p = Picture { right(60) repeat(3) { forward(3) right(120) } } def p2 = PicShape.arc(1, 140) clearWithUL(Cm) axesOn() gridOn() invisible() val pic1 = p val pic2 = trans(4, 4) * rotp(-10, 1, 0) * flip -> HPics( p2, p2 ).withGap(1) draw(pic1, pic2) animate { if (pic1.collidesWith(pic2)) { pic1.translate(-0.1, -0.1) } pic1.translate(.025, .025) pic2.translate(-.01, 0) }
- Refinements to the Tracing feature introduced in the previous release.
Note – If you are upgrading from Version 140813-2 of Kojo, and you are on either Windows or Mac, you need to get rid of a file in your Kojo2/lib directory — jdi-win.jar (Windows) or jdi-mac.jar (Mac). You can either do this manually, or by uninstalling the older version of Kojo before you install the new version.
As always, the new version is available from the Kojo Download Page.
Enjoy!