再学 GDI+[67]: 路径画刷(7) - 画个五角星
代码1:
unit Unit1;interfaceusesWindows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,Dialogs;typeTForm1 = class(TForm)procedure FormPaint(Sender: TObject);end;varForm1: TForm1;implementation{$R *.dfm}uses GDIPOBJ, GDIPAPI;procedure TForm1.FormPaint(Sender: TObject); constpt: TPoint = (X:130; Y:130);r = 120;colors: array[0..0] of TGPColor = (aclRed); varg: TGPGraphics;p: TGPPen;path: TGPGraphicsPath;pb: TGPPathGradientBrush;pts: array[0..4] of TGPPoint;radian: Single;i,num: Integer; beginfor i := 0 to 4 dobeginradian := i * (360*2/5) * (Pi/180);pts[i].X := pt.X + Round(Sin(radian) * r);pts[i].Y := pt.Y - Round(Cos(radian) * r);end;g := TGPGraphics.Create(Canvas.Handle);path := TGPGraphicsPath.Create;path.AddPolygon(PGPPoint(@pts), Length(pts));pb:= TGPPathGradientBrush.Create(path);num := Length(colors);pb.SetSurroundColors(@colors, num);pb.SetCenterColor(aclYellow);{描个边}p := TGPPen.Create(aclYellow);g.SetSmoothingMode(SmoothingModeAntiAlias);g.DrawPath(p, path);g.FillPath(pb, path);pb.Free;path.Free;p.Free;g.Free; end;end.
代码2:
unit Unit1;interfaceusesWindows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,Dialogs;typeTForm1 = class(TForm)procedure FormPaint(Sender: TObject);end;varForm1: TForm1;implementation{$R *.dfm}uses GDIPOBJ, GDIPAPI;procedure TForm1.FormPaint(Sender: TObject); constpt: TPoint = (X:130; Y:130);r = 120;colors: array[0..0] of TGPColor = (aclRed); varg: TGPGraphics;p: TGPPen;path: TGPGraphicsPath;pb: TGPPathGradientBrush;pts: array[0..9] of TGPPoint;radian: Single;i,num: Integer;rx: Single; beginfor i := 0 to 9 dobeginrx := r;if Odd(i) then rx := r * (1- (Sqrt(5)-1)/2); {(Sqrt(5)-1)/2 是黄金分割点, 约为 0.618}radian := i * (360/10) * (Pi/180);pts[i].X := pt.X + Round(Sin(radian) * rx);pts[i].Y := pt.Y - Round(Cos(radian) * rx);end;g := TGPGraphics.Create(Canvas.Handle);path := TGPGraphicsPath.Create;path.AddPolygon(PGPPoint(@pts), Length(pts));pb:= TGPPathGradientBrush.Create(path);num := Length(colors);pb.SetSurroundColors(@colors, num);pb.SetCenterColor(aclYellow);{描个边}p := TGPPen.Create(aclYellow);g.SetSmoothingMode(SmoothingModeAntiAlias);g.DrawPath(p, path);g.FillPath(pb, path);pb.Free;path.Free;p.Free;g.Free; end;end.
窗体文件:
object Form1: TForm1Left = 0Top = 0Caption = 'Form1'ClientHeight = 238ClientWidth = 259Color = clBtnFaceFont.Charset = DEFAULT_CHARSETFont.Color = clWindowTextFont.Height = -11Font.Name = 'Tahoma'Font.Style = []OldCreateOrder = FalsePosition = poDesktopCenterOnPaint = FormPaintPixelsPerInch = 96TextHeight = 13 end
再学 GDI+[67]: 路径画刷(7) - 画个五角星相关推荐
- 再学 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+[63]: 路径画刷(3) - SetFocusScales、GetFocusScales
为什么80%的码农都做不了架构师?>>> 本例效果图: 代码文件: unit Unit1;interfaceusesWindows, Messages, SysUtils, V ...
- 再学 GDI+[57]: 路径 - Widen
为什么80%的码农都做不了架构师?>>> 路径的 Widen 方法可以把路径中的线, 根据指定画笔的宽度与样式, 转换为一个范围(有点类似区域); 但转换后再描绘路径就只能使用 ...
- 再学 GDI+[56]: 路径 - Warp
为什么80%的码农都做不了架构师?>>> 通过路径的 Warp 方法可以让路径在一个范围内(四个点决定的范围)变换; 第一个参数可以是 3 个点或 4 个点的数组, 如果是 3 ...
- 再学 GDI+[20]: TGPTextureBrush 与 TWrapMode
为什么80%的码农都做不了架构师?>>> TGPTextureBrush.Create(image: TGPImage; {用于画刷的图像}wrapMode: TWrapMod ...
- 再学 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 ...
最新文章
- 运维-系统架构师经验总结:
- Eclipse配置初始化(自用)
- java学习(154):文件复制
- SplitConcatWithAMP----Array转换为String,连接;String转换为Array,切割
- [RMAN]使用RMAN删除过期归档日志
- 没有servlet接口_Java——Servlet
- Outlook常见问题解决方案
- .NET框架源码解读之SSCLI编译过程简介
- 论文阅读(12) 与其他后生动物相比,水母被动能量的重新获取有助于推进优势(2013)
- cocos creator人物动画切换控制
- 万能五笔输入法弹窗_万能五笔输入法广告如何彻底关闭
- linux更改ntfs格式权限,Gentoo Linux下读写NTFS格式分区(ntfs-3g解决NTFS只读不可写的问题)...
- linux进阶52——pthread_cond_t
- html ace编辑器,Springboot 集成 Ace editor前端编辑器
- pg_stat_database 视图 tup_returned、tup_fetched 的含义
- 为什么日本人不吃鲤鱼
- Caliburn.Micro将枚举 绑定到ComboBox
- python setup.py build,无法执行“python setup.py build”命令..!
- gdb @entry= 是什么意思
- c语言谷歌的招聘题目扣分,google的环环相扣招聘试题
热门文章
- 浙江科技学院计算机辅助教育试卷,(下册).-浙江科技学院经济与管理学院.doc
- 数据库-几个重要的数据库相关概念
- 125w短波通信距离_125W军用自主选频短波电台
- kafka java_Java操作Kafka
- 为什么前端工程师的工作很难找?
- 什么是HTML5前端开发?HTML5前端要学哪些技术?
- 学web前端开发写给新手的建议,超实用
- 前端开发核心JavaScript要怎么学?给转行或是自学的朋友提些学习建议
- 请问我应该怎么做,才能让前端的基础打牢固?
- 生命游戏 并行化_新加坡电音制作人楚晴Jasmine《困兽游戏》,讲述爱情间的博弈...