[delphi][GDI+]学习记录(1): 画笔 – Pen

  • A+
所属分类:[开发技巧]

//画笔
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 := TGPGraphics.Create(Canvas.Handle);

p := TGPPen.Create(aclBlack);
{建立时应该不给参数是可以的, 但在测试中不行, 至少要给一个颜色}

p.SetColor(aclBlue); {设置颜色}
p.SetWidth(10); {设置笔宽}

g.DrawEllipse(p, 11, 11, 222, 111);

p.Free;
g.Free;
end;
--------------------------------------------------------------------------------

//获取笔宽与颜色
var
g: TGPGraphics;
p: TGPPen;
c: TGPColor;
begin
g := TGPGraphics.Create(Canvas.Handle);

p := TGPPen.Create(MakeColor(128,0,0,255), 10);

g.DrawEllipse(p, 11, 11, 222, 111);

p.GetColor(c); {获取颜色给 c}
ShowMessage(IntToHex(c, 8)); {转换为十六进制: 800000FF}
ShowMessage(FloatToStr(p.GetWidth)); {10}

p.Free;
g.Free;
end;
--------------------------------------------------------------------------------

  • 我的微信
  • 这是我的微信扫一扫
  • weinxin
  • 我的微信公众号
  • 我的微信公众号扫一扫
  • weinxin
广告也精彩
avatar
广告也精彩

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: