2D graphics/turtle lib suitable for kids?

Discussion of Common Lisp
yena
Posts: 12
Joined: Sat Jun 28, 2008 2:33 am

2D graphics/turtle lib suitable for kids?

Post by yena » Sat Jan 01, 2011 11:30 pm

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.

Duke
Posts: 38
Joined: Sat Oct 17, 2009 10:40 pm
Contact:

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

Post by Duke » Sun Jan 02, 2011 2:08 am

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. ;)
"If you want to improve, be content to be thought foolish and stupid." -Epictetus

TheGZeus
Posts: 79
Joined: Mon Jun 30, 2008 10:46 am

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

Post by TheGZeus » Sun Jan 02, 2011 8:35 am

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

Warren Wilkinson
Posts: 117
Joined: Tue Aug 10, 2010 11:24 pm
Location: Calgary, Alberta
Contact:

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

Post by Warren Wilkinson » Sun Jan 02, 2011 12:02 pm

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.
Need an online wiki database? My Lisp startup http://www.formlis.com combines a wiki with forms and reports.

gugamilare
Posts: 406
Joined: Sat Mar 07, 2009 6:17 pm
Location: Brazil
Contact:

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

Post by gugamilare » Sun Jan 02, 2011 4:37 pm

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

TheGZeus
Posts: 79
Joined: Mon Jun 30, 2008 10:46 am

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

Post by TheGZeus » Mon Jan 03, 2011 4:37 pm

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

nuntius
Posts: 538
Joined: Sat Aug 09, 2008 10:44 am
Location: Newton, MA

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

Post by nuntius » Tue Jan 04, 2011 9:43 am

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.

yena
Posts: 12
Joined: Sat Jun 28, 2008 2:33 am

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

Post by yena » Tue Jan 04, 2011 3:12 pm

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.

Warren Wilkinson
Posts: 117
Joined: Tue Aug 10, 2010 11:24 pm
Location: Calgary, Alberta
Contact:

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

Post by Warren Wilkinson » Wed Jan 05, 2011 12:24 pm

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. =)
Need an online wiki database? My Lisp startup http://www.formlis.com combines a wiki with forms and reports.

TheGZeus
Posts: 79
Joined: Mon Jun 30, 2008 10:46 am

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

Post by TheGZeus » Thu Jan 06, 2011 8:50 am

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. ;)

Post Reply