procedure TForm1.Button1Click(Sender: TObject);begin form1.Canvas.Rectangle(0, 0, 100, 100); form1.Canvas.Ellipse(50, 50, 100, 100); form1.Canvas.FloodFill(3, 3, clRed, fsSurface);end;
before the Canvas.Rectangle (or any form Ellipse, etc.), you have to define the fill color in Canvas.Brush.Color propertyRegards,FabienWang
Thank you. But Suppose that I have opened a .bmp/bitmap file containing the rectangle and the circle, then how should I Fill the rectangle? (and not the circle?)
AFAIK this is usually done with recursive algorithm. ...
Canvas.Brush.Color := clNone; Canvas.Rectangle(0, 0, 100, 100); Canvas.Ellipse(0, 0, 50, 50); Canvas.Brush.Color := clBlack; Canvas.FloodFill(3, 3, clBlack, fsBorder);
Code: [Select] Canvas.Brush.Color := clNone; Canvas.Rectangle(0, 0, 100, 100); Canvas.Ellipse(0, 0, 50, 50); Canvas.Brush.Color := clBlack; Canvas.FloodFill(3, 3, clBlack, fsBorder);
// replaces any color with clYellow at the mouse positionprocedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);begin Canvas.Brush.Color := clYellow; Canvas.FloodFill(x, y, Canvas.Pixels[x,y], fsSurface);end;