New Kojo Release — 2.7.03

I’m pleased to announce a new release of Kojo. Highlights of changes since v2.4.14 include:

1. The introduction of a dark theme

Kojo now includes a modern dark theme. The colors in this theme are easier on the eyes, especially for those who sit in front of Kojo for longer periods of time.

10-tree-dark1

Here are some screenshots, showing both the new dark theme and the original (but slightly refined) light theme.

2. Windows gaming improvement

Animations on Windows are now able to run at 45-50 frames per second (fps), up from 30-33 fps in earlier versions.

To enable this, Kojo increases the resolution of the Windows system timer whenver an animation starts (and resets it to its original value when the animation ends).

3. Picture enhancements for generative art

In Kojo, Pictures are the building blocks of compositional graphics and generative art (and also gaming, but this section is not about that). The following Picture methods have been added in this release — from the perspective of supporting performant and rich generative art:

  • Picture.line(x, y) (to augment Picture.hline and Picture.vline)
  • Picture.ellipse(rx, ry)
  • Picture.fromPath { path => Unit }

The following method has been ‘optimized’ to perform well with a large number of instances

  • Picture.rectangle(w, h)

In case you are wondering about the missing second coordinate for the line/rectangle or the missing center coordinate for the ellipse, that’s because Pictures are anchored around the origin of their parent Picture’s coordinate system, and can be translated, rotated, and scaled as desired after they are created.

All of this will be explained in an upcoming e-book on generative art for secondary school children that will (as currently planned, but subject to enhancement) walk through the creation of these paintings  using Pictures. Here are a couple of Kojo screenshots to whet your appetite:

11-mondrian-dark1

13-mountains-dark1

4. Embedded mode for devices like the Raspberry Pi.

Kojo now has a couple of modes – the original Desktop mode, and a new Embedded mode. The Embedded mode delays the loading of certain Kojo components till (and if) they are actually needed in a Kojo session. This, for example, brings down the Kojo startup time on a plugged-in Raspberry Pi 3b+ from ~50 seconds to ~20 seconds.

Also, in Embedded mode, Kojo does Fast syntax coloring within the script editor (based on the dafault Scala syntax coloring in RSyntaxTextArea). In Desktop mode, Kojo does Rich syntax coloring, which provides better support for things like interpolated strings and xml literals.

You can manually switch between Embedded / Desktop mode and Fast / Rich coloring using the script editor context menu (via a right-click on the editor).

5. Improvements to the Kojo-Arduino bridge

The Kojo-Arduino bridge has seen steady enhancements (the most notable recent one being the addition of support for ultra-sonic sensors for distance sensing). It is now pretty easy to program robots like this one using Kojo (we’ll put up a better video after we get our video-making act together).

Here’s a screenshot of the computer screen from the above video (with Kojo running on a Raspberry Pi 3b+):

rpi-robot

6. Protection against the very rare freeze

Certain advanced Kojo scripts (like an earlier version of the beginner challenges) could freeze Kojo if the stars were aligned just wrong. Kojo now detects such potential freezes and stops the offending script.

7. Scala upgrade to 2.12.6

Last but not least, the Scala version in Kojo has moved from 2.11.11 to 2.12.6. This has been on the todo-list for quite some time, and was held back by the dependence of Kojo on the original Scala actor framework (which is not supported on Scala 2.12.x). For this release, Kojo’s actor dependency has been migrated to akka actors.

I’d like to put in a special word of thanks to Lund University for taking on the responsibility of building, signing, and hosting the Mac version of Kojo. Thanks Björn, Marcus, and Peter (for this, and for all your earlier contributions to Kojo).

That’s it for this release. As always, the new version is available from the Kojo Download Page. If you run into any difficulties, let us know.

Enjoy!

Advertisements
Posted in News, Release | Leave a comment

New Kojo Release — 2.4.14

I’m pleased to announce a new release of Kojo. Highlights include:

0. New Installers

The primary Kojo installers for Linux, Windows, and Mac now come with Java 8 bundled inside, making it easier to get going with Kojo without worrying about installing a compatible version of Java before installing Kojo. The new Kojo installers are built using Install4j.

1. Richer color handling

You can now mix rich colors in Kojo using the ColorMaker:

ColorMaker.hsla(hue, saturation, lightness, opacity)
ColorMaker.rgba(red, green, blue, opacity)

I’m calling these colors rich because they can be modified in a controlled fasion in many different ways — by:

  • Rotating their hues.
  • Changing their saturation, lightness, or opacity.
  • Increasing, or decreasing their saturation, lightness, or opacity by absolute or relative amounts.

Here is an example that increments the hue of a color by 20 degrees in a loop that runs for 18 repitions, thus covering the whole range of hues from 0 to 360 degrees:

clear()
setSpeed(fast)
var clr = ColorMaker.hsla(0, 1.00, 0.5, 0.36)
setPenColor(black)
repeat(18) {
  setFillColor(clr)
  repeat(5) {
    forward(100)
    right(72)
  }
  right(20)
  clr = clr.spin(20)
}

colored-pentagon-kojowindow

The full list of color manipulation methods is available here.

There are also 147 predefined colors, which you can easily access via code completion — by typing in ColorMaker. and then pressing Ctrl-Space or Ctrl+Alt+Space:

predefined-colors

Richer colors in Kojo are based on the Doodle Color class.

2. Arduino fixes

This release provides a fix for Kojo’s Arduino support which allows Kojo to work with the latest version of the Arduino IDE. Instructions for programming Arduino boards with Kojo can be found via the ‘Tools -> Arduino Programming’ menu item. Also, the latest code, instructions, and samples for working with Arduino can be found in the kojo-arduino repository.

Here is an example Arduino program that controls an LED (at pin 12) based on inputs from a light sensor (at analog pin 0):

// #include ~/kojo-includes/ka-bridge.kojo

def setup() {
  pinMode(12, OUTPUT)
}

def loop() {
  val light = analogRead(0)
  println(light)
  if (light < 170) {
    digitalWrite(12, HIGH)
  }
  else {
    digitalWrite(12, LOW)
  }
  // delay(100)
}

3. Bundled scalatest for out of the box testing

Scalatest is now bundled with Kojo. This allows for easy testing of functions written within Kojo:

scalatest

Tests that pass show up in green in the output pane. Failing tests show up in red, and report the exact nature of the problem:

scalatest-with-failure

4. Picture enhancements

This includes various syntactic enhancements to make working with pictures easier:

  • You can create picture based shapes (rectangles, circles, text, etc) using the Picture object:
val r = Picture.rectangle(40, 60)
val t = Picture.text("Hello", 20)

Earlier, this was supported (and still is) by the PicShape object.

  • The Picture translate and offset methods can now take vector arguments in addition to (x, y) arguments.
  • The draw method now works better with a sequence of pictures (specifically Lists and Vectors), without requiring unpacking via ‘_ : *’.

5. Gaming Enhancements

The following commands have been added:

  • showFps(color, fontSize) — show frames per second during the game on the top-left of the canvas.
  • showGameTime(seconds, endMessage, color, fontSize) – shows the seconds since the start of the game on the bottom-left of the canvas using the given color and fontSize. If the specified number of seconds have elapsed since the start of the game, the game is stopped and the specified messgage is shown in the center of the canvas.
  • drawCenteredMessage(message, color, size): draws the specified message with the given color and size in the center of the canvas.

game-fps-time2

6. Angles playground

An angles playground is now available for young children to experiment with the angles that they use to turn the turtle. The playground can be launched via the ‘Samples -> Math Learning Modules -> Playing with Angles’ menu item:

angles-playground

7. Support for step animations (for younger children)

There is a new command — clearStepDrawing() — to enable children to make fun step animations as a first step along the path of animating their drawings. Here’s an example that draws a growing, rotating square:

def square(n: Int) {
  repeat(4) {
    forward(n)
    right(90)
  }
}

clear()
repeatFor(10 to 100 by 5) { n =>
  clearStepDrawing()
  setSpeed(superFast)
  setPenColor(ColorMaker.darkGreen)
  setFillColor(ColorMaker.darkKhaki)
  right(n * 3 - 30)
  square(n)
  pause(0.5)
}

That’s it for this release. As always, the new version is available from the Kojo Download Page. If you run into any difficulties, let us know.

Enjoy!

 

Posted in News, Release | Leave a comment

New Kojo Release — 2.4.12

I’m pleased to announce a new release of Kojo. Highlights include:

  • Croatian support, contributed by Luka Volarić.
  • Further improvements to the support for high DPI displays. This should work better out of the box. But you now also have the option of tweaking your font sizes by modifying the kojo.properties file located at ~/.kojo/lite. Here are the first few lines of the file:
# Uncomment/tweak options as desired:
# Increase Kojo font size
# font.increase=2
# Or decrease Kojo font size
# font.increase=-4
  • A new drawing API (the Shapes API), inspired by Doodle.  Here’s an example:
Shape.clear()
def r(w: Int, h: Int) = Shape.rectangle(w, h) .outlined(black)
def sq(l: Int) = r(l, l)
def vgap(l: Int) = Shape.gap(0, l)
def hgap(l: Int) = Shape.gap(l, 0)

val eyes = sq(50) beside hgap(100) beside sq(50) filled(lightGray)
val nose = r(30, 100) .filled(orange)
val mouth = r(100, 20) .filled(red)

val face = eyes above
 vgap(10) above
 nose above
 vgap(30) above
 mouth on
 sq(350)

Shape.draw(face)

shapes-simple-example

As always, the new version is available from the Kojo Download Page.

Enjoy!

Posted in News, Release | Leave a comment

New Kojo Release — 2.4.09

I’m pleased to announce a new release of Kojo. Highlights include:

  • Improved support for high DPI displays.
  • Games for young kids contributed by Anusha Pant:
    • Counting game (via use of multiplication and addition).
    • Making Fractions.
    • Identifying Fractions.
  • Localization improvements contributed by Christoph Knabe:
    • More coverage deeper inside the UI.
    • Sample localization.

As always, the new version is available from the Kojo Download Page.

Enjoy!

Posted in News, Release | Leave a comment

New Kojo Release — 2.4.08

I’m pleased to announce a new release of Kojo. Highlights include:

  • Italian Level 1 (UI) and Level 2 (programming) support — contributed by Massimo Maria Ghisalberti.

As always, the new version is available from the Kojo Download Page.

Enjoy!

Posted in Uncategorized | Leave a comment

New Kojo Release — 2.4.07

I’m pleased to announce a new release of Kojo. Highlights include:

  • Russian (Level 1 and Level 2) support contributed by Alexey Loginov.
    • A simplified method for doing Level 2 translations, which was developed while doing the Russian translation. This is described on the Kojo Localization page.
  • Games for 7-9 year olds to practice addition and multiplication. These are available under Samples -> Math Learning Modules.

As always, the new version is available from the Kojo Download Page.

Enjoy!

Posted in News, Release | Leave a comment

New Kojo Release — 2.4.06

I’m pleased to announce a new release of Kojo. Highlights include:

  • Enhancements for young (~7 year old) learners:
    1. Beginner Challenges to get kids going with programming. These are available via the Tools -> Beginner Challenges menu item.
    2. Refinements to the Instruction Palette tool to make it easier for kids to write substantial programs with minimal typing. This is available via Tools -> Instruction Palette.
  • Enhancements to the Linear Equations story (available via Samples -> Math Learning Modules -> Solving Linear Equations). Kids can now type in an equation and then click on an Explain button to see a step-by-step solution of the equation.
  • Scala upgrade to version 2.11.6
  • And the big one for this release — gaming enhancements (you can see these in action in the sample games mentioned below):
    1. Support for pictures bouncing off pictures:
      There’s a new function – bouncePicVectorOffPic(pic: Picture, velocity: Vector2D, obstacle: Picture): Vector2D
      You give this function a picture, its velocity, and an obstacle, and it figures out for you the picture’s new velocity after it bounces off the obstacle.
    2. Support for collision polygons for image pictures:
      These allow you to create a game character using an image, and then specify a collision polygon for the image to enable realistic and efficient collision detection for that character.
    3. Support for batches of pictures for more realistic animation (via easily controlled cycling through the pictures in a batch).
    4. Support for game timers.
    5. Support for updatable text pictures (for easy game scoring).
    6. Sample games based on the above enhancements. Three new games are included:
      Car Ride
      car-ride
      Collidium
      collidium
      Flappy Ball
      flappy-ball

As always, the new version is available from the Kojo Download Page.

Enjoy!

Posted in News, Release | Leave a comment