ImageEn, unit iegdiplus

TIECanvas.RoundRect

TIECanvas.RoundRect


Declaration

procedure RoundRect(X1, Y1, X2, Y2, X3, Y3: Integer);


Description

Draw a rounded rect within a specified area.
X3 and Y3 specify the amount of corner rounding.
The rectangle border is set by Pen and the fill by Brush.

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


Examples

// Draw a rounded rectangle
with ImageEnView1.IEBitmap.IECanvas do
begin
  Pen.Mode  := pmCopy;
  Pen.Style := psSolid;
  Pen.Color := clBlack;

  Brush.Color := clYellow;
  Brush.Style := bsSolid;
  Brush.Transparency := 128;

  Rectangle( 100, 100, 500, 300, 20, 20 );
end;
ImageEnView1.Update();

// Draw a rounded, semi-transparent scrollbar (anti-aliased)
const
  RX         = 12;  // round width
  RY         = 12;  // round height
  MINSLIDERW = 8;   // minimum slider width
var
  scrollPos, scrollCount: integer;
  sliderWidth: double;
begin
  x := 100;
  y := 100;
  Width  := 300;
  Height := 16;
  scrollCount := 20;
  scrollPos := 3;

  with ImageEnView1.IEBitmap.IECanvas do
  begin
    // paint brush and border
    Brush.Style := bsSolid;
    Brush.Color := clWhite;
    Brush.Transparency := 64;
    Pen.Color := clWhite;
    Pen.Style := psSolid;
    Pen.Mode := pmCopy;
    Pen.Width := 1;
    Pen.Transparency := 128;
    RoundRect( x, y, x + width, y + height, RX, RY );

    // paint slider
    Brush.Style := bsSolid;
    Brush.Color := clBlack;
    Brush.Transparency := 128;
    Pen.Width := 1;
    Pen.Transparency := 128;
    sliderWidth := width / scrollCount;
    if sliderWidth < MINSLIDERW then
      sliderWidth := MINSLIDERW;
    RoundRect( x + trunc(scrollPos * sliderWidth), y + 1, x + trunc(scrollPos * sliderWidth) + trunc(asliderWidth), y + height - 1, RX, RY);
    end;
end;


See Also

 AdvancedDrawShape