Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2007-07

fpcanvas and FloodFill()

6 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Graeme Geldenhuys

Hi,

Still trying to implement fpcanvas as the bases classed for fpGUI. What is the function of...?

TFPCustomCanvas = class
....

  procedure FloodFill (x,y:integer);

...

How is it supposed to differ from Canvas.Clear() and Canvas.Rectangle() which can both handle filling of a rectangle?

Regards,
- Graeme -

Reply by email

Michael Van Canneyt
to Graeme Geldenhuys
Graeme Geldenhuys wrote 12 lines
Hi, Still trying to implement fpcanvas as the bases classed for fpGUI. What is the function of...? TFPCustomCanvas = class .... procedure FloodFill (x,y:integer); ... How is it supposed to differ from Canvas.Clear() and Canvas.Rectangle() which can both handle filling of a rectangle?

It fills the canvas (in all directions) till it encounters a different color which differs from the starting color. You can use this to fill irregular shapes.

Michael.

Reply by email

Graeme Geldenhuys
to Michael Van Canneyt
Michael Van Canneyt wrote
It fills the canvas (in all directions) till it encounters a different color which differs from the starting color. You can use this to fill irregular shapes.

Excellent idea. Now I only need to figure out how to implement that! ;-)

Graeme.

Reply by email

Michael Van Canneyt
to Graeme Geldenhuys
Graeme Geldenhuys wrote 7 lines
On 02/07/07, Michael Van Canneyt wrote: > > It fills the canvas (in all directions) till it encounters a different > color which differs from the starting color. You can use this to fill > irregular shapes. Excellent idea. Now I only need to figure out how to implement that! ;-)

The FPImagecanvas has it implemented, you should be able to get some inspiration from that. Look also in the pixtools unit.

Michael.

Reply by email

Graeme Geldenhuys
to Michael Van Canneyt
Michael Van Canneyt wrote
The FPImagecanvas has it implemented, you should be able to get some inspiration from that. Look also in the pixtools unit.

Thanks Michael.
The hard bit (without looking at any code) will be the rules when to paint.

Am I understanding FloodFill() correctly. For example: If we have a Canvas with shapes painted on it. The inside of a rectangle might have the same background color as the canvas, but we don't want to paint inside the rectangle as it is a closed shape. Then we might have a another shape with a outline, but the shape isn't closed (end points of polygon doesn't meet up), so we still need to paint inside it.

This is going to be fun. I'll have a look at those units you mentioned.

So far I have implement about 70% of TFPCustomCanvas in my new fpGUI framework. I've also completed Canvas.Pen, Canvas.Brush and Canvas.Font support. All under X11 only, but now that I know what to do, GDI should hopefully go quicker.

Regards,
- Graeme -

Reply by email

Michael Van Canneyt
to Graeme Geldenhuys
Graeme Geldenhuys wrote 16 lines
On 02/07/07, Michael Van Canneyt wrote: > > The FPImagecanvas has it implemented, you should be able to get some > inspiration > from that. Look also in the pixtools unit. Thanks Michael. The hard bit (without looking at any code) will be the rules when to paint. Am I understanding FloodFill() correctly. For example: If we have a Canvas with shapes painted on it. The inside of a rectangle might have the same background color as the canvas, but we don't want to paint inside the rectangle as it is a closed shape. Then we might have a another shape with a outline, but the shape isn't closed (end points of polygon doesn't meet up), so we still need to paint inside it.

Yes.

This is going to be fun. I'll have a look at those units you mentioned.

Pixtools should have a fully functional version.
It just needs to be able to retrieve pixel colors.

Show quoted text 5 lines
So far I have implement about 70% of TFPCustomCanvas in my new fpGUI framework. I've also completed Canvas.Pen, Canvas.Brush and Canvas.Font support. All under X11 only, but now that I know what to do, GDI should hopefully go quicker.

No-one promised an easy ride ;-)

if you have questions, don't hesitate to bug me.

Michael.

Reply by email