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
// 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 custom rounded, semi-transparent scrollbar
const
RX = 12; // round width
RY = 12; // round height
MINSLIDERW = 8; // minimum slider width
var
scrollPos, scrollCount: integer;
sliderWidth: double;
x, y, Width, Height: Integer;
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(sliderWidth), y + height - 1, RX, RY);
end;
ImageEnView1.Update();
end;
See Also
◼AdvancedDrawShape