再学 GDI+[57]: 路径 - Widen
为什么80%的码农都做不了架构师?>>>
路径的 Widen 方法可以把路径中的线, 根据指定画笔的宽度与样式, 转换为一个范围(有点类似区域); 但转换后再描绘路径就只能使用 FillPath 而不是 DrawPath 了. 本例没有测试它的两个默认参数, 因为前面已多次提到了.
本例效果图:
代码文件:
unit Unit1;interfaceusesWindows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,Dialogs, StdCtrls;typeTForm1 = class(TForm)CheckBox1: TCheckBox;CheckBox2: TCheckBox;procedure FormCreate(Sender: TObject);procedure FormPaint(Sender: TObject);procedure CheckBox1Click(Sender: TObject);procedure CheckBox2Click(Sender: TObject);end;varForm1: TForm1;implementation{$R *.dfm}uses GDIPOBJ, GDIPAPI;procedure TForm1.FormCreate(Sender: TObject);
beginCheckBox1.Caption := '执行 Widen';CheckBox2.Caption := '显示路径中所有的点';
end;procedure TForm1.FormPaint(Sender: TObject);
varg: TGPGraphics;p: TGPPen;b1,b2: TGPBrush;path: TGPGraphicsPath;pts: array of TGPPoint;i: Integer;
beging := TGPGraphics.Create(Canvas.Handle);p := TGPPen.Create(aclSlateGray, 20);p.SetEndCap(LineCapArrowAnchor);b1 := TGPSolidBrush.Create(aclRed);b2 := TGPHatchBrush.Create(HatchStyleDiagonalCross, aclSilver, aclSlateGray);path := TGPGraphicsPath.Create;path.AddLine(40, 50, ClientWidth-40, 50);if CheckBox1.Checked thenbeginpath.Widen(p);g.FillPath(b2, path);end else g.DrawPath(p, path);if CheckBox2.Checked thenbeginSetLength(pts, path.GetPointCount);path.GetPathPoints(PGPPoint(pts), Length(pts));TGPSolidBrush(b1).SetColor(aclRed);for i := 0 to Length(pts) - 1 dog.FillRectangle(b1, pts[i].X-3, pts[i].Y-3, 6, 6);end;path.Free;b1.Free;b2.Free;p.Free;g.Free;
end;procedure TForm1.CheckBox1Click(Sender: TObject);
beginRepaint;
end;procedure TForm1.CheckBox2Click(Sender: TObject);
beginRepaint;
end;end.
窗体文件:
object Form1: TForm1Left = 0Top = 0Caption = 'Form1'ClientHeight = 136ClientWidth = 287Color = clBtnFaceFont.Charset = DEFAULT_CHARSETFont.Color = clWindowTextFont.Height = -11Font.Name = 'Tahoma'Font.Style = []OldCreateOrder = FalsePosition = poDesktopCenterOnCreate = FormCreateOnPaint = FormPaintPixelsPerInch = 96TextHeight = 13object CheckBox1: TCheckBoxLeft = 43Top = 104Width = 97Height = 17Caption = 'CheckBox1'TabOrder = 0OnClick = CheckBox1Clickendobject CheckBox2: TCheckBoxLeft = 138Top = 104Width = 125Height = 17Caption = 'CheckBox2'TabOrder = 1OnClick = CheckBox2Clickend
end
转载于:https://my.oschina.net/hermer/blog/320228
再学 GDI+[57]: 路径 - Widen相关推荐
- 再学 GDI+[56]: 路径 - Warp
为什么80%的码农都做不了架构师?>>> 通过路径的 Warp 方法可以让路径在一个范围内(四个点决定的范围)变换; 第一个参数可以是 3 个点或 4 个点的数组, 如果是 3 ...
- 再学 GDI+[68]: 路径画刷(8) - SetBlendTriangularShaped、SetBlendBellShape
本例效果图(颜色失真严重, 因为 GIF 最多只能接受 256 中颜色): 代码文件: unit Unit1;interfaceusesWindows, Messages, SysUtils, Var ...
- 再学 GDI+[62]: 路径画刷(2) - SetCenterPoint、GetCenterPoint
本例效果图: 代码文件: unit Unit1;interfaceusesWindows, Messages, SysUtils, Variants, Classes, Graphics, Contr ...
- 再学 GDI+[67]: 路径画刷(7) - 画个五角星
本例效果图: 代码1: unit Unit1;interfaceusesWindows, Messages, SysUtils, Variants, Classes, Graphics, Contro ...
- 再学 GDI+[63]: 路径画刷(3) - SetFocusScales、GetFocusScales
为什么80%的码农都做不了架构师?>>> 本例效果图: 代码文件: unit Unit1;interfaceusesWindows, Messages, SysUtils, V ...
- 再学 GDI+[81]: TGPImage(1) - 显示图像
已知 GDI+ 可以支持的图像格式: BMP.JPEG.GIF.TIFF.PNG.ICO.WMF.EMF TGPGraphics.DrawImage 函数有太多重载了, 一起列在这吧: functio ...
- 再学 GDI+[11]: DrawCurve - 绘制曲线
本例效果图: 代码文件: unit Unit1;interfaceusesWindows, Messages, SysUtils, Variants, Classes, Graphics, Contr ...
- 再学 GDI+[7]: DrawLines - 绘制一组直线
本例效果图: 代码文件: unit Unit1;interfaceusesWindows, Messages, SysUtils, Variants, Classes, Graphics, Contr ...
- mysql img格式缩放,再学 GDI+[89]: TGPImage(9) - 图像缩放时的质量(算法)
本例效果图: 代码文件: unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Co ...
最新文章
- 反距离加权法高程_干货:企业估值的收益法、成本法和市场法
- 502 bad gateway php-fm,php+nginx 上传大文件 502 Bad Gateway
- php数组指定键名,查找数组中指定键名的值_PHP教程
- 量产之后计算机读不出u盘,求大神、我量产没成功然后U盘就电脑上就不显示了...
- 创业者谈:畏惧失败,但也要拥抱失败
- [BZOJ2879] [Noi2012] 美食节 (费用流 动态加边)
- 下载keep运动软件_keep app下载-keep安卓版(运动健身) - 超好玩
- 计算机835真题,《计算机水平考试》复习题835题(含答案)
- icmp协议_计算机网络基础(七)网络层ICMP协议
- php之使用file_get_contents对百度orc进行文字识别(二维码识别同理)--base64编码方式(解决image format error)
- [GRE] 填空机经 Section56-60
- 谷歌地图地名显示繁体字_谷歌地图卫星地图怎么取消地名还有路线
- JQuery实现防抖节流
- MobaXterm连接到Linux虚拟机教程
- pyqt5报错——ERROR: pip‘s dependency resolver does not currently take into account all the packages that
- 算法与数据结构学习路线
- WordPress快速增加百度收录的方法
- 鸿蒙系统怎么打开纯净模式,#手机[超话]##2021有点东西##OPP... - @安诺颜_ 的微博精选 - 微博国际站...
- 推荐系统中的双塔模型
- 定时器控制LED闪烁