Sign in Join
Wiki copytemporary

Drawing with canvas/zh CN: what changed

Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.

Title: Drawing with canvas/zh CN

OldNewLine
1+leo_tecnologica@yahoo.com.ar 发布 —— Leonardo Gabriel Calautti
2+
3+**Line** (x1, y1, x2, y2)-\> 从(x1,y1)到(x2,y2)画线
4+
5+**Rectangle** (x1, y1, x2, y2)-\> 从(x1,y1)点到(x2,y2)点画矩形
6+
7+**Ellipse** (x1, y1, x2, y2)-\> 从(x1,y1)点到(x2,y2)点画椭圆
8+
9+<figure>
10+<img src="canvas2.png" title="canvas2.png" />
11+<figcaption>canvas2.png</figcaption>
12+</figure>
13+
14+如,下面的代码,将绘制对角线,在Button1Click间:
15+
16+``` pascal
17+procedure TForm1.Button1Click(Sender: TObject);
18+begin
19+ canvas.Line(0,0, form1.Width,form1.Height);
20+ canvas.Line(0,form1.height,form1.width,0);
21+end;
22+```
23+
24+如何绘制矩形和椭圆在里面使用**Rectangle**和**Ellipse**;在调用Brush和Pen时,使用color设置颜色,该属性给绘制对象填充、线条的颜色。在绘制前,顺序很重要:
25+
26+``` pascal
27+ canvas.Brush.color:= clred;
28+ canvas.Ellipse(195, 117, 205, 128);
29+ canvas.Brush.color:= clblue;
30+ canvas.Rectangle (192, 130,208,160);
31+ canvas.Brush.color:= clgreen;
32+ Canvas.Rectangle (187, 130,191,162);
33+ canvas.Brush.color:= clyellow;
34+ Canvas.Rectangle (209, 130,213,162);
35+ canvas.Brush.color:= clmaroon;
36+ Canvas.Rectangle (193,161,199,200);
37+ canvas.Brush.color:= clpurple;
38+ Canvas.Rectangle (201,161,207,200);
39+```
40+
41+如果按着步骤,你可以做到:
42+
43+<figure>
44+<img src="canvas3.png" title="canvas3.png" />
45+<figcaption>canvas3.png</figcaption>
46+</figure>
47+
48+[[Graphics/zh CN|上一页]]
49+
50+---
51+*From the Free Pascal wiki, page "Drawing with canvas/zh CN", as it stood on 2020-02-14 after a change by Trev, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*
52+Category: zh

Back to history