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); {默认}
 rect := MakeRect(22,22,222,111);
 g.DrawEllipse(p, rect);
 g.FillEllipse(sb, rect);
 p.SetAlignment(PenAlignmentInset);
 rect := MakeRect(22,111,222,111);
 g.DrawEllipse(p, rect);
 g.FillEllipse(sb, rect);
 sb.Free;
 p.Free;
 g.Free;
end;

画笔对齐方式:

Delphi 微软 说明
PenAlignmentCenter Center 指定 Pen 对象以理论的线条为中心。
PenAlignmentInset Inset 指定 Pen 被定位于理论的线条内。
无定义 Left 指定将 Pen 定位于理论的线条的左侧。
无定义 Outset 指定将 Pen 定位于理论的线条外。
无定义 Right 指定将 Pen 定位于理论的线条的右侧。
时间: 2024-12-02 07:21:16

Delphi GDI+学习记录(4): 画笔对齐的相关文章

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; 线

Delphi GDI+学习记录(1) 画笔

//画笔 var g: TGPGraphics; p: TGPPen; begin g := TGPGraphics.Create(Canvas.Handle); p := TGPPen.Create(aclRed, 2); {参数1颜色; 参数2是笔宽, 笔宽是可选, 默认 1} g.DrawEllipse(p, 11, 11, 222, 111); p.Free; g.Free; end; //设置笔宽与颜色 var g: TGPGraphics; p: TGPPen; begin g :=

Delphi GDI+学习记录(6): 使用画刷建立画笔

//使用画刷建立画笔 var g: TGPGraphics; img: TGPImage; tb: TGPTextureBrush; p: TGPPen; begin g := TGPGraphics.Create(Canvas.Handle); img := TGPImage.Create('c:\temp\small.jpg'); tb := TGPTextureBrush.Create(img); p := TGPPen.Create(tb,36); {参数 1 是画刷; 参数 2 是笔宽

Delphi GDI+学习记录(5): 复合画笔

//复合画笔 var g: TGPGraphics; p: TGPPen; arr: array[0..9] of Single; {10 个元素可以分成 5 条线, 每条线需要起点和终点} begin g := TGPGraphics.Create(Canvas.Handle); p := TGPPen.Create(MakeColor(255,255,0,0),100); {笔宽定为 100 好算帐} arr[0] := 0.00; {第一条线起点} arr[1] := 0.01; {第一条

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+ 学习记录(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+学习记录(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+ 学习记录(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+学习记录(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