Declaration
TIEBrush = class;
Description
TIEBrush is a GDI+ Brush wrapper and VCL TBrush wrapper. It is available via
TIEBitmap.IECanvas.Brush.
Methods and Properties
Member | Declaration | Description |
BackColor | property BackColor: TColor; | The secondary color for brush styles of bsHorizontal, bsVertical, bsFDiagonal, bsBDiagonal, bsCross, bsDiagCross or gradients |
BackTransparency | property BackTransparency: integer; | Level of transparency of the secondary color for brush styles of bsHorizontal, bsVertical, bsFDiagonal, bsBDiagonal, bsCross, bsDiagCross or gradients (from 0 - fully transparent to 255 - fully opaque) |
Color | property Color: TColor; | Color of fills |
SetGradient | procedure SetGradient(Dir: TIEGDIPlusGradient; Width, Height: Integer); | Fill the brush with a linear gradient running from Color to BackColor. Width and Height should be set to the size of the canvas |
Style | property Style: TBrushStyle; | Style of brush fill |
Transparency | property Transparency: integer; | Level of transparency of fills (from 0 - fully transparent to 255 - fully opaque) |
Examples
// Draw an envelope with 50% transparency
with ImageEnView1.IEBitmap.IECanvas do
begin
Pen.Mode := pmCopy;
Pen.Style := psSolid;
Pen.Color := clBlack;
Pen.Transparency := 128;
Brush.Color := clYellow;
Brush.Style := bsSolid;
Brush.Transparency := 128;
// Draw outer rect
Rectangle( 100, 100, 500, 300 );
// Draw flap
MoveTo( 100, 100 );
LineTo( 300, 200 );
LineTo( 500, 100 );
end;
ImageEnView1.Update();
// Draw a semi-transparent text box onto a bitmap
const
Horz_Margin = 8;
Vert_Margin = 3;
Center_Text = False;
var
x, y: integer;
tw, rw, rh: integer;
iec: TIECanvas;
ss: string;
begin
ss := 'This is my text';
x := 100;
y := 100;
iec := TIECanvas.Create( Bitmap.Canvas );
iec.Font.Assign( GetTextFont() );
tw := iec.TextWidth(ss);
rw := imax( tw + 2 * Horz_Margin, iec.TextWidth(minText) + 2 * Horz_Margin );
rh := iec.TextHeight(ss) + 2 * Vert_Margin;
if Center_Text then
dec( x, rw div 2 );
iec.Brush.Color := clYellow;
iec.Brush.Style := bsSolid;
iec.Brush.Transparency := 196;
iec.Pen.Color := clBlack;
iec.Pen.Style := psSolid;
iec.Rectangle( x, y, x + rw, y + rh );
iec.Brush.Style := bsClear;
iec.TextOut(x + ( rw - tw ) div 2, y + Vert_Margin, ss);
iec.Free;
end;
// Highlight an area of a bitmap
iec := TIECanvas.Create( Bitmap.Canvas, false );
iec.Brush.Color := clRed;
iec.Brush.Style := bsSolid;
iec.Brush.Transparency := 125;
iec.FillRect( Rect( 100, 100, 300, 300 );
iec.Free;
// 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;