Page 1 of 2

2D graphics/turtle lib suitable for kids?

Posted: Sat Jan 01, 2011 11:30 pm
by yena
My daughter found Land of Lisp on my shelf and wants to learn Common Lisp. I approve of course, but for a 10-year old child I think the examples in the book are a bit too abstract. I'd like to start simple interactive graphics (create stuff from the REPL - instant satisfaction), but I have no luck finding a simple 2D graphics lib for this, preferably with turtle graphics, and perhaps other simple 2D functions (lines, basic shapes, fill with colors etc.). Is there such a package which is small and easy enough to be useful for small children just starting out? Any advice appreciated.

Re: 2D graphics/turtle lib suitable for kids?

Posted: Sun Jan 02, 2011 2:08 am
by Duke
yena wrote:My daughter found Land of Lisp on my shelf and wants to learn Common Lisp. I approve of course, but for a 10-year old child I think the examples in the book are a bit too abstract. I'd like to start simple interactive graphics (create stuff from the REPL - instant satisfaction), but I have no luck finding a simple 2D graphics lib for this, preferably with turtle graphics, and perhaps other simple 2D functions (lines, basic shapes, fill with colors etc.). Is there such a package which is small and easy enough to be useful for small children just starting out? Any advice appreciated.
If I were you, I'd just use lispbuilder-sdl and make whatever primitives I need on top of it. Lispbuilder handles window creation, framerate, and the event pump pretty cleanly. It includes draw-pixel, draw-line, as well as draw functions for filled and unfilled rectangles, polygons, and circles. You'd have to define your own sprite type and... google image search a turtle to use to that end, I guess. ;)

Re: 2D graphics/turtle lib suitable for kids?

Posted: Sun Jan 02, 2011 8:35 am
by TheGZeus
Duke wrote: google image search a turtle to use to that end, I guess. ;)
BAH! Just use a triangle!
It was good enough for when I was learning how to work Apple Logo on my //c with the tiny phosphorescent green-screen ;)

Re: 2D graphics/turtle lib suitable for kids?

Posted: Sun Jan 02, 2011 12:02 pm
by Warren Wilkinson
I think Duke's idea is a good one (if you have the time). I discovered programming through Basic, because I could put it into mode 13h and draw pixels. I think pixel plotting is probably an easier starting point than rotation, recursion and line drawing.

Were it me, I'd probably use SDL to create a 800x600 window, and then create a 'pixel' routine to draw 4x4 square (in one of 5 colors: RED, BLUE GREEN, WHITE, BLACK) big and visible. I'd expect this to be about 100 loc, max.

With pixel drawing routines, she can probably figure out horz-line routines and vert-line routines. Then progress to using those to draw big boxes, hollow boxes, a trail of boxes, a moving box, etc. In time you might relax limitations --- draw 1 pixel rather than 4, use RGB colors, manually control double buffering, etc.

Just an idea, if you keep your beginner library short (less than 100 loc) than she is never far removed from the real language itself.

Re: 2D graphics/turtle lib suitable for kids?

Posted: Sun Jan 02, 2011 4:37 pm
by gugamilare
Teaching Common Lisp to a 10 years old kid? Man, you are my hero :P

Seriously, if you eventually manage to do it, I would love if you could explain how you did it. Of course, please don't feel obligated to it, just a relative small post telling your experience will be enough for me ;)

Re: 2D graphics/turtle lib suitable for kids?

Posted: Mon Jan 03, 2011 4:37 pm
by TheGZeus
Warren Wilkinson wrote:I think Duke's idea is a good one (if you have the time). I discovered programming through Basic, because I could put it into mode 13h and draw pixels. I think pixel plotting is probably an easier starting point than rotation, recursion and line drawing.

Were it me, I'd probably use SDL to create a 800x600 window, and then create a 'pixel' routine to draw 4x4 square (in one of 5 colors: RED, BLUE GREEN, WHITE, BLACK) big and visible. I'd expect this to be about 100 loc, max.

With pixel drawing routines, she can probably figure out horz-line routines and vert-line routines. Then progress to using those to draw big boxes, hollow boxes, a trail of boxes, a moving box, etc. In time you might relax limitations --- draw 1 pixel rather than 4, use RGB colors, manually control double buffering, etc.

Just an idea, if you keep your beginner library short (less than 100 loc) than she is never far removed from the real language itself.
Different strokes for different folks, but I would have found that tedious and painful.
LOGO is beautiful, because once you write a few routines you can use those to draw stick figures and other simple objects, and if you have something more complete at your disposal (like SDL gives) you can grow from there.
Advocating a programming style inspired by BASIC in a CL forum is also a bit o_O to me...

Re: 2D graphics/turtle lib suitable for kids?

Posted: Tue Jan 04, 2011 9:43 am
by nuntius
For an out-of-the-box solution, give Scratch a try.

Tk's canvas is not far from what you describe. Simple, cross-platform, but a bit dated in capabilities. Easily accessible through LTK.

The new HTML canvas is much better. I people are using it from CL; Kenny Tilton or Tim Daly might be able to point you towards CL bindings.

There's also the Qt canvas. A bit heavier API. Accessible via CommonQt, or on ECL via EQL.

Re: 2D graphics/turtle lib suitable for kids?

Posted: Tue Jan 04, 2011 3:12 pm
by yena
Thanks all for the replies so far. I'm a bit short of time and was hoping to find something ready to use, but I suppose that putting together a simple turtle lib myself shouldn't be too hard. I'll have a look at the sdl and tk options. Re: Lisp for a child - I don't really think that is too far-fetched, strange, or harder than any other approach. Her mind is still open to non-C syntax ;) We actually tried Ruby but it was more confusing to her - too many ways to get syntax errors.

Re: 2D graphics/turtle lib suitable for kids?

Posted: Wed Jan 05, 2011 12:24 pm
by Warren Wilkinson
TheGZeus wrote:Different strokes for different folks, but I would have found that tedious and painful.
LOGO is beautiful, because once you write a few routines you can use those to draw stick figures and other simple objects, and if you have something more complete at your disposal (like SDL gives) you can grow from there.
Advocating a programming style inspired by BASIC in a CL forum is also a bit o_O to me...
I've never used logo, so I can't judge. I just feel that teaching cartesian coordinates would be easier than trigonometry, and since all graphical displays are based on pixels, also more useful long term. I'm also guessing that a child might be more interested in gradients and colorful patterns than they would be in triangles and recursion, this is easier with pixel plotting.

Its simpler too -- there is no pen, if you do it right there is just a continuous block of memory. Line drawing calls pixel drawing. Box drawing calls line drawing. Its perfectly functional. =)

Re: 2D graphics/turtle lib suitable for kids?

Posted: Thu Jan 06, 2011 8:50 am
by TheGZeus
Warren Wilkinson wrote:
TheGZeus wrote:Different strokes for different folks, but I would have found that tedious and painful.
LOGO is beautiful, because once you write a few routines you can use those to draw stick figures and other simple objects, and if you have something more complete at your disposal (like SDL gives) you can grow from there.
Advocating a programming style inspired by BASIC in a CL forum is also a bit o_O to me...
I've never used logo, so I can't judge. I just feel that teaching cartesian coordinates would be easier than trigonometry, and since all graphical displays are based on pixels, also more useful long term. I'm also guessing that a child might be more interested in gradients and colorful patterns than they would be in triangles and recursion, this is easier with pixel plotting.

Its simpler too -- there is no pen, if you do it right there is just a continuous block of memory. Line drawing calls pixel drawing. Box drawing calls line drawing. Its perfectly functional. =)
You're not teaching trigonometry, but basic geometry. You're still working from coordinates, just abstract ones. fd 1 (forward one, in a hypothetical dialect) could be one pixel (it was in Apple Logo) but it could also be an arbitrary distance, with 1.235 as a possibility, as well.

Advocating direct pixel manipulation seems... archaic, and non-portable to higher/lower resolutions.
SVG is much more flexible than (insert bitmapped format).
NeWS was much more flexible than X.

Artists don't draw on graphing paper, yo. ;)