ChaiDraw Screenshot Toy Drawing System That Teaches Programming

ChaiScript is a toy application that lets you draw shapes using the programming language ChaiScript. It's simple enough to use to teach basic programming principles to children and complex enough to practice with functional programming.

License: free

Sound:Play in X:Play in Console:Multiplayer:Network Play:3D Acceleration:Source Available:
noyesnonononoyes
Suggest an update

Comments

For a tool that's supposed to teach functional programming, the code example looks rather imperative. ;->
Re: Functional? posted by lefticus on Aug 26 2009 8:33 PM
Yes, that's true, the example shown is a simple imperative example. ChaiScript supports functional and imperative programming styles with a splash of object oriented.
A more interesting example might be:
use("draw.chai");
context.draw_grid(drawingarea);

def draw_function(context, f, plot, color)
{
  for (var i = -100; i < 100; i += 10)
  {
    color(i, f(i));
    plot(i, f(i));
  }
}

context.draw_function(fun(x) { x * x / 20 }, 
    bind(draw_circle, context, _, _, 15), 
    bind(fun(c, x, y) { c.set_color(min(1, x/30.0), min(1,y/30.0), 0, .85); }, context, _, _) );

Which uses a flair of functional programming to draw a parabola that gradients from green to yellow, passing through black as it reaches the saddle point.

Log in or register to rate this game or post a comment.