Game Maker's Garage Forum

Game Creation => Other Languages & Tools => Topic started by: Telstar5 on June 20, 2009, 03:49:52 PM

Title: Painting in RealBasic?
Post by: Telstar5 on June 20, 2009, 03:49:52 PM
Redd? Mike? Anyone? :)

How would I go about producing a basic paint-type program in RB?

None of the tutorials on the net seem to apply to the newer versions of RB, and the examples provided with RB aren't much help either.
Title: Re: Painting in RealBasic?
Post by: Redd on June 20, 2009, 05:33:03 PM
This is what I did:

First, set properties dX and dY as Integers and cardPic as Picture.

Following is all in the canvas methods:

Make sure cardPic is as big as the canvas:
Open
Code: [Select]
cardPic = NewPicture( Me.Width, Me.Height, 32 )

To avoid flickering under other platforms:
Paint
Code: [Select]
g.DrawPicture( cardPic, 0, 0 )

For the paint brush:
MouseDown
Code: [Select]
dX = X
dY = Y
Return True
MouseDrag
Code: [Select]
cardPic.Graphics.DrawLine dX, dY, X, Y
dX = X
dY = Y
Refresh

Paint bucket is fairly simple:
MouseDown
Code: [Select]
cardPic.RGBSurface.FloodFill( X, Y, color )

That's the simple stuff I can come up with right now.
Title: Re: Painting in RealBasic?
Post by: Telstar5 on June 20, 2009, 06:00:22 PM
Oh lord, thanks Redd. That was suprisingly easy...

Thanks again :)
Title: Re: Painting in RealBasic?
Post by: Tireas Dragon on June 20, 2009, 10:20:30 PM
who woulda thought making a drawing program could take just a few lines of code.
Title: Re: Painting in RealBasic?
Post by: Redd on June 21, 2009, 09:40:25 AM
Quote
who woulda thought making a drawing program could take just a few lines of code.
Usually it doesn't take much effort at all. :P