Help with simple graphics
Bob Arning
arning at charm.net
Thu Sep 23 23:37:34 UTC 1999
On Thu, 23 Sep 1999 19:22:29 -0400 Aron Brener <brener at home.com> wrote:
>I have to do a project for a class I'm taking relating to shortest
>path on a maze. As my programs find the solutions, it supposed to
>show them on the screen. My professor gave us a graphics package we
>can use for C. I'd prefer to do the project in Smalltalk because I
>think it'll be a lot easier to implement.
>
>What I need is a tutorial that'll teach me to do simple stuff in
>squeak, like drawing squares, lines, maybe use different thicknesses,
>labels for the lines. I also have to be able to print the screen,
>although this is not imperative. I guess I could use a screen
>grabbing utility to do that.
For a quick first pass, consider implementing your maze solution as a Morph subclass (or, perhaps better, a BorderedMorph subclass). Every Morph in the World is sent a message "drawOn: aCanvas" when some part of its area needs to be redrawn. Your #drawOn: method could do things like:
aCanvas
line: aPoint
to: someOtherPoint
width: oneOrWhatever
color: insertYourFavoriteColorHere.
aCanvas
frameAndFillRectangle: someRectangle
fillColor: someOtherColor
borderWidth: zeroOrMore
borderColor: yetAnotherColor.
repeated, of course, for all the lines/squares in your maze.
Cheers,
Bob
More information about the Squeak-dev
mailing list
|