New Kojo Release — 2.9.07

I’m pleased to announce a new release of Kojo. The following are the highlights (for Kojo and the activities around it) since the last announcement:

1. We now also have a web-based version of Kojo. iKojo (as this version is called) is hosted at Lund University, Sweden. Many thanks to Björn Regnell, Peter Möller, and the folks at the Vattenhallen Science Center at Lund University for facilitating this.

iKojo brings several benefits to the Kojo platform:

  • It enables users to easily start experimenting with Kojo without having to download/install anything. When they want to dig deeper and do more serious programming, they can download/install desktop-Kojo.
  • It enables users to easily share (via a web link) the games and simulations that they write in Kojo. The game or simulation can be developed in desktop-Kojo, and then shared via iKojo.
  • It enables the exporting of web-apps from Kojo. These web-apps can run within any internet browser (on personal computers, tablets, and mobile phones).

Here is an example of a simple game (playable via keyboard and joystick) developed in desktop-Kojo (using Scala), tested on iKojo (via Scalajs), and then exported as a web-app. Click on the image below to play (note that full-screen mode does not work on Apple devices):

hunted

You can check out the source code for the game.

2. There’s a new Kojo Intro video out there that introduces the various features of Kojo:

 

3. There is a new Learning Material section on the docs website that provides a reasonably structured learning journey for children across various fun areas of programming.

kojo-learning-modules

4. And finally, a new version (2.9.07) of desktop-Kojo has been released, with the following enhancements since the last release announcement:

  • A Turkish (level-3 with custom enhancements) translation contributed by Bulent Basaran. We are looking forward to seeing children in Turkey benefiting from this. Great job, Bulent!
  • Sprite-sheets and mp3 files can now be loaded off the net.
  • Support for eval.
  • Support for screens.
  • Web-app export feature.
  • Scala has been bumped up to version 2.13.3
  • The bundled Java has been bumped up to version 11.0.7
  • There is now a virtual Joystick control for games (driven by iKojo on mobile).
  • Some sample games have been synced with iKojo.
  • Access to the code exchange is available via https.
  • Support has been added for vertex shapes – for turtles, pictures, and canvas sketches. This includes support for polygons and curves using (r, theta) coordinates – which enables easy drawing of circular patterns like mandalas and yantras.
  • Code completion improvements.
  • New viewTranslate(x, y), viewRotate(a), and viewScale(f) commands.

That’s it for now.

As always, the new version of Kojo 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.9.01

I’m pleased to announce a new release of Kojo. The following are the highlights since the last announcement:

1. Upgrade to Java 11 and Scala 2.13.2

This release includes updates to the core foundational technologies within Kojo:

  • The Java runtime (JVM) has been upgraded from version 8 to version 11 — for access to the latest stable JVM technology. The upgrade to Java 11 also provided an opportunity to trim the size of the JVM that is bundled with Kojo (by removing unused components like JavaFX). This has resulted in a decrease of around 25% in the size of the Kojo installer.
  • Scala has been upgraded to 2.13.2 (from 2.12.10). This provides improvements to the collections framework and overall performance, in addition to other internal improvements.

2. Generative art enhancements

2(a) Neural style transfer using deep learning

Neural style transfer (NST) is a deep-learning technique that lets you apply the style of one image to the content of another image.

Kojo now supports NST via its easy to use picture transformation syntax. Using this syntax, applying one or more styles (from one or more images) to a pattern is as simple as doing:

val pic = effect(style1) * effect(style2) -> pattern
draw(pic)

Here is an example drawing made in Kojo using NST:

neural-style-2

This feature is based on PyTorch. To use NST in Kojo, you need to set up a Python virtual environment with PyTorch, and then do a bit more. So setting this up is a little bit of work for now. But once things are set up, this feature is easy to use (as described above).

2(b) Immediate mode canvas graphics based on a Processing like API

For scenarios (like agent-motion based generative art)  where you need to draw hundreds of thousands of objects on the screen, Kojo now includes an immediate mode API — modelled on the Processing API. To use this API, you need to do the following:

  • Create an instance of a class (called Sketch by convention) that has two methods — setup() and drawLoop().
  • Give this instance to the canvasSketch(sketch) command.
  • After this, your setup() code will be called once and your drawLoop() code will be called at 50 FPS.

Within setup() and drawLoop() you can use the Processing like API.

To make it easy to get going with an immediate mode sketch, Kojo includes a code template for this. Just type in canvasSk in the script editor and press Ctrl+Alt+Space. Then select the canvasSketch template from the code-completion window that pops up. That will give you the following ready to run code:

cleari()
originBottomLeft()
setBackground(white)

class Sketch {
var x = 0
  def setup(surface: CanvasDraw) {
    import surface._
    strokeWeight(4)
    rect(0, cheight/2, 40, 40)
  }

  def drawLoop(surface: CanvasDraw) {
    import surface._
    background(255)
    x += 2
    rect(x, cheight/2, 40, 40)
  }
}

val sketch = new Sketch
canvasSketch(sketch)

Now tweak this as desired. Within setup() and drawLoop(), you can can use code completion on the surface object to see what (Processing like) drawing commands are available to you.

Here is a larger example that uses this API :

canvas-sketch7

3. Breakpoint command

Kojo now includes a breakpoint command which makes it easy to debug/understand programs. You can put breakpoint(someData) on any line in a program, and when the program runs it will stop at that line and show you the value of someData. someData can be a formatted string, so you can put in whatever descriptive string you want to see — to help you to debug/understand the program. All the provided data across successive breakpoint calls is also printed in the output pane, so the output there gives you a nice view of how the data of interest in your program is evolving as the program runs.

This feature is especially useful in debugging/understanding two kinds of scenarios:

  • Graphical drawing — for example when you draw a grid, you can put a breakpoint in your grid-cell drawing code, and then see the grid being drawn cell by cell,  along with the desired data for each cell.
  • Algorithms — you can put a breakpoint at the input/output to a function to see, step by step, exactly what comes in to, and goes out of, the function. You can see similar information with tracing, but with a breakpoint you can stop a program at a point of interest, look at the data values there, and then proceed step by step.

Here are screenshots of both of the above scenarios:

grid
quicksort

4. New tutorials and book

New tutorials and a beginner-level book in lesson-plan format are now available on the Tutorials page on the Kojo Docs website. Here are a few examples (ranging from the simple to the not so simple) of the kinds of drawings you can make with the help of the tutorials:

5. Other enhancements

5(a) Support for HSB colors in the ColorMaker

The ColorMaker now supports the HSB/HSV color model, in addition to the HSL and RGB models. This is fully integrated with IPM (Interactive Program Manipulation), so you can Ctrl+Click on any HSB color  in  your code to bring up the color-tweaker window:

color-ipm

For quick reference, the following are some of the ColorMaker functions for creating colors (here shown creating a green or a half-transparent green color):

// cm is an abbreviation for ColorMaker
cm.rgb(0, 255, 0)
cm.rgba(0, 255, 0, 127)
cm.hsl(120, 1.0, 0.5)
cm.hsla(120, 1.0, 0.5, 0.5)
cm.hsl(120, 1.0, 1.0)
cm.hsla(120, 1.0, 1.0, 0.5)
cm.hex(0x00ff00)
cm.hex(0x7f00ff00)

You can also create gradients and textures via the following ColorMaker functions:

// use code completion to fill out the args
cm.linearGradient
cm.linearMultipleGradient
cm.radialGradient
cm.radialMultipleGradient
cm.texture

5(b) timeit command

A new timeit command makes it easy to time your code. For example:

// type KList = ArrayBuffer[Int]
val n = 1500000
val L = util.Random.shuffle(KList.range(0, n))

clearOutput()
timeit {
  quickSort(L)
}
println(L.slice(n - 5, n))

The above prints out the following in the output pane:

Timed code took 3.039 seconds
ArrayBuffer(1499995, 1499996, 1499997, 1499998, 1499999)

That’s it for now.

As always, the new version of Kojo 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.7.10

I’m pleased to announce a new release of Kojo. The following are the highlights (for Kojo and the activities around it) since the last announcement:

1. New docs website

Kojo has a new documentation website – with reference material, concepts, tutorials, and how-to guides on various aspects of programming in Kojo.

kojodoc-website

2. Generative Art Enhancements in Kojo

We are starting to get serious about generative art  in Kojo, and this release ties together a few threads to make Kojo’s gen-art support more polished. Various ways of doing generative (and computational) art in Kojo are documented at these links:

The docs website also has a Scala Quickref to help kids get going with the next level of Scala programming (at about the level of regular Python programming) as they move on from turtle graphics to pictures based gen-art.

To whet your gen-art appetite, screenshots of some recent Kojo artwork are shown below (a few of these drawings are described in the tutorials above):

3. Creative coding by kids for physical products

Kids in Dehradun (the home base for Kojo) have been busy using Kojo for artwork and physical product design. Here are a couple of photos of kids with their first Kojo designed t-shirts:

We are hoping that this work will pick up steam this year, providing lots of great learning opportunities to the kids that we work with.

As always, the new version of Kojo 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.7.06

I’m pleased to announce a new release of Kojo. The following are the highlights of the  release:

1.  Support for Tile based games

Kojo now supports multi-layer game environments created using the Tiled level editor. You can load Tiled map/level files inside Kojo, and then use Kojo’s tile-world API to start building games. An example side-scrolling platformer is included with this release, and can be run from the Showcase menu. Here’s a quick video snippet of the game:

 

2. Miscellaneous improvements

  • Kojo now starts up with a bigger script editor in the light-theme mode (just like it already did in dark-theme mode).
  • Desktop icons on Windows should now look better (and should not appear jagged / pixelated).

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.7.05

I’m pleased to announce a new release of Kojo. The following are the highlights of changes since the previous release announcement:

1.  Initial support for Data Science and Machine Learning

The core features of this support include:

  • A data exploration pane (which can be opened/closed at the bottom of the Script Editor) where you can type in snippets of code, run them, and see the results in the output pane. The data exploration pane supports code-completion – for easy discoverability of methods and fields on objects of interest.
  • An add-on pack, which can be downloaded from the Kojo-AI project and installed within Kojo. This pack currently includes support for data-frames, charting, neural networks, and graph searching.

Here are some screenshots showing the above in action:

joinsLoading and joining data-frames

group-byDoing a Group-by

selectionDoing a selection

histogramDoing a projection and then drawing a histogram

barchartDoing a projection and then drawing a bar-chart

nonlinear-regressionDoing non-linear regression using Tensorflow and Keras-like layers

astar-searchA-star search

This is very much work in progress, but also an exciting area of potential growth, with nice synergies with the Kojo-gaming and Kojo-arduino projects. 

2. Gaming Enhancements

Some initial work has been done to support the use-case of developing games within Kojo-Desktop and publishing them on KojoJS. Here are some sample games (running in the browser):

This is shaping up to be the next area of focus for Kojo based on feedback from users.
Note that KojoJS (powering the links above) is still in ‘experimental’ mode and running on a not very powerful server.

bugs gameBugs game running in Kojo-Desktop

3. Miscellaneous improvements

  • Editor speedup for larger scripts
  • Improvements with Find/Replace.
  • New Samples in the area of Generative Art and Math. Other Sample tweaks.
  • More robust script interruption under stress (like, for example, while changing drawing colors via the interactive program manipulator)
  • Scala upgrade to 2.12.8

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.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!

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