Thoughtworks interview

from Thoughtworks interviewed me last month. The interview contains a good summary of where Kojo has come from and where it is going.

Posted in News | Leave a comment

New Kojo Release (2.1, 120514)

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

  • Introduction of Dutch support, contributed by Eric Zoerner and Jacco Huysmans.
  • Upgrade to Scala version 2.11.0

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

Enjoy!

Posted in News, Release | Leave a comment

New Kojo Release (2.1, 090414)

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

  • A change in the way that programs are run via the Run button (or the Ctrl+Enter keyboard shortcut). Earlier, the Scala interpreter was used to run programs. Now, the Scala compiler and a custom program launcher is used to run them. This has been done to make the repeated running of larger programs (like games) faster.
    The biggest consequence of this change is that no state (vals, vars, function definitions, etc.) is retained between program runs.
    If you run programs in worksheet mode (via the Run as Worksheet button or the Shift+Enter keyboard shortcut), the scala interpreter is still used under the covers. So, if you want to retain state across runs for certain programs, use the worksheet mode.
    If this change impacts you negatively, please let me know.
  • More accurate arcs via the arc(radius, angle) and turn(angle, turnRadius) turtle commands.
  • Support for radial color gradients and more powerful linear color gradients.
  • Picture effects (based on JH Labs image filters). The currently supported effects are: blur, fade, lights, noise, and weave. There is also a (Java reflection based) effect which allows the use of any of the JH Labs image filters.
  • A new Showcase menu item with samples that demonstrate many of the new features (gradients, effects, etc.). Some of these samples are shown below:

mandelbrot fern spiral inner-eye

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

Enjoy!

Posted in News, Release | Leave a comment

New Kojo Release (2.1, 210214)

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

  • UI widgets in the drawing canvas. Go to the Samples -> Widgets menu to see an example of this.
  • Support for rational numbers.
  • Introduction of Polish support, contributed by Mikołaj Sochacki.
  • Tweaks to rendering in the drawing canvas for smoother forward/turn curves.
  • New commands and functions (randomFrom, randomBoolean, repeatFor, dot, etc).
  • Support for writable images in which you can programatically set pixel values. This enables the efficient drawing of things like the Mandelbrot set.

As you can see, there’s a whole bunch of exciting new stuff in this release. Watch out for samples of this stuff in the coming weeks. In the meantime, there’s a new book in the works — Kojo Programming Quick-Ref, which describes a lot of the new features. You can download this book from the Kojo beta books page.

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

Enjoy!

Posted in News, Release | Leave a comment

New Kojo Release (2.1, 151213)

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

  • A new tool called the Turtle Controller, which can be accessed from the Tools menu. This is meant to help younger children (~5 years) use Kojo effectively.
  • A new perspective with a bigger script editor (for larger canvas based programs), which can be accessed from the Window menu.
  • Additional Vector2D methods – normalize, magnitude, limit, / (division), - (subtraction), dot, distance.
  • Control of the Script Editor and Output Pane font size via the mouse scroll wheel (Ctrl + Scroll)
  • New Picture creation functions – PicShape.image() and PicShape.button().
    • PicShape.image() allows you to load an image file as a Picture. You can then use the Picture composition and transformation functions to lay out images declaritively, arrange them algorithmically, etc.
    • PicShape.button() allows you to add Picture based buttons (that your code can react to) to the canvas. The Turtle Controller tool uses this feature.
  • Upgrade to Scala 2.10.3

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

Enjoy!

Posted in News, Release | Leave a comment

New Kojo Release (2.1, 300813)

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)

    tree-with-circles

    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)
    }

    arc-tri-collisions

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

Posted in News, Release | Leave a comment

New Kojo Release (2.1, 140813), with support for Tracing and #includes

I’m pleased to announce a new release of Kojo. This release includes a couple of big features:

Program Tracing

This feature is based on work done by Sami Jaber during GSOC’13.

Here’s how you use Tracing. Copy the program below into the Script Editor:

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

Now click on the Trace button trace-button in the Script Editor Toolbar.

This will run the program in Trace mode and bring up the Program Trace window:

tracing-1

The new window shows you a trace of all the important command/function Calls and Returns in your program. If you click on a trace element, the line in the script editor which generated that element gets highlighted (see below), and a marker appears in the drawing canvas showing you the contribution of that element to the drawing inside the canvas:

tracing-2

Tracing works well for non-visual programs, too. Try it with this program:

def factorial(n: Int): Int =
    if (n == 0) 1 else n * factorial(n - 1)

factorial(4)

Hopefully, that is enough information to get you started with tracing. I’ll do a more detailed post on this topic later…

#includes – for code reuse

With this feature, you can make scripts refer to other scripts by using #includes. So, for example, you might define a function in a file called script1.kojo:

def sum(n1: Int, n2: Int) = n1 + n2

And then, in another script, you can start using the sum function like this:

// #include script1.kojo
sum(2,3)

This allows you to start writing libraries of useful commands/functions that can be reused across scripts.

Many thanks to Björn Regnell for his contributions to the #include feature and his feedback on the Tracing feature.

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

Enjoy!

Posted in News, Release | 2 Comments