Topic:   Painting in RealBasic?   (Read 19568 times)


0 Members and 1 Guest are viewing this topic.

Telstar5


  • GMG-er

  • **


  • Posts: 371

  • The sun is up, the sky is blue...
Painting in RealBasic?
« 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.


Redd


  • GMG-er

  • **


  • Posts: 118

  • Silent, but very, very deadly.
Re: Painting in RealBasic?
« Reply #1 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.

Telstar5


  • GMG-er

  • **


  • Posts: 371

  • The sun is up, the sky is blue...
Re: Painting in RealBasic?
« Reply #2 on: June 20, 2009, 06:00:22 PM »
Oh lord, thanks Redd. That was suprisingly easy...

Thanks again :)


Tireas Dragon


  • GMG Extraordinaire

  • ***


  • Posts: 1626

  • Trying to recover from my shattered screen.
Re: Painting in RealBasic?
« Reply #3 on: June 20, 2009, 10:20:30 PM »
who woulda thought making a drawing program could take just a few lines of code.
I must be dreaming (wake up me wake up) How could this have happened. Tireas' cry when he found his computer fallen over in his chair with it's screen shattered.

Redd


  • GMG-er

  • **


  • Posts: 118

  • Silent, but very, very deadly.
Re: Painting in RealBasic?
« Reply #4 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