Doodle Kids

 
 

program DoodleKids;

uses Types, Quickdraw, Events, miscTool;


var

  etypes,color            : integer;

  key, size, shape, x, y, i : integer;

  event                 : eventRecord;

  mouse                 : point;

  tri                   : handle;

  rec                   : rect;

  animate, draw         : boolean;

  tick                    : longInt;


{ Color cycle }


procedure cycle;

begin 

  if animate then begin

    color := getColorEntry(0, 1);

    for i := 1 to 14 do

      setColorEntry(0, i,

        getColorEntry(0, i + 1));

    setColorEntry(0, 15, color);

  end;     

end;


{ Start drawing }


procedure startDraw;

begin  

  if draw then begin

    size := random mod 9 + 3;              

    getMouse(mouse);

    x := mouse.h;

    y := mouse.v;

       

    setSolidPenPat(random mod 15 + 1);

             

    if shape < 5 then

      setRect(rec, x - size div 2,

        y - size div 2, x + size div 2,

        y + size div 2);

               

    if (shape > 6) and (shape < 9) then begin

      tri := openPoly;

        moveTo(x - size div 2, y + size div 2);

        line(size, 0);

        lineTo(x, y - size div 2);

      closePoly;

    end;               

             

    { Draw shape }

           

    case shape of

      1: paintOval(rec);

      2: paintRect(rec);

      3: frameOval(rec);

      4: frameRect(rec);

      5: begin

        moveTo(x + size div 2,

          y + size div 2);

        lineTo(x - size div 2,

          y - size div 2);

      end; 

      6: begin

        moveTo(x - size div 2,

          y + size div 2);

        lineTo(x + size div 2,

          y - size div 2);

      end; 

      7: paintPoly(tri);

      8: framePoly(tri);

      9: begin

        moveTo(x + size div 2,

          y + size div 2);

        lineTo(x - size div 2,

          y - size div 2);

        moveTo(x - size div 2,

          y + size div 2);

        lineTo(x + size div 2,

          y - size div 2);

        moveTo(x - size div 2, y);

        line(size,0);

        moveTo(x,y - size div 2);

        line(0,size);

      end; 

    end;

  end;                                 

end;   


begin

  etypes := keyDownMask + mDownMask + mUpMask;

  tick := getTick; 


  { Setup }


  graphics(320);

  clearScreen(0);

 

  while true do begin

    startDraw;

    if getTick - tick > 9 then begin

      tick := getTick;

      cycle;

    end; 

       

    if getNextEvent(etypes,event) then begin

      case event.what of

       

        { Keys }

       

        keyDownEvt: begin

          key := event.message;

         

          case key of

            27: halt;

            32: begin

              if not animate then

                animate := true

              else animate := false; 

            end;     

            127: clearScreen(0);

          end;   

        end;

       

        { Mouse }

       

        mouseDownEvt: begin

          shape := random mod 9 + 1;

          draw := true;

        end;  

        mouseUpEvt: draw := false;

      end;

    end;

  end;

end.

Ding Wen first event driven program - a full screen painting program for kids that draw random shapes and colors.


Press Delete key to clear the picture and Space key to do color cycling! Press ESC key to quit the program.


This program is written for his younger sisters. It is designed and written completely by himself.



Doodle Kids is now available as an iPhone and Android application!

Artist Julia Kay has drawn some excellent pictures using Doodle Kids for iPhone.