Delphi GDI+学习记录(12): 矩形

//填充与描边

var
 g: TGPGraphics;
 p: TGPPen;
 sb: TGPSolidBrush;
begin
 g := TGPGraphics.Create(Canvas.Handle);
 sb := TGPSolidBrush.Create(MakeColor(255,255,255));
 p := TGPPen.Create(MakeColor(255,0,0),6);
 g.FillRectangle(sb, 0, 0, Self.ClientWidth, Self.ClientHeight); {填充窗体矩形}
 g.DrawRectangle(p,11,11,111,111); {矩形描边}
 sb.SetColor(MakeColor(255,255,0));
 g.FillRectangle(sb,11,11,111,111); {填充矩形}
 p.Free;
 sb.Free;
 g.Free;
end;

//矩形组

var
 g: TGPGraphics;
 p: TGPPen;
 sb: TGPSolidBrush;
 rs: array[0..1] of TGPRect;
begin
 g := TGPGraphics.Create(Canvas.Handle);
 sb := TGPSolidBrush.Create(MakeColor(255,255,255));
 p := TGPPen.Create(MakeColor(255,0,0),2);
 rs[0].X := 11; rs[0].Y := 11; rs[0].Width := 88; rs[0].Height := 111;
 rs[1].X := 111; rs[1].Y := 122; rs[1].Width := 88; rs[1].Height := 111;
 g.DrawRectangles(p, PGPRect(@rs), Length(rs));
 g.FillRectangles(sb, PGPRect(@rs), Length(rs));
 p.Free;
 sb.Free;
 g.Free;
end;

时间: 2024-11-08 17:30:30

Delphi GDI+学习记录(12): 矩形的相关文章

Delphi GDI+ 学习记录(28): 图像颜色的数据格式

//指定位图颜色var g,gbit: TGPGraphics; bit1,bit2: TGPBitmap; sb: TGPSolidBrush; begin //Self.Color := clWhite; g := TGPGraphics.Create(Canvas.Handle); sb := TGPSolidBrush.Create(MakeColor(255,0,0)); {画刷为红色} bit1 := TGPBitmap.Create(200, 32, PixelFormat32bp

Delphi GDI+ 学习记录(23): 输出文本<2>

//在矩形范围中显示文本var g: TGPGraphics; fontFamily: TGPFontFamily; font: TGPFont; rectF: TGPRectF; p: TGPPen; sb: TGPSolidBrush; str: WideString; begin g := TGPGraphics.Create(Canvas.Handle); fontFamily:= TGPFontFamily.Create('宋体'); font:= TGPFont.Create(fon

Delphi GDI+学习记录(21): 颜色

//颜色透明度var g: TGPGraphics; sb: TGPSolidBrush; begin g := TGPGraphics.Create(Canvas.Handle); sb := TGPSolidBrush.Create(MakeColor(128,255,0,0)); {128表示半透明} g.FillRectangle(sb,10,10,100,100); sb.Free; g.Free; end; //使用 GDI+ 的颜色类型var g: TGPGraphics; sb:

Delphi GDI+学习记录(19): 路径

//绘制与填充路径var g: TGPGraphics; path: TGPGraphicsPath; p: TGPPen; sb: TGPSolidBrush; begin g := TGPGraphics.Create(Canvas.Handle); p := TGPPen.Create(MakeColor(128,255,0,0),4); sb := TGPSolidBrush.Create(MakeColor(128,255,255,0)); path := TGPGraphicsPat

Delphi GDI+学习记录(9): 纹理画刷

//纹理画刷 var g: TGPGraphics; img: TGPImage; tb: TGPTextureBrush; begin g := TGPGraphics.Create(Canvas.Handle); img := TGPImage.Create('c:\temp\small.jpg'); tb := TGPTextureBrush.Create(img); g.FillEllipse(tb, 0, 0, Self.ClientWidth, Self.ClientHeight);

Delphi GDI+学习记录(8): 阴影画刷

//阴影画刷 var g: TGPGraphics; hb: TGPHatchBrush; begin g := TGPGraphics.Create(Canvas.Handle); hb := TGPHatchBrush.Create(HatchStyleHorizontal, aclRed, aclYellow); {参数1是阴影样式; 参数2是前景色; 参数3是背景色, 参数3可选, 默认黑色} g.FillEllipse(hb, 11, 11, 222, 111); hb.Free; g

Delphi GDI+学习记录(4): 画笔对齐

//笔对齐 var g: TGPGraphics; p: TGPPen; sb: TGPSolidBrush; rect: TGPRect; begin g := TGPGraphics.Create(Canvas.Handle); p := TGPPen.Create(MakeColor(255,255,0,0),5); sb := TGPSolidBrush.Create(MakeColor(255,255,255,0)); p.SetAlignment(PenAlignmentCenter

Delphi GDI+学习记录(3): 虚线画笔

//虚线样式 var g: TGPGraphics; p: TGPPen; begin g := TGPGraphics.Create(Canvas.Handle); p := TGPPen.Create(MakeColor(255,255,0,0),3); g.DrawLine(p, 11, 11, 333, 11); {实线} p.SetDashStyle(DashStyleDashDot); {设置虚线样式} g.DrawLine(p, 11, 33, 333, 33); {绘制任何形状都

Delphi GDI+学习记录(2): 画笔线帽

//线帽 var g: TGPGraphics; p: TGPPen; begin g := TGPGraphics.Create(Canvas.Handle); p:= TGPPen.Create(aclBlue, 8); p.SetStartCap(LineCapArrowAnchor); {起点线帽} p.SetEndCap(LineCapRoundAnchor); {终点线帽} g.DrawLine(p, 20, 20, 300, 175); p.Free; g.Free; end; 线