DelphiXE FireMonkey 如何画图
<p><img src="https://images.cnblogs.com/cnblogs_com/FKdelphi/936049/o_200506083047DelphiXE%20FireMonkey%20%E5%A6%82%E4%BD%95%E7%94%BB%E5%9B%BE.png" alt="" width="773" height="493"></p><p> </p>
<p>相关资料:</p>
<p>https://stackoverflow.com/questions/10291330/firemonkey-penmode-equivalent-drawline</p>
<p>https://blog.csdn.net/shuaihj/article/details/8444676</p>
<p>http://www.delphitop.com/html/FMX/2646.html</p>
<p>http://docwiki.embarcadero.com/CodeExamples/Rio/en/FMXTCanvasDrawFunctions_(Delphi)</p>
<p>CSDN代码下载:</p>
<p>https://download.csdn.net/download/zhujianqiangqq/12394005</p>
<p> </p>
<p>代码实例:</p>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 128, 128, 1)">1</span> <span style="color: rgba(0, 128, 0, 1)">{</span>
<span style="color: rgba(0, 128, 128, 1)">2</span> <span style="color: rgba(0, 128, 0, 1)">相关资料:
</span><span style="color: rgba(0, 128, 128, 1)">3</span> <span style="color: rgba(0, 128, 0, 1)">http://www.delphitop.com/html/FMX/2646.html
</span><span style="color: rgba(0, 128, 128, 1)">4</span> <span style="color: rgba(0, 128, 0, 1)">http://docwiki.embarcadero.com/CodeExamples/Rio/en/FMXTCanvasDrawFunctions_(Delphi)
</span><span style="color: rgba(0, 128, 128, 1)">5</span>
<span style="color: rgba(0, 128, 128, 1)">6</span> <span style="color: rgba(0, 128, 0, 1)">FMX 的 Canvas 在不同的系统上会分别使用:
</span><span style="color: rgba(0, 128, 128, 1)">7</span> <span style="color: rgba(0, 128, 0, 1)">WinVista、Win7: D2D (FMX.Canvas.D2D.pas)
</span><span style="color: rgba(0, 128, 128, 1)">8</span> <span style="color: rgba(0, 128, 0, 1)">WinXP: GDI+ (FMX.Canvas.GDIP.pas)
</span><span style="color: rgba(0, 128, 128, 1)">9</span> <span style="color: rgba(0, 128, 0, 1)">Mac 系列: Core Graphics (FMX.Canvas.Mac.pas)
</span><span style="color: rgba(0, 128, 128, 1)"> 10</span>
<span style="color: rgba(0, 128, 128, 1)"> 11</span> <span style="color: rgba(0, 128, 0, 1)">和 HTML5 中的 Canvas 非常类似, 现在的 Canvas 模糊了 Pen 的概念:
</span><span style="color: rgba(0, 128, 128, 1)"> 12</span> <span style="color: rgba(0, 128, 0, 1)">之前的 Canvas.Pen 对应: Canvas.Stroke;
</span><span style="color: rgba(0, 128, 128, 1)"> 13</span> <span style="color: rgba(0, 128, 0, 1)">之前的 Canvas.Brush 对应: Canvas.Fill.
</span><span style="color: rgba(0, 128, 128, 1)"> 14</span>
<span style="color: rgba(0, 128, 128, 1)"> 15</span> <span style="color: rgba(0, 128, 0, 1)">在 FMX 中, Canvas 无处不在, 其 Canvas.Stroke、Canvas.Fill 的状态也各不相同, 一般要先初始化它们.
</span><span style="color: rgba(0, 128, 128, 1)"> 16</span> <span style="color: rgba(0, 128, 0, 1)">}</span>
<span style="color: rgba(0, 128, 128, 1)"> 17</span> <span style="color: rgba(0, 0, 255, 1)">unit</span><span style="color: rgba(0, 0, 0, 1)"> Unit1;
</span><span style="color: rgba(0, 128, 128, 1)"> 18</span>
<span style="color: rgba(0, 128, 128, 1)"> 19</span> <span style="color: rgba(0, 0, 255, 1)">interface</span>
<span style="color: rgba(0, 128, 128, 1)"> 20</span>
<span style="color: rgba(0, 128, 128, 1)"> 21</span> <span style="color: rgba(0, 0, 255, 1)">uses</span>
<span style="color: rgba(0, 128, 128, 1)"> 22</span> <span style="color: rgba(0, 0, 0, 1)">System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
</span><span style="color: rgba(0, 128, 128, 1)"> 23</span> <span style="color: rgba(0, 0, 0, 1)">FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.Objects,
</span><span style="color: rgba(0, 128, 128, 1)"> 24</span> <span style="color: rgba(0, 0, 0, 1)">FMX.Controls.Presentation, FMX.StdCtrls, FMX.ListBox, FMX.Edit, FMX.ComboEdit,
</span><span style="color: rgba(0, 128, 128, 1)"> 25</span> <span style="color: rgba(0, 0, 0, 1)">FMX.Colors;
</span><span style="color: rgba(0, 128, 128, 1)"> 26</span>
<span style="color: rgba(0, 128, 128, 1)"> 27</span> <span style="color: rgba(0, 0, 255, 1)">type</span>
<span style="color: rgba(0, 128, 128, 1)"> 28</span> TMYStyle = <span style="color: rgba(0, 0, 255, 1)">record</span>
<span style="color: rgba(0, 128, 128, 1)"> 29</span> <span style="color: rgba(0, 0, 0, 1)"> StrokeColor: TAlphaColor;
</span><span style="color: rgba(0, 128, 128, 1)"> 30</span> <span style="color: rgba(0, 0, 0, 1)"> StrokeThickness: Integer;
</span><span style="color: rgba(0, 128, 128, 1)"> 31</span> <span style="color: rgba(0, 0, 0, 1)"> StrokeCap: TStrokeCap;
</span><span style="color: rgba(0, 128, 128, 1)"> 32</span> <span style="color: rgba(0, 0, 0, 1)"> StrokeDash: TStrokeDash;
</span><span style="color: rgba(0, 128, 128, 1)"> 33</span> <span style="color: rgba(0, 0, 0, 1)"> StrokeJoin: TStrokeJoin;
</span><span style="color: rgba(0, 128, 128, 1)"> 34</span> <span style="color: rgba(0, 0, 0, 1)"> FillColor: TAlphaColor;
</span><span style="color: rgba(0, 128, 128, 1)"> 35</span> <span style="color: rgba(0, 0, 0, 1)"> FontSize: Integer;
</span><span style="color: rgba(0, 128, 128, 1)"> 36</span> <span style="color: rgba(0, 0, 255, 1)">end</span><span style="color: rgba(0, 0, 0, 1)">;
</span><span style="color: rgba(0, 128, 128, 1)"> 37</span> TForm1 = <span style="color: rgba(0, 0, 255, 1)">class</span><span style="color: rgba(0, 0, 0, 1)">(TForm)
</span><span style="color: rgba(0, 128, 128, 1)"> 38</span> <span style="color: rgba(0, 0, 0, 1)"> Image1: TImage;
</span><span style="color: rgba(0, 128, 128, 1)"> 39</span> <span style="color: rgba(0, 0, 0, 1)"> DrawLine: TButton;
</span><span style="color: rgba(0, 128, 128, 1)"> 40</span> <span style="color: rgba(0, 0, 0, 1)"> DrawEllipse: TButton;
</span><span style="color: rgba(0, 128, 128, 1)"> 41</span> <span style="color: rgba(0, 0, 0, 1)"> DrawArc: TButton;
</span><span style="color: rgba(0, 128, 128, 1)"> 42</span> <span style="color: rgba(0, 0, 0, 1)"> DrawBitmap: TButton;
</span><span style="color: rgba(0, 128, 128, 1)"> 43</span> <span style="color: rgba(0, 0, 0, 1)"> GroupBox1: TGroupBox;
</span><span style="color: rgba(0, 128, 128, 1)"> 44</span> <span style="color: rgba(0, 0, 0, 1)"> Label1: TLabel;
</span><span style="color: rgba(0, 128, 128, 1)"> 45</span> <span style="color: rgba(0, 0, 0, 1)"> StrokeColor: TColorComboBox;
</span><span style="color: rgba(0, 128, 128, 1)"> 46</span> <span style="color: rgba(0, 0, 0, 1)"> Label2: TLabel;
</span><span style="color: rgba(0, 128, 128, 1)"> 47</span> <span style="color: rgba(0, 0, 0, 1)"> Label3: TLabel;
</span><span style="color: rgba(0, 128, 128, 1)"> 48</span> <span style="color: rgba(0, 0, 0, 1)"> Label4: TLabel;
</span><span style="color: rgba(0, 128, 128, 1)"> 49</span> <span style="color: rgba(0, 0, 0, 1)"> Label5: TLabel;
</span><span style="color: rgba(0, 128, 128, 1)"> 50</span> <span style="color: rgba(0, 0, 0, 1)"> Label6: TLabel;
</span><span style="color: rgba(0, 128, 128, 1)"> 51</span> <span style="color: rgba(0, 0, 0, 1)"> Label7: TLabel;
</span><span style="color: rgba(0, 128, 128, 1)"> 52</span> <span style="color: rgba(0, 0, 0, 1)"> StrokeThickness: TEdit;
</span><span style="color: rgba(0, 128, 128, 1)"> 53</span> <span style="color: rgba(0, 0, 0, 1)"> StrokeCap: TComboBox;
</span><span style="color: rgba(0, 128, 128, 1)"> 54</span> <span style="color: rgba(0, 0, 0, 1)"> StrokeDash: TComboBox;
</span><span style="color: rgba(0, 128, 128, 1)"> 55</span> <span style="color: rgba(0, 0, 0, 1)"> StrokeJoin: TComboBox;
</span><span style="color: rgba(0, 128, 128, 1)"> 56</span> <span style="color: rgba(0, 0, 0, 1)"> FillColor: TColorComboBox;
</span><span style="color: rgba(0, 128, 128, 1)"> 57</span> <span style="color: rgba(0, 0, 0, 1)"> FontSize: TEdit;
</span><span style="color: rgba(0, 128, 128, 1)"> 58</span> <span style="color: rgba(0, 0, 0, 1)"> scFlat: TListBoxItem;
</span><span style="color: rgba(0, 128, 128, 1)"> 59</span> <span style="color: rgba(0, 0, 0, 1)"> scRound: TListBoxItem;
</span><span style="color: rgba(0, 128, 128, 1)"> 60</span> <span style="color: rgba(0, 0, 0, 1)"> sjMiter: TListBoxItem;
</span><span style="color: rgba(0, 128, 128, 1)"> 61</span> <span style="color: rgba(0, 0, 0, 1)"> sjRound: TListBoxItem;
</span><span style="color: rgba(0, 128, 128, 1)"> 62</span> <span style="color: rgba(0, 0, 0, 1)"> sjBevel: TListBoxItem;
</span><span style="color: rgba(0, 128, 128, 1)"> 63</span> <span style="color: rgba(0, 0, 0, 1)"> GroupBox2: TGroupBox;
</span><span style="color: rgba(0, 128, 128, 1)"> 64</span> <span style="color: rgba(0, 0, 0, 1)"> DrawRectSides: TButton;
</span><span style="color: rgba(0, 128, 128, 1)"> 65</span> <span style="color: rgba(0, 0, 0, 1)"> DrawRect: TButton;
</span><span style="color: rgba(0, 128, 128, 1)"> 66</span> <span style="color: rgba(0, 0, 0, 1)"> Edit3: TEdit;
</span><span style="color: rgba(0, 128, 128, 1)"> 67</span> <span style="color: rgba(0, 0, 0, 1)"> FillText: TButton;
</span><span style="color: rgba(0, 128, 128, 1)"> 68</span> <span style="color: rgba(0, 0, 0, 1)"> Claer: TButton;
</span><span style="color: rgba(0, 128, 128, 1)"> 69</span> <span style="color: rgba(0, 0, 0, 1)"> DrawPath: TButton;
</span><span style="color: rgba(0, 128, 128, 1)"> 70</span> <span style="color: rgba(0, 0, 0, 1)"> DrawPolygon: TButton;
</span><span style="color: rgba(0, 128, 128, 1)"> 71</span> <span style="color: rgba(0, 0, 0, 1)"> CreateThumbnail: TButton;
</span><span style="color: rgba(0, 128, 128, 1)"> 72</span> <span style="color: rgba(0, 0, 0, 1)"> OpenDialog1: TOpenDialog;
</span><span style="color: rgba(0, 128, 128, 1)"> 73</span> <span style="color: rgba(0, 0, 255, 1)">procedure</span><span style="color: rgba(0, 0, 0, 1)"> DrawLineClick(Sender: TObject);
</span><span style="color: rgba(0, 128, 128, 1)"> 74</span> <span style="color: rgba(0, 0, 255, 1)">procedure</span><span style="color: rgba(0, 0, 0, 1)"> ClaerClick(Sender: TObject);
</span><span style="color: rgba(0, 128, 128, 1)"> 75</span> <span style="color: rgba(0, 0, 255, 1)">procedure</span><span style="color: rgba(0, 0, 0, 1)"> DrawRectSidesClick(Sender: TObject);
</span><span style="color: rgba(0, 128, 128, 1)"> 76</span> <span style="color: rgba(0, 0, 255, 1)">procedure</span><span style="color: rgba(0, 0, 0, 1)"> Image1Paint(Sender: TObject; Canvas: TCanvas;
</span><span style="color: rgba(0, 128, 128, 1)"> 77</span> <span style="color: rgba(0, 0, 255, 1)">const</span><span style="color: rgba(0, 0, 0, 1)"> ARect: TRectF);
</span><span style="color: rgba(0, 128, 128, 1)"> 78</span> <span style="color: rgba(0, 0, 255, 1)">procedure</span><span style="color: rgba(0, 0, 0, 1)"> FormCreate(Sender: TObject);
</span><span style="color: rgba(0, 128, 128, 1)"> 79</span> <span style="color: rgba(0, 0, 255, 1)">procedure</span><span style="color: rgba(0, 0, 0, 1)"> DrawArcClick(Sender: TObject);
</span><span style="color: rgba(0, 128, 128, 1)"> 80</span> <span style="color: rgba(0, 0, 255, 1)">procedure</span><span style="color: rgba(0, 0, 0, 1)"> DrawBitmapClick(Sender: TObject);
</span><span style="color: rgba(0, 128, 128, 1)"> 81</span> <span style="color: rgba(0, 0, 255, 1)">procedure</span><span style="color: rgba(0, 0, 0, 1)"> DrawEllipseClick(Sender: TObject);
</span><span style="color: rgba(0, 128, 128, 1)"> 82</span> <span style="color: rgba(0, 0, 255, 1)">procedure</span><span style="color: rgba(0, 0, 0, 1)"> DrawPathClick(Sender: TObject);
</span><span style="color: rgba(0, 128, 128, 1)"> 83</span> <span style="color: rgba(0, 0, 255, 1)">procedure</span><span style="color: rgba(0, 0, 0, 1)"> DrawPolygonClick(Sender: TObject);
</span><span style="color: rgba(0, 128, 128, 1)"> 84</span> <span style="color: rgba(0, 0, 255, 1)">procedure</span><span style="color: rgba(0, 0, 0, 1)"> DrawRectClick(Sender: TObject);
</span><span style="color: rgba(0, 128, 128, 1)"> 85</span> <span style="color: rgba(0, 0, 255, 1)">procedure</span><span style="color: rgba(0, 0, 0, 1)"> CreateThumbnailClick(Sender: TObject);
</span><span style="color: rgba(0, 128, 128, 1)"> 86</span> <span style="color: rgba(0, 0, 255, 1)">procedure</span><span style="color: rgba(0, 0, 0, 1)"> FillTextClick(Sender: TObject);
</span><span style="color: rgba(0, 128, 128, 1)"> 87</span> <span style="color: rgba(0, 0, 255, 1)">procedure</span><span style="color: rgba(0, 0, 0, 1)"> StrokeColorChange(Sender: TObject);
</span><span style="color: rgba(0, 128, 128, 1)"> 88</span> <span style="color: rgba(0, 0, 255, 1)">private</span>
<span style="color: rgba(0, 128, 128, 1)"> 89</span> <span style="color: rgba(0, 128, 0, 1)">{</span><span style="color: rgba(0, 128, 0, 1)"> Private declarations </span><span style="color: rgba(0, 128, 0, 1)">}</span>
<span style="color: rgba(0, 128, 128, 1)"> 90</span> <span style="color: rgba(0, 0, 255, 1)">procedure</span><span style="color: rgba(0, 0, 0, 1)"> SetMYStyle;
</span><span style="color: rgba(0, 128, 128, 1)"> 91</span> <span style="color: rgba(0, 0, 255, 1)">public</span>
<span style="color: rgba(0, 128, 128, 1)"> 92</span> <span style="color: rgba(0, 128, 0, 1)">{</span><span style="color: rgba(0, 128, 0, 1)"> Public declarations </span><span style="color: rgba(0, 128, 0, 1)">}</span>
<span style="color: rgba(0, 128, 128, 1)"> 93</span> <span style="color: rgba(0, 0, 255, 1)">end</span><span style="color: rgba(0, 0, 0, 1)">;
</span><span style="color: rgba(0, 128, 128, 1)"> 94</span>
<span style="color: rgba(0, 128, 128, 1)"> 95</span> <span style="color: rgba(0, 0, 255, 1)">var</span>
<span style="color: rgba(0, 128, 128, 1)"> 96</span> <span style="color: rgba(0, 0, 0, 1)">Form1: TForm1;
</span><span style="color: rgba(0, 128, 128, 1)"> 97</span> <span style="color: rgba(0, 0, 0, 1)">oStyle: TMYStyle;
</span><span style="color: rgba(0, 128, 128, 1)"> 98</span>
<span style="color: rgba(0, 128, 128, 1)"> 99</span> <span style="color: rgba(0, 0, 255, 1)">implementation</span>
<span style="color: rgba(0, 128, 128, 1)">100</span> <span style="color: rgba(0, 0, 255, 1)">uses</span>
<span style="color: rgba(0, 128, 128, 1)">101</span> <span style="color: rgba(0, 0, 0, 1)">System.UIConsts,
</span><span style="color: rgba(0, 128, 128, 1)">102</span> <span style="color: rgba(0, 0, 0, 1)">System.Math.Vectors;
</span><span style="color: rgba(0, 128, 128, 1)">103</span>
<span style="color: rgba(0, 128, 128, 1)">104</span> <span style="color: rgba(0, 128, 0, 1)">{</span><span style="color: rgba(0, 128, 0, 1)">$R *.fmx</span><span style="color: rgba(0, 128, 0, 1)">}</span>
<span style="color: rgba(0, 128, 128, 1)">105</span> <span style="color: rgba(0, 128, 0, 1)">{</span><span style="color: rgba(0, 128, 0, 1)">$R *.LgXhdpiPh.fmx ANDROID</span><span style="color: rgba(0, 128, 0, 1)">}</span>
<span style="color: rgba(0, 128, 128, 1)">106</span>
<span style="color: rgba(0, 128, 128, 1)">107</span> <span style="color: rgba(0, 0, 255, 1)">procedure</span><span style="color: rgba(0, 0, 0, 1)"> TForm1.DrawLineClick(Sender: TObject);
</span><span style="color: rgba(0, 128, 128, 1)">108</span> <span style="color: rgba(0, 0, 255, 1)">var</span>
<span style="color: rgba(0, 128, 128, 1)">109</span> <span style="color: rgba(0, 0, 0, 1)">p1, p2: TPointF;
</span><span style="color: rgba(0, 128, 128, 1)">110</span> <span style="color: rgba(0, 0, 255, 1)">begin</span>
<span style="color: rgba(0, 128, 128, 1)">111</span> <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> sets the ends of the line to be drawn</span>
<span style="color: rgba(0, 128, 128, 1)">112</span> p1 := TPointF.<span style="color: rgba(0, 0, 255, 1)">Create</span>(<span style="color: rgba(128, 0, 128, 1)">20</span>, <span style="color: rgba(128, 0, 128, 1)">2</span><span style="color: rgba(0, 0, 0, 1)">);
</span><span style="color: rgba(0, 128, 128, 1)">113</span> p2 := TPointF.<span style="color: rgba(0, 0, 255, 1)">Create</span>(<span style="color: rgba(128, 0, 128, 1)">350</span>, <span style="color: rgba(128, 0, 128, 1)">400</span><span style="color: rgba(0, 0, 0, 1)">);
</span><span style="color: rgba(0, 128, 128, 1)">114</span> <span style="color: rgba(0, 0, 0, 1)">Image1.Bitmap.Canvas.BeginScene;
</span><span style="color: rgba(0, 128, 128, 1)">115</span> <span style="color: rgba(0, 0, 0, 1)">SetMYStyle;
</span><span style="color: rgba(0, 128, 128, 1)">116</span> <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> draws the line on the canvas</span>
<span style="color: rgba(0, 128, 128, 1)">117</span> Image1.Bitmap.Canvas.DrawLine(p1, p2, <span style="color: rgba(128, 0, 128, 1)">100</span><span style="color: rgba(0, 0, 0, 1)">);
</span><span style="color: rgba(0, 128, 128, 1)">118</span> <span style="color: rgba(0, 0, 0, 1)">Image1.Bitmap.Canvas.EndScene;
</span><span style="color: rgba(0, 128, 128, 1)">119</span> <span style="color: rgba(0, 0, 255, 1)">end</span><span style="color: rgba(0, 0, 0, 1)">;
</span><span style="color: rgba(0, 128, 128, 1)">120</span>
<span style="color: rgba(0, 128, 128, 1)">121</span> <span style="color: rgba(0, 0, 255, 1)">procedure</span><span style="color: rgba(0, 0, 0, 1)"> TForm1.DrawPathClick(Sender: TObject);
</span><span style="color: rgba(0, 128, 128, 1)">122</span> <span style="color: rgba(0, 0, 255, 1)">var</span>
<span style="color: rgba(0, 128, 128, 1)">123</span> <span style="color: rgba(0, 0, 0, 1)">path: TPathData;
</span><span style="color: rgba(0, 128, 128, 1)">124</span> <span style="color: rgba(0, 0, 0, 1)">MyRect1, MyRect2: TRectF;
</span><span style="color: rgba(0, 128, 128, 1)">125</span> <span style="color: rgba(0, 0, 255, 1)">begin</span>
<span style="color: rgba(0, 128, 128, 1)">126</span> <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> set the circumscribed rectangle of the ellipse to be add in the path</span>
<span style="color: rgba(0, 128, 128, 1)">127</span> MyRect1 := TRectF.<span style="color: rgba(0, 0, 255, 1)">Create</span>(<span style="color: rgba(128, 0, 128, 1)">90</span>, <span style="color: rgba(128, 0, 128, 1)">100</span>, <span style="color: rgba(128, 0, 128, 1)">230</span>, <span style="color: rgba(128, 0, 128, 1)">300</span><span style="color: rgba(0, 0, 0, 1)">);
</span><span style="color: rgba(0, 128, 128, 1)">128</span> <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">/ sets the rectangle to be add in the path</span>
<span style="color: rgba(0, 128, 128, 1)">129</span> MyRect2 := TRectF.<span style="color: rgba(0, 0, 255, 1)">Create</span>(<span style="color: rgba(128, 0, 128, 1)">70</span>, <span style="color: rgba(128, 0, 128, 1)">90</span>, <span style="color: rgba(128, 0, 128, 1)">220</span>, <span style="color: rgba(128, 0, 128, 1)">290</span><span style="color: rgba(0, 0, 0, 1)">);
</span><span style="color: rgba(0, 128, 128, 1)">130</span> <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> initializes and creates the path to be drawn</span>
<span style="color: rgba(0, 128, 128, 1)">131</span> path := TPathData.<span style="color: rgba(0, 0, 255, 1)">Create</span><span style="color: rgba(0, 0, 0, 1)">;
</span><span style="color: rgba(0, 128, 128, 1)">132</span> <span style="color: rgba(0, 0, 0, 1)">path.AddEllipse(MyRect1);
</span><span style="color: rgba(0, 128, 128, 1)">133</span> path.AddRectangle(MyRect2, <span style="color: rgba(128, 0, 128, 1)">0</span>, <span style="color: rgba(128, 0, 128, 1)">0</span><span style="color: rgba(0, 0, 0, 1)">, AllCorners);
</span><span style="color: rgba(0, 128, 128, 1)">134</span> <span style="color: rgba(0, 0, 0, 1)">Image1.Bitmap.Canvas.BeginScene;
</span><span style="color: rgba(0, 128, 128, 1)">135</span> <span style="color: rgba(0, 0, 0, 1)">SetMYStyle;
</span><span style="color: rgba(0, 128, 128, 1)">136</span> <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> draws the path on the canvas</span>
<span style="color: rgba(0, 128, 128, 1)">137</span> Image1.Bitmap.Canvas.DrawPath(path, <span style="color: rgba(128, 0, 128, 1)">200</span><span style="color: rgba(0, 0, 0, 1)">);
</span><span style="color: rgba(0, 128, 128, 1)">138</span> <span style="color: rgba(0, 0, 0, 1)">Image1.Bitmap.Canvas.EndScene;
</span><span style="color: rgba(0, 128, 128, 1)">139</span> <span style="color: rgba(0, 0, 255, 1)">end</span><span style="color: rgba(0, 0, 0, 1)">;
</span><span style="color: rgba(0, 128, 128, 1)">140</span>
<span style="color: rgba(0, 128, 128, 1)">141</span> <span style="color: rgba(0, 0, 255, 1)">procedure</span><span style="color: rgba(0, 0, 0, 1)"> TForm1.DrawPolygonClick(Sender: TObject);
</span><span style="color: rgba(0, 128, 128, 1)">142</span> <span style="color: rgba(0, 0, 255, 1)">var</span>
<span style="color: rgba(0, 128, 128, 1)">143</span> <span style="color: rgba(0, 0, 0, 1)">p1, p2, p3, p4, p5, p6: TPointF;
</span><span style="color: rgba(0, 128, 128, 1)">144</span> MyPolygon: TPolygon; <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">System.Math.Vectors unit needed.</span>
<span style="color: rgba(0, 128, 128, 1)">145</span> <span style="color: rgba(0, 0, 255, 1)">begin</span>
<span style="color: rgba(0, 128, 128, 1)">146</span> <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> sets the points that define the polygon</span>
<span style="color: rgba(0, 128, 128, 1)">147</span> p1 := TPointF.<span style="color: rgba(0, 0, 255, 1)">Create</span>(<span style="color: rgba(128, 0, 128, 1)">80</span>, <span style="color: rgba(128, 0, 128, 1)">200</span><span style="color: rgba(0, 0, 0, 1)">);
</span><span style="color: rgba(0, 128, 128, 1)">148</span> p2 := TPointF.<span style="color: rgba(0, 0, 255, 1)">Create</span>(<span style="color: rgba(128, 0, 128, 1)">225</span>, <span style="color: rgba(128, 0, 128, 1)">30</span><span style="color: rgba(0, 0, 0, 1)">);
</span><span style="color: rgba(0, 128, 128, 1)">149</span> p3 := TPointF.<span style="color: rgba(0, 0, 255, 1)">Create</span>(<span style="color: rgba(128, 0, 128, 1)">370</span>, <span style="color: rgba(128, 0, 128, 1)">200</span><span style="color: rgba(0, 0, 0, 1)">);
</span><span style="color: rgba(0, 128, 128, 1)">150</span> p4 := TPointF.<span style="color: rgba(0, 0, 255, 1)">Create</span>(<span style="color: rgba(128, 0, 128, 1)">300</span>, <span style="color: rgba(128, 0, 128, 1)">340</span><span style="color: rgba(0, 0, 0, 1)">);
</span><span style="color: rgba(0, 128, 128, 1)">151</span> p5 := TPointF.<span style="color: rgba(0, 0, 255, 1)">Create</span>(<span style="color: rgba(128, 0, 128, 1)">150</span>, <span style="color: rgba(128, 0, 128, 1)">340</span><span style="color: rgba(0, 0, 0, 1)">);
</span><span style="color: rgba(0, 128, 128, 1)">152</span> p6 := TPointF.<span style="color: rgba(0, 0, 255, 1)">Create</span>(<span style="color: rgba(128, 0, 128, 1)">80</span>, <span style="color: rgba(128, 0, 128, 1)">200</span><span style="color: rgba(0, 0, 0, 1)">);
</span><span style="color: rgba(0, 128, 128, 1)">153</span> <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> creates the polygon</span>
<span style="color: rgba(0, 128, 128, 1)">154</span> SetLength(MyPolygon, <span style="color: rgba(128, 0, 128, 1)">6</span><span style="color: rgba(0, 0, 0, 1)">);
</span><span style="color: rgba(0, 128, 128, 1)">155</span> MyPolygon[<span style="color: rgba(128, 0, 128, 1)">0</span>] :=<span style="color: rgba(0, 0, 0, 1)"> p1;
</span><span style="color: rgba(0, 128, 128, 1)">156</span> MyPolygon[<span style="color: rgba(128, 0, 128, 1)">1</span>] :=<span style="color: rgba(0, 0, 0, 1)"> p2;
</span><span style="color: rgba(0, 128, 128, 1)">157</span> MyPolygon[<span style="color: rgba(128, 0, 128, 1)">2</span>] :=<span style="color: rgba(0, 0, 0, 1)"> p3;
</span><span style="color: rgba(0, 128, 128, 1)">158</span> MyPolygon[<span style="color: rgba(128, 0, 128, 1)">3</span>] :=<span style="color: rgba(0, 0, 0, 1)"> p4;
</span><span style="color: rgba(0, 128, 128, 1)">159</span> MyPolygon[<span style="color: rgba(128, 0, 128, 1)">4</span>] :=<span style="color: rgba(0, 0, 0, 1)"> p5;
</span><span style="color: rgba(0, 128, 128, 1)">160</span> MyPolygon[<span style="color: rgba(128, 0, 128, 1)">5</span>] :=<span style="color: rgba(0, 0, 0, 1)"> p6;
</span><span style="color: rgba(0, 128, 128, 1)">161</span> <span style="color: rgba(0, 0, 0, 1)">Image1.Bitmap.Canvas.BeginScene;
</span><span style="color: rgba(0, 128, 128, 1)">162</span> <span style="color: rgba(0, 0, 0, 1)">SetMYStyle;
</span><span style="color: rgba(0, 128, 128, 1)">163</span> <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> draws the polygon on the canvas</span>
<span style="color: rgba(0, 128, 128, 1)">164</span> Image1.Bitmap.Canvas.DrawPolygon(MyPolygon, <span style="color: rgba(128, 0, 128, 1)">50</span><span style="color: rgba(0, 0, 0, 1)">);
</span><span style="color: rgba(0, 128, 128, 1)">165</span> <span style="color: rgba(0, 0, 0, 1)">Image1.Bitmap.Canvas.EndScene;
</span><span style="color: rgba(0, 128, 128, 1)">166</span> <span style="color: rgba(0, 0, 255, 1)">end</span><span style="color: rgba(0, 0, 0, 1)">;
</span><span style="color: rgba(0, 128, 128, 1)">167</span>
<span style="color: rgba(0, 128, 128, 1)">168</span> <span style="color: rgba(0, 0, 255, 1)">procedure</span><span style="color: rgba(0, 0, 0, 1)"> TForm1.DrawRectClick(Sender: TObject);
</span><span style="color: rgba(0, 128, 128, 1)">169</span> <span style="color: rgba(0, 0, 255, 1)">var</span>
<span style="color: rgba(0, 128, 128, 1)">170</span> <span style="color: rgba(0, 0, 0, 1)">MyRect: TRectF;
</span><span style="color: rgba(0, 128, 128, 1)">171</span> <span style="color: rgba(0, 0, 255, 1)">begin</span>
<span style="color: rgba(0, 128, 128, 1)">172</span> <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> sets the rectangle to be drawn</span>
<span style="color: rgba(0, 128, 128, 1)">173</span> MyRect := TRectF.<span style="color: rgba(0, 0, 255, 1)">Create</span>(<span style="color: rgba(128, 0, 128, 1)">50</span>, <span style="color: rgba(128, 0, 128, 1)">40</span>, <span style="color: rgba(128, 0, 128, 1)">200</span>, <span style="color: rgba(128, 0, 128, 1)">270</span><span style="color: rgba(0, 0, 0, 1)">);
</span><span style="color: rgba(0, 128, 128, 1)">174</span> <span style="color: rgba(0, 0, 0, 1)">Image1.Bitmap.Canvas.BeginScene;
</span><span style="color: rgba(0, 128, 128, 1)">175</span> <span style="color: rgba(0, 0, 0, 1)">SetMYStyle;
</span><span style="color: rgba(0, 128, 128, 1)">176</span> <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> draws the rectangle on the canvas</span>
<span style="color: rgba(0, 128, 128, 1)">177</span> Image1.Bitmap.Canvas.DrawRect(MyRect, <span style="color: rgba(128, 0, 128, 1)">30</span>, <span style="color: rgba(128, 0, 128, 1)">60</span>, AllCorners, <span style="color: rgba(128, 0, 128, 1)">100</span><span style="color: rgba(0, 0, 0, 1)">);
</span><span style="color: rgba(0, 128, 128, 1)">178</span> <span style="color: rgba(0, 0, 0, 1)">Image1.Bitmap.Canvas.EndScene;
</span><span style="color: rgba(0, 128, 128, 1)">179</span> <span style="color: rgba(0, 0, 255, 1)">end</span><span style="color: rgba(0, 0, 0, 1)">;
</span><span style="color: rgba(0, 128, 128, 1)">180</span>
<span style="color: rgba(0, 128, 128, 1)">181</span> <span style="color: rgba(0, 0, 255, 1)">procedure</span><span style="color: rgba(0, 0, 0, 1)"> TForm1.CreateThumbnailClick(Sender: TObject);
</span><span style="color: rgba(0, 128, 128, 1)">182</span> <span style="color: rgba(0, 0, 255, 1)">var</span>
<span style="color: rgba(0, 128, 128, 1)">183</span> <span style="color: rgba(0, 0, 0, 1)">MyBitmap: TBitmap;
</span><span style="color: rgba(0, 128, 128, 1)">184</span> <span style="color: rgba(0, 0, 255, 1)">begin</span>
<span style="color: rgba(0, 128, 128, 1)">185</span> <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> loads the bitmap using the TOpenDialog.</span>
<span style="color: rgba(0, 128, 128, 1)">186</span> <span style="color: rgba(0, 0, 255, 1)">if</span> OpenDialog1.Execute <span style="color: rgba(0, 0, 255, 1)">then</span>
<span style="color: rgba(0, 128, 128, 1)">187</span> MyBitmap := TBitmap.CreateFromFile(OpenDialog1.Files[<span style="color: rgba(128, 0, 128, 1)">0</span><span style="color: rgba(0, 0, 0, 1)">]);
</span><span style="color: rgba(0, 128, 128, 1)">188</span> <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> draws a thumbnail with given sizes</span>
<span style="color: rgba(0, 128, 128, 1)">189</span> Image1.Bitmap :=MyBitmap.CreateThumbnail(<span style="color: rgba(128, 0, 128, 1)">300</span>,<span style="color: rgba(128, 0, 128, 1)">300</span><span style="color: rgba(0, 0, 0, 1)">);
</span><span style="color: rgba(0, 128, 128, 1)">190</span> <span style="color: rgba(0, 0, 255, 1)">end</span><span style="color: rgba(0, 0, 0, 1)">;
</span><span style="color: rgba(0, 128, 128, 1)">191</span>
<span style="color: rgba(0, 128, 128, 1)">192</span> <span style="color: rgba(0, 0, 255, 1)">procedure</span><span style="color: rgba(0, 0, 0, 1)"> TForm1.DrawArcClick(Sender: TObject);
</span><span style="color: rgba(0, 128, 128, 1)">193</span> <span style="color: rgba(0, 0, 255, 1)">var</span>
<span style="color: rgba(0, 128, 128, 1)">194</span> <span style="color: rgba(0, 0, 0, 1)">p1, p2: TPointF;
</span><span style="color: rgba(0, 128, 128, 1)">195</span> <span style="color: rgba(0, 0, 255, 1)">begin</span>
<span style="color: rgba(0, 128, 128, 1)">196</span> <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> Sets the center of the arc</span>
<span style="color: rgba(0, 128, 128, 1)">197</span> p1 := TPointF.<span style="color: rgba(0, 0, 255, 1)">Create</span>(<span style="color: rgba(128, 0, 128, 1)">200</span>, <span style="color: rgba(128, 0, 128, 1)">200</span><span style="color: rgba(0, 0, 0, 1)">);
</span><span style="color: rgba(0, 128, 128, 1)">198</span> <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> sets the radius of the arc</span>
<span style="color: rgba(0, 128, 128, 1)">199</span> p2 := TPointF.<span style="color: rgba(0, 0, 255, 1)">Create</span>(<span style="color: rgba(128, 0, 128, 1)">150</span>, <span style="color: rgba(128, 0, 128, 1)">150</span><span style="color: rgba(0, 0, 0, 1)">);
</span><span style="color: rgba(0, 128, 128, 1)">200</span> <span style="color: rgba(0, 0, 0, 1)">Image1.Bitmap.Canvas.BeginScene;
</span><span style="color: rgba(0, 128, 128, 1)">201</span> <span style="color: rgba(0, 0, 0, 1)">SetMYStyle;
</span><span style="color: rgba(0, 128, 128, 1)">202</span> <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> draws the arc on the canvas</span>
<span style="color: rgba(0, 128, 128, 1)">203</span> Image1.Bitmap.Canvas.DrawArc(p1, p2, <span style="color: rgba(128, 0, 128, 1)">90</span>, <span style="color: rgba(128, 0, 128, 1)">230</span>, <span style="color: rgba(128, 0, 128, 1)">20</span><span style="color: rgba(0, 0, 0, 1)">);
</span><span style="color: rgba(0, 128, 128, 1)">204</span> <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> updates the bitmap to show the arc</span>
<span style="color: rgba(0, 128, 128, 1)">205</span> <span style="color: rgba(0, 0, 0, 1)">Image1.Bitmap.Canvas.EndScene;
</span><span style="color: rgba(0, 128, 128, 1)">206</span> <span style="color: rgba(0, 0, 255, 1)">end</span><span style="color: rgba(0, 0, 0, 1)">;
</span><span style="color: rgba(0, 128, 128, 1)">207</span>
<span style="color: rgba(0, 128, 128, 1)">208</span> <span style="color: rgba(0, 0, 255, 1)">procedure</span><span style="color: rgba(0, 0, 0, 1)"> TForm1.DrawBitmapClick(Sender: TObject);
</span><span style="color: rgba(0, 128, 128, 1)">209</span> <span style="color: rgba(0, 0, 255, 1)">var</span>
<span style="color: rgba(0, 128, 128, 1)">210</span> <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> MyBitmap is the bitmap to be drawn on the canvas</span>
<span style="color: rgba(0, 128, 128, 1)">211</span> <span style="color: rgba(0, 0, 0, 1)">MyBitmap: TBitmap;
</span><span style="color: rgba(0, 128, 128, 1)">212</span> <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> is the area where to draw the bitmap</span>
<span style="color: rgba(0, 128, 128, 1)">213</span> <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> also is the area of the bitmap to be drawn on the canvas</span>
<span style="color: rgba(0, 128, 128, 1)">214</span> <span style="color: rgba(0, 0, 0, 1)">MyRect: TRectF;
</span><span style="color: rgba(0, 128, 128, 1)">215</span> <span style="color: rgba(0, 0, 255, 1)">begin</span>
<span style="color: rgba(0, 128, 128, 1)">216</span> <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> loads the bitmap using the TOpenDialog.</span>
<span style="color: rgba(0, 128, 128, 1)">217</span> <span style="color: rgba(0, 0, 255, 1)">if</span> OpenDialog1.Execute <span style="color: rgba(0, 0, 255, 1)">then</span>
<span style="color: rgba(0, 128, 128, 1)">218</span> MyBitmap := TBitmap.CreateFromFile(OpenDialog1.Files[<span style="color: rgba(128, 0, 128, 1)">0</span><span style="color: rgba(0, 0, 0, 1)">]);
</span><span style="color: rgba(0, 128, 128, 1)">219</span> <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> set theMyRect coordinates</span>
<span style="color: rgba(0, 128, 128, 1)">220</span> MyRect := TRectF.<span style="color: rgba(0, 0, 255, 1)">Create</span>(<span style="color: rgba(128, 0, 128, 1)">0</span>, <span style="color: rgba(128, 0, 128, 1)">0</span>, <span style="color: rgba(128, 0, 128, 1)">150</span>, <span style="color: rgba(128, 0, 128, 1)">200</span><span style="color: rgba(0, 0, 0, 1)">);
</span><span style="color: rgba(0, 128, 128, 1)">221</span> <span style="color: rgba(0, 0, 0, 1)">Image1.Bitmap.Canvas.BeginScene;
</span><span style="color: rgba(0, 128, 128, 1)">222</span> <span style="color: rgba(0, 0, 0, 1)">SetMYStyle;
</span><span style="color: rgba(0, 128, 128, 1)">223</span> <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> draws on the rectangle specified by MyRect the area from MyBitmap specified by MyRect</span>
<span style="color: rgba(0, 128, 128, 1)">224</span> Image1.Bitmap.Canvas.DrawBitmap(MyBitmap, MyRect, MyRect, <span style="color: rgba(128, 0, 128, 1)">20</span><span style="color: rgba(0, 0, 0, 1)">);
</span><span style="color: rgba(0, 128, 128, 1)">225</span> <span style="color: rgba(0, 0, 0, 1)">Image1.Bitmap.Canvas.EndScene;
</span><span style="color: rgba(0, 128, 128, 1)">226</span> <span style="color: rgba(0, 0, 255, 1)">end</span><span style="color: rgba(0, 0, 0, 1)">;
</span><span style="color: rgba(0, 128, 128, 1)">227</span>
<span style="color: rgba(0, 128, 128, 1)">228</span> <span style="color: rgba(0, 0, 255, 1)">procedure</span><span style="color: rgba(0, 0, 0, 1)"> TForm1.DrawEllipseClick(Sender: TObject);
</span><span style="color: rgba(0, 128, 128, 1)">229</span> <span style="color: rgba(0, 0, 255, 1)">var</span>
<span style="color: rgba(0, 128, 128, 1)">230</span> <span style="color: rgba(0, 0, 0, 1)">MyRect: TRectF;
</span><span style="color: rgba(0, 128, 128, 1)">231</span> <span style="color: rgba(0, 0, 255, 1)">begin</span>
<span style="color: rgba(0, 128, 128, 1)">232</span> <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> sets the circumscribed rectangle of the ellipse</span>
<span style="color: rgba(0, 128, 128, 1)">233</span> MyRect := TRectF.<span style="color: rgba(0, 0, 255, 1)">Create</span>(<span style="color: rgba(128, 0, 128, 1)">50</span>, <span style="color: rgba(128, 0, 128, 1)">40</span>, <span style="color: rgba(128, 0, 128, 1)">200</span>, <span style="color: rgba(128, 0, 128, 1)">270</span><span style="color: rgba(0, 0, 0, 1)">);
</span><span style="color: rgba(0, 128, 128, 1)">234</span> <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> draws the ellipse on the canvas</span>
<span style="color: rgba(0, 128, 128, 1)">235</span> <span style="color: rgba(0, 0, 0, 1)">Image1.Bitmap.Canvas.BeginScene;
</span><span style="color: rgba(0, 128, 128, 1)">236</span> <span style="color: rgba(0, 0, 0, 1)">SetMYStyle;
</span><span style="color: rgba(0, 128, 128, 1)">237</span> Image1.Bitmap.Canvas.DrawEllipse(MyRect, <span style="color: rgba(128, 0, 128, 1)">40</span><span style="color: rgba(0, 0, 0, 1)">);
</span><span style="color: rgba(0, 128, 128, 1)">238</span> <span style="color: rgba(0, 0, 0, 1)">Image1.Bitmap.Canvas.EndScene;
</span><span style="color: rgba(0, 128, 128, 1)">239</span> <span style="color: rgba(0, 0, 255, 1)">end</span><span style="color: rgba(0, 0, 0, 1)">;
</span><span style="color: rgba(0, 128, 128, 1)">240</span>
<span style="color: rgba(0, 128, 128, 1)">241</span> <span style="color: rgba(0, 0, 255, 1)">procedure</span><span style="color: rgba(0, 0, 0, 1)"> TForm1.DrawRectSidesClick(Sender: TObject);
</span><span style="color: rgba(0, 128, 128, 1)">242</span> <span style="color: rgba(0, 0, 255, 1)">var</span>
<span style="color: rgba(0, 128, 128, 1)">243</span> <span style="color: rgba(0, 0, 0, 1)">MyRect: TRectF;
</span><span style="color: rgba(0, 128, 128, 1)">244</span> <span style="color: rgba(0, 0, 255, 1)">begin</span>
<span style="color: rgba(0, 128, 128, 1)">245</span> <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> sets the rectangle to be customized and drawn</span>
<span style="color: rgba(0, 128, 128, 1)">246</span> MyRect := TRectF.<span style="color: rgba(0, 0, 255, 1)">Create</span>(<span style="color: rgba(128, 0, 128, 1)">50</span>, <span style="color: rgba(128, 0, 128, 1)">40</span>, <span style="color: rgba(128, 0, 128, 1)">200</span>, <span style="color: rgba(128, 0, 128, 1)">270</span><span style="color: rgba(0, 0, 0, 1)">);
</span><span style="color: rgba(0, 128, 128, 1)">247</span> <span style="color: rgba(0, 0, 0, 1)">Image1.Bitmap.Canvas.BeginScene;
</span><span style="color: rgba(0, 128, 128, 1)">248</span> <span style="color: rgba(0, 0, 0, 1)">SetMYStyle;
</span><span style="color: rgba(0, 128, 128, 1)">249</span> <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> customize the rectangle and draws it on the canvas</span>
<span style="color: rgba(0, 128, 128, 1)">250</span> Image1.Bitmap.Canvas.DrawRectSides(MyRect, <span style="color: rgba(128, 0, 128, 1)">50</span>, <span style="color: rgba(128, 0, 128, 1)">20</span>, AllCorners, <span style="color: rgba(128, 0, 128, 1)">40</span><span style="color: rgba(0, 0, 0, 1)">, AllSides,
</span><span style="color: rgba(0, 128, 128, 1)">251</span> <span style="color: rgba(0, 0, 0, 1)"> TCornerType.Bevel);
</span><span style="color: rgba(0, 128, 128, 1)">252</span> <span style="color: rgba(0, 0, 0, 1)">Image1.Bitmap.Canvas.EndScene;
</span><span style="color: rgba(0, 128, 128, 1)">253</span> <span style="color: rgba(0, 0, 255, 1)">end</span><span style="color: rgba(0, 0, 0, 1)">;
</span><span style="color: rgba(0, 128, 128, 1)">254</span>
<span style="color: rgba(0, 128, 128, 1)">255</span> <span style="color: rgba(0, 0, 255, 1)">procedure</span><span style="color: rgba(0, 0, 0, 1)"> TForm1.FillTextClick(Sender: TObject);
</span><span style="color: rgba(0, 128, 128, 1)">256</span> <span style="color: rgba(0, 0, 255, 1)">var</span>
<span style="color: rgba(0, 128, 128, 1)">257</span> <span style="color: rgba(0, 0, 0, 1)">MyRect: TRectF;
</span><span style="color: rgba(0, 128, 128, 1)">258</span> <span style="color: rgba(0, 0, 255, 1)">begin</span>
<span style="color: rgba(0, 128, 128, 1)">259</span> <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> sets the rectangle to be customized and drawn</span>
<span style="color: rgba(0, 128, 128, 1)">260</span> MyRect := TRectF.<span style="color: rgba(0, 0, 255, 1)">Create</span>(<span style="color: rgba(128, 0, 128, 1)">0</span>, <span style="color: rgba(128, 0, 128, 1)">0</span>, <span style="color: rgba(128, 0, 128, 1)">100</span>, <span style="color: rgba(128, 0, 128, 1)">200</span><span style="color: rgba(0, 0, 0, 1)">);
</span><span style="color: rgba(0, 128, 128, 1)">261</span> <span style="color: rgba(0, 0, 0, 1)">Image1.Bitmap.Canvas.BeginScene;
</span><span style="color: rgba(0, 128, 128, 1)">262</span> <span style="color: rgba(0, 0, 0, 1)">SetMYStyle;
</span><span style="color: rgba(0, 128, 128, 1)">263</span> Image1.Bitmap.Canvas.FillText(MyRect, Edit3.Text, false, <span style="color: rgba(128, 0, 128, 1)">100</span><span style="color: rgba(0, 0, 0, 1)">, [], TTextAlign.taLeading, TTextAlign.taCenter);
</span><span style="color: rgba(0, 128, 128, 1)">264</span> <span style="color: rgba(0, 0, 0, 1)">Image1.Bitmap.Canvas.EndScene;
</span><span style="color: rgba(0, 128, 128, 1)">265</span> <span style="color: rgba(0, 0, 255, 1)">end</span><span style="color: rgba(0, 0, 0, 1)">;
</span><span style="color: rgba(0, 128, 128, 1)">266</span>
<span style="color: rgba(0, 128, 128, 1)">267</span> <span style="color: rgba(0, 0, 255, 1)">procedure</span><span style="color: rgba(0, 0, 0, 1)"> TForm1.ClaerClick(Sender: TObject);
</span><span style="color: rgba(0, 128, 128, 1)">268</span> <span style="color: rgba(0, 0, 255, 1)">begin</span>
<span style="color: rgba(0, 128, 128, 1)">269</span> <span style="color: rgba(0, 0, 0, 1)">Image1.Bitmap.Clear(TAlphaColors.White);
</span><span style="color: rgba(0, 128, 128, 1)">270</span> <span style="color: rgba(0, 0, 255, 1)">end</span><span style="color: rgba(0, 0, 0, 1)">;
</span><span style="color: rgba(0, 128, 128, 1)">271</span>
<span style="color: rgba(0, 128, 128, 1)">272</span> <span style="color: rgba(0, 0, 255, 1)">procedure</span><span style="color: rgba(0, 0, 0, 1)"> TForm1.FormCreate(Sender: TObject);
</span><span style="color: rgba(0, 128, 128, 1)">273</span> <span style="color: rgba(0, 0, 255, 1)">begin</span>
<span style="color: rgba(0, 128, 128, 1)">274</span> <span style="color: rgba(0, 0, 0, 1)">SetMYStyle;
</span><span style="color: rgba(0, 128, 128, 1)">275</span> <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">第一种方式</span>
<span style="color: rgba(0, 128, 128, 1)">276</span> <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">Self.OnPaint := Image1.OnPaint;</span>
<span style="color: rgba(0, 128, 128, 1)">277</span> <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">Button1.OnPaint := Image1.OnPaint;</span>
<span style="color: rgba(0, 128, 128, 1)">278</span> <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">Image1.Opacity := 0.75;</span>
<span style="color: rgba(0, 128, 128, 1)">279</span> <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">第2种方式</span>
<span style="color: rgba(0, 128, 128, 1)">280</span> <span style="color: rgba(0, 0, 0, 1)">Image1.Bitmap.SetSize(Round(Image1.Width), Round(Image1.Height));
</span><span style="color: rgba(0, 128, 128, 1)">281</span> <span style="color: rgba(0, 0, 0, 1)">Image1.Bitmap.Clear(TAlphaColors.White);
</span><span style="color: rgba(0, 128, 128, 1)">282</span> <span style="color: rgba(0, 0, 255, 1)">end</span><span style="color: rgba(0, 0, 0, 1)">;
</span><span style="color: rgba(0, 128, 128, 1)">283</span>
<span style="color: rgba(0, 128, 128, 1)">284</span> <span style="color: rgba(0, 0, 255, 1)">procedure</span><span style="color: rgba(0, 0, 0, 1)"> TForm1.Image1Paint(Sender: TObject; Canvas: TCanvas;
</span><span style="color: rgba(0, 128, 128, 1)">285</span> <span style="color: rgba(0, 0, 255, 1)">const</span><span style="color: rgba(0, 0, 0, 1)"> ARect: TRectF);
</span><span style="color: rgba(0, 128, 128, 1)">286</span> <span style="color: rgba(0, 0, 255, 1)">var</span>
<span style="color: rgba(0, 128, 128, 1)">287</span> <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">图片</span>
<span style="color: rgba(0, 128, 128, 1)">288</span> <span style="color: rgba(0, 0, 0, 1)">oBMP: TBitmap;
</span><span style="color: rgba(0, 128, 128, 1)">289</span> <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">路径</span>
<span style="color: rgba(0, 128, 128, 1)">290</span> <span style="color: rgba(0, 0, 0, 1)">oPath: TPathData;
</span><span style="color: rgba(0, 128, 128, 1)">291</span> <span style="color: rgba(0, 0, 0, 1)">MyRect1, MyRect2: TRectF;
</span><span style="color: rgba(0, 128, 128, 1)">292</span> <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">多边形</span>
<span style="color: rgba(0, 128, 128, 1)">293</span> <span style="color: rgba(0, 0, 0, 1)">p1, p2, p3, p4, p5, p6: TPointF;
</span><span style="color: rgba(0, 128, 128, 1)">294</span> MyPolygon: TPolygon; <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">System.Math.Vectors unit needed.</span>
<span style="color: rgba(0, 128, 128, 1)">295</span> <span style="color: rgba(0, 0, 255, 1)">begin</span>
<span style="color: rgba(0, 128, 128, 1)">296</span> <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">下面的代码是第二种方式,上面几个按钮事件是第一种方式。都可以</span>
<span style="color: rgba(0, 128, 128, 1)">297</span> <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">//图片</span>
<span style="color: rgba(0, 128, 128, 1)">298</span> <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">oBMP := TBitMap.Create;</span>
<span style="color: rgba(0, 128, 128, 1)">299</span> <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">oBMP.LoadFromFile('..\..\123.bmp');</span>
<span style="color: rgba(0, 128, 128, 1)">300</span> <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">//路径</span>
<span style="color: rgba(0, 128, 128, 1)">301</span> <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">MyRect1 := TRectF.Create(90, 100, 230, 300);</span>
<span style="color: rgba(0, 128, 128, 1)">302</span> <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">MyRect2 := TRectF.Create(70, 90, 220, 290);</span>
<span style="color: rgba(0, 128, 128, 1)">303</span> <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">oPath := TPathData.Create();</span>
<span style="color: rgba(0, 128, 128, 1)">304</span> <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">oPath.AddEllipse(MyRect1);</span>
<span style="color: rgba(0, 128, 128, 1)">305</span> <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">oPath.AddRectangle(MyRect2, 0, 0, AllCorners);</span>
<span style="color: rgba(0, 128, 128, 1)">306</span> <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">//多边形</span>
<span style="color: rgba(0, 128, 128, 1)">307</span> <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">p1 := TPointF.Create(80, 200);</span>
<span style="color: rgba(0, 128, 128, 1)">308</span> <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">p2 := TPointF.Create(225, 30);</span>
<span style="color: rgba(0, 128, 128, 1)">309</span> <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">p3 := TPointF.Create(370, 200);</span>
<span style="color: rgba(0, 128, 128, 1)">310</span> <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">p4 := TPointF.Create(300, 340);</span>
<span style="color: rgba(0, 128, 128, 1)">311</span> <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">p5 := TPointF.Create(150, 340);</span>
<span style="color: rgba(0, 128, 128, 1)">312</span> <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">p6 := TPointF.Create(80, 200);</span>
<span style="color: rgba(0, 128, 128, 1)">313</span> <span style="color: rgba(0, 128, 0, 1)">//
</span><span style="color: rgba(0, 128, 128, 1)">314</span> <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">SetLength(MyPolygon, 6);</span>
<span style="color: rgba(0, 128, 128, 1)">315</span> <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">MyPolygon := p1;</span>
<span style="color: rgba(0, 128, 128, 1)">316</span> <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">MyPolygon := p2;</span>
<span style="color: rgba(0, 128, 128, 1)">317</span> <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">MyPolygon := p3;</span>
<span style="color: rgba(0, 128, 128, 1)">318</span> <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">MyPolygon := p4;</span>
<span style="color: rgba(0, 128, 128, 1)">319</span> <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">MyPolygon := p5;</span>
<span style="color: rgba(0, 128, 128, 1)">320</span> <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">MyPolygon := p6;</span>
<span style="color: rgba(0, 128, 128, 1)">321</span> <span style="color: rgba(0, 128, 0, 1)">//
</span><span style="color: rgba(0, 128, 128, 1)">322</span> <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">Canvas.Stroke.Kind := TBrushKind.bkSolid;</span>
<span style="color: rgba(0, 128, 128, 1)">323</span> <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">Canvas.Stroke.Color := StrokeColor.Color;</span>
<span style="color: rgba(0, 128, 128, 1)">324</span> <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">Canvas.Fill.Color := FillColor.Color;</span>
<span style="color: rgba(0, 128, 128, 1)">325</span> <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">Canvas.Font.Size := 30;</span>
<span style="color: rgba(0, 128, 128, 1)">326</span> <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">//画直线</span>
<span style="color: rgba(0, 128, 128, 1)">327</span> <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">Canvas.DrawLine(ARect.Location, ARect.BottomRight, 1);</span>
<span style="color: rgba(0, 128, 128, 1)">328</span> <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">//画矩形; 集合 TCorners: 四个角是否使用指定的样式类型; 枚举 TCornerType: 角样式类型</span>
<span style="color: rgba(0, 128, 128, 1)">329</span> <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">Canvas.DrawRect(RectF(ARect.Width/4, ARect.Height/4, ARect.Width/4*2, ARect.Height/4*2), 0.5, 0.5, , 1, TCornerType.Round);</span>
<span style="color: rgba(0, 128, 128, 1)">330</span> <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">//画矩形边; 集合 TSides 指定要画的边</span>
<span style="color: rgba(0, 128, 128, 1)">331</span> <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">Canvas.DrawRectSides(RectF(ARect.Width/3, ARect.Height/3, ARect.Width/3*4, ARect.Height/3*4), 0.5, 0.5,, 1, , TCornerType.Round);</span>
<span style="color: rgba(0, 128, 128, 1)">332</span> <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">//画椭圆</span>
<span style="color: rgba(0, 128, 128, 1)">333</span> <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">Canvas.DrawEllipse(RectF(ARect.Width/2, ARect.Height/2, ARect.Width/2*2, ARect.Height/2*2), 1);</span>
<span style="color: rgba(0, 128, 128, 1)">334</span> <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">//画弧</span>
<span style="color: rgba(0, 128, 128, 1)">335</span> <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">Canvas.DrawArc(ARect.TopLeft, ARect.BottomRight/2, 40, 40, 1);</span>
<span style="color: rgba(0, 128, 128, 1)">336</span> <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">//画路径</span>
<span style="color: rgba(0, 128, 128, 1)">337</span> <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">Canvas.DrawPath(oPath, 200);</span>
<span style="color: rgba(0, 128, 128, 1)">338</span> <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">//画多边形</span>
<span style="color: rgba(0, 128, 128, 1)">339</span> <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">Canvas.DrawPolygon(MyPolygon, 50);</span>
<span style="color: rgba(0, 128, 128, 1)">340</span> <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">//图片</span>
<span style="color: rgba(0, 128, 128, 1)">341</span> <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">Canvas.DrawBitmap(oBMP,</span>
<span style="color: rgba(0, 128, 128, 1)">342</span> <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> RectF(0, 0, oBMP.Width, oBMP.Height),</span>
<span style="color: rgba(0, 128, 128, 1)">343</span> <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> RectF(100, 100, 100 + oBMP.Width, 100 + oBMP.Height),</span>
<span style="color: rgba(0, 128, 128, 1)">344</span> <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> 1);</span>
<span style="color: rgba(0, 128, 128, 1)">345</span>
<span style="color: rgba(0, 128, 128, 1)">346</span> <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">//填充矩形</span>
<span style="color: rgba(0, 128, 128, 1)">347</span> <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">Canvas.FillRect();</span>
<span style="color: rgba(0, 128, 128, 1)">348</span> <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">//填充椭圆</span>
<span style="color: rgba(0, 128, 128, 1)">349</span> <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">Canvas.FillEllipse(RectF(ARect.Width/2, ARect.Height/2, ARect.Width/2*2, ARect.Height/2*2), 1);</span>
<span style="color: rgba(0, 128, 128, 1)">350</span> <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">//填充弧</span>
<span style="color: rgba(0, 128, 128, 1)">351</span> <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">Canvas.FillArc(ARect.TopLeft, ARect.BottomRight/2, 40, 40, 1);</span>
<span style="color: rgba(0, 128, 128, 1)">352</span> <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">//填充路径</span>
<span style="color: rgba(0, 128, 128, 1)">353</span> <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">Canvas.FillPath(oPath, 200);</span>
<span style="color: rgba(0, 128, 128, 1)">354</span> <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">//填充多边形</span>
<span style="color: rgba(0, 128, 128, 1)">355</span> <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">Canvas.FillPolygon(MyPolygon, 50);</span>
<span style="color: rgba(0, 128, 128, 1)">356</span> <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">//文本输出</span>
<span style="color: rgba(0, 128, 128, 1)">357</span> <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">Canvas.FillText(ARect, 'TEST测试字符串', True, 1, [], TTextAlign.taLeading, TTextAlign.taCenter);</span>
<span style="color: rgba(0, 128, 128, 1)">358</span> <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">oBMP.Free</span>
<span style="color: rgba(0, 128, 128, 1)">359</span> <span style="color: rgba(0, 0, 255, 1)">end</span><span style="color: rgba(0, 0, 0, 1)">;
</span><span style="color: rgba(0, 128, 128, 1)">360</span>
<span style="color: rgba(0, 128, 128, 1)">361</span> <span style="color: rgba(0, 0, 255, 1)">procedure</span><span style="color: rgba(0, 0, 0, 1)"> TForm1.SetMYStyle;
</span><span style="color: rgba(0, 128, 128, 1)">362</span> <span style="color: rgba(0, 0, 255, 1)">begin</span>
<span style="color: rgba(0, 128, 128, 1)">363</span> oStyle.StrokeColor :=<span style="color: rgba(0, 0, 0, 1)"> StrokeColor.Color;
</span><span style="color: rgba(0, 128, 128, 1)">364</span> oStyle.StrokeThickness :=<span style="color: rgba(0, 0, 0, 1)"> StrToInt(StrokeThickness.Text);
</span><span style="color: rgba(0, 128, 128, 1)">365</span> <span style="color: rgba(0, 0, 255, 1)">case</span> StrokeCap.ItemIndex <span style="color: rgba(0, 0, 255, 1)">of</span>
<span style="color: rgba(0, 128, 128, 1)">366</span> <span style="color: rgba(128, 0, 128, 1)">0</span>: oStyle.StrokeCap :=<span style="color: rgba(0, 0, 0, 1)"> TStrokeCap.Flat;
</span><span style="color: rgba(0, 128, 128, 1)">367</span> <span style="color: rgba(128, 0, 128, 1)">1</span>: oStyle.StrokeCap :=<span style="color: rgba(0, 0, 0, 1)"> TStrokeCap.Round;
</span><span style="color: rgba(0, 128, 128, 1)">368</span> <span style="color: rgba(0, 0, 255, 1)">end</span><span style="color: rgba(0, 0, 0, 1)">;
</span><span style="color: rgba(0, 128, 128, 1)">369</span> <span style="color: rgba(0, 0, 255, 1)">case</span> StrokeDash.ItemIndex <span style="color: rgba(0, 0, 255, 1)">of</span>
<span style="color: rgba(0, 128, 128, 1)">370</span> <span style="color: rgba(128, 0, 128, 1)">0</span>: oStyle.StrokeDash :=<span style="color: rgba(0, 0, 0, 1)"> TStrokeDash.Solid;
</span><span style="color: rgba(0, 128, 128, 1)">371</span> <span style="color: rgba(128, 0, 128, 1)">1</span>: oStyle.StrokeDash :=<span style="color: rgba(0, 0, 0, 1)"> TStrokeDash.Dash;
</span><span style="color: rgba(0, 128, 128, 1)">372</span> <span style="color: rgba(128, 0, 128, 1)">2</span>: oStyle.StrokeDash :=<span style="color: rgba(0, 0, 0, 1)"> TStrokeDash.Dot;
</span><span style="color: rgba(0, 128, 128, 1)">373</span> <span style="color: rgba(128, 0, 128, 1)">3</span>: oStyle.StrokeDash :=<span style="color: rgba(0, 0, 0, 1)"> TStrokeDash.DashDot;
</span><span style="color: rgba(0, 128, 128, 1)">374</span> <span style="color: rgba(128, 0, 128, 1)">4</span>: oStyle.StrokeDash :=<span style="color: rgba(0, 0, 0, 1)"> TStrokeDash.DashDotDot;
</span><span style="color: rgba(0, 128, 128, 1)">375</span> <span style="color: rgba(128, 0, 128, 1)">5</span>: oStyle.StrokeDash :=<span style="color: rgba(0, 0, 0, 1)"> TStrokeDash.Custom;
</span><span style="color: rgba(0, 128, 128, 1)">376</span> <span style="color: rgba(0, 0, 255, 1)">end</span><span style="color: rgba(0, 0, 0, 1)">;
</span><span style="color: rgba(0, 128, 128, 1)">377</span> <span style="color: rgba(0, 0, 255, 1)">case</span> StrokeJoin.ItemIndex <span style="color: rgba(0, 0, 255, 1)">of</span>
<span style="color: rgba(0, 128, 128, 1)">378</span> <span style="color: rgba(128, 0, 128, 1)">0</span>: oStyle.StrokeJoin :=<span style="color: rgba(0, 0, 0, 1)"> TStrokeJoin.Miter;
</span><span style="color: rgba(0, 128, 128, 1)">379</span> <span style="color: rgba(128, 0, 128, 1)">1</span>: oStyle.StrokeJoin :=<span style="color: rgba(0, 0, 0, 1)"> TStrokeJoin.Round;
</span><span style="color: rgba(0, 128, 128, 1)">380</span> <span style="color: rgba(128, 0, 128, 1)">2</span>: oStyle.StrokeJoin :=<span style="color: rgba(0, 0, 0, 1)"> TStrokeJoin.Bevel;
</span><span style="color: rgba(0, 128, 128, 1)">381</span> <span style="color: rgba(0, 0, 255, 1)">end</span><span style="color: rgba(0, 0, 0, 1)">;
</span><span style="color: rgba(0, 128, 128, 1)">382</span> oStyle.FillColor :=<span style="color: rgba(0, 0, 0, 1)"> FillColor.Color;
</span><span style="color: rgba(0, 128, 128, 1)">383</span> oStyle.FontSize :=<span style="color: rgba(0, 0, 0, 1)"> StrToInt(FontSize.Text);
</span><span style="color: rgba(0, 128, 128, 1)">384</span>
<span style="color: rgba(0, 128, 128, 1)">385</span> Image1.Bitmap.Canvas.Stroke.Kind :=<span style="color: rgba(0, 0, 0, 1)"> TBrushKind.bkSolid;
</span><span style="color: rgba(0, 128, 128, 1)">386</span> Image1.Bitmap.Canvas.Stroke.Color :=<span style="color: rgba(0, 0, 0, 1)"> oStyle.StrokeColor;
</span><span style="color: rgba(0, 128, 128, 1)">387</span> Image1.Bitmap.Canvas.Stroke.Thickness :=<span style="color: rgba(0, 0, 0, 1)"> oStyle.StrokeThickness;
</span><span style="color: rgba(0, 128, 128, 1)">388</span> Image1.Bitmap.Canvas.Stroke.Cap :=<span style="color: rgba(0, 0, 0, 1)"> oStyle.StrokeCap;
</span><span style="color: rgba(0, 128, 128, 1)">389</span> Image1.Bitmap.Canvas.Stroke.Dash :=<span style="color: rgba(0, 0, 0, 1)"> oStyle.StrokeDash;
</span><span style="color: rgba(0, 128, 128, 1)">390</span> Image1.Bitmap.Canvas.Stroke.Join :=<span style="color: rgba(0, 0, 0, 1)"> oStyle.StrokeJoin;
</span><span style="color: rgba(0, 128, 128, 1)">391</span>
<span style="color: rgba(0, 128, 128, 1)">392</span> Image1.Bitmap.Canvas.Fill.Color :=<span style="color: rgba(0, 0, 0, 1)"> oStyle.FillColor;
</span><span style="color: rgba(0, 128, 128, 1)">393</span> Image1.Bitmap.Canvas.Font.Size :=<span style="color: rgba(0, 0, 0, 1)"> oStyle.FontSize;
</span><span style="color: rgba(0, 128, 128, 1)">394</span> Image1.Bitmap.Canvas.Font.Style :=<span style="color: rgba(0, 0, 0, 1)"> [];
</span><span style="color: rgba(0, 128, 128, 1)">395</span> <span style="color: rgba(0, 0, 255, 1)">end</span><span style="color: rgba(0, 0, 0, 1)">;
</span><span style="color: rgba(0, 128, 128, 1)">396</span>
<span style="color: rgba(0, 128, 128, 1)">397</span> <span style="color: rgba(0, 0, 255, 1)">procedure</span><span style="color: rgba(0, 0, 0, 1)"> TForm1.StrokeColorChange(Sender: TObject);
</span><span style="color: rgba(0, 128, 128, 1)">398</span> <span style="color: rgba(0, 0, 255, 1)">begin</span>
<span style="color: rgba(0, 128, 128, 1)">399</span> <span style="color: rgba(0, 0, 0, 1)">SetMYStyle;
</span><span style="color: rgba(0, 128, 128, 1)">400</span> <span style="color: rgba(0, 0, 255, 1)">end</span><span style="color: rgba(0, 0, 0, 1)">;
</span><span style="color: rgba(0, 128, 128, 1)">401</span>
<span style="color: rgba(0, 128, 128, 1)">402</span> <span style="color: rgba(0, 0, 255, 1)">end</span>.</pre>
</div>
<p> </p>
</div>
<div id="MySignature" role="contentinfo">
<div id="AllanboltSignature">
<div>作者:疯狂Delphi</div>
<div>出处:https://www.cnblogs.com/FKdelphi/</div>
<div>本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利.</div>
</div>
<div class="div_masklayer" id="div_masklayer"></div>
<div class="div_popup" id="Div_popup">
<p class="mid">欢迎关注我,一起进步!扫描下方二维码即可加我</p>
<img class="img_zfb" id="img_zfb" width="150" src="https://images.cnblogs.com/cnblogs_com/FKdelphi/1101510/o_251208113944_QQ.png">
<img class="img_zfb" id="img_zfb" width="150" src="https://images.cnblogs.com/cnblogs_com/FKdelphi/1101510/o_251208115029_WX.png">
</div><br><br>
来源:https://www.cnblogs.com/FKdelphi/p/12837201.html
頁:
[1]