ImageEn, unit iegdiplus

TIECanvas.Ellipse

TIECanvas.Ellipse


Declaration

procedure Ellipse(X1, Y1, X2, Y2: Integer); overload;
procedure Ellipse(const Rect: TRect); overload;


Description

Draw an ellipse within a specified area.
The ellipse border is set by Pen and the fill by Brush.

GDI+ Methods: GdipFillEllipse, GdipDrawEllipse

Note: The X2 and Y2 points are excluded from the painting


Examples

// Draw an anti-aliased ellipse onto a TBitmap
iec := TIECanvas.Create( ABitmap.Canvas );
with iec do
begin
  Pen.Style := psSolid;
  Pen.Width := 3;
  Pen.Mode  := pmCopy;
  Pen.Color := clRed;
  Brush.Style := bsClear;
  Ellipse( Rect( 100, 100, 200, 200 ));
end;
iec.Free();



// Draw an anti-aliased ellipse onto a TIEBitmap
with iebmp.IECanvas do
begin
  Pen.Style := psSolid;
  Pen.Mode  := pmCopy;
  Pen.Color := clRed;
  Brush.Style := bsClear;
  Ellipse( Rect( 100, 100, 200, 200 ));
end;


// Method to draw a styled ellipse to a canvas
procedure IEDrawSimpleShape(Canvas: TIECanvas;
                            Left, Top, Width, Height: Integer;
                            BorderColor: TColor; BorderWidth: Integer;
                            FillColor: TColor; FillColor2: TColor = clNone;
                            FillGradient: TIEGDIPlusGradient = gpgVertical;
                            AntiAlias: Boolean = True);
const
  Rect_Rounding = 20;
var
  drawGradient: Boolean;
begin
  drawGradient := ( FillGradient <> gpgNone ) and
                  ( FillColor2 <> FillColor ) and
                  ( FillColor <> clNone ) and ( FillColor2 <> clNone );

  if AntiAlias then
    Canvas.SmoothingMode := iesmAntialias
  else
    Canvas.SmoothingMode := iesmBestPerformance;

  // Border
  if ( BorderColor = clNone ) or ( BorderWidth < 1 ) then
    Canvas.Pen.Style := psClear
  else
    Canvas.Pen.Style := psSolid;
  Canvas.Pen.Color := BorderColor;
  Canvas.Pen.Width := BorderWidth;

  // Fill
  if ( FillColor = clNone ) then
    Canvas.Brush.Style := bsClear
  else
    Canvas.Brush.Style := bsSolid;
  Canvas.Brush.Color := FillColor;

  inc( Left  , BorderWidth div 2 );
  inc( Top   , BorderWidth div 2 );
  dec( Width , BorderWidth );
  dec( Height, BorderWidth );

  if drawGradient = False then
    Canvas.Brush.SetGradient( gpgNone, 0, 0 )
  else
  begin
    Canvas.Brush.SetGradient( FillGradient, Width, Height );
    Canvas.Brush.BackTransparency := 255;
    Canvas.Brush.BackColor := FillColor2;
  end;

  Canvas.Ellipse( Left, Top, Left + Width, Top + Height );
end;



See Also

AdvancedDrawShape