Sign in Join
Wiki copytemporary

Drawing with canvas/de: what changed

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

OldNewLine
1-\
21Zurück zur Seite [[code examples/de|Code Beispiele]].\
3-\
2+
43veröffentlicht von leo_tecnologica@yahoo.com.ar --- Leonardo Gabriel Calautti\
54* **Line** (x1, y1, x2, y2) -\> zieht eine Linie von Punkt (x1, y1) zu Punkt (x2, y2)\
65* **Rectangle** (x1, y1, x2, y2) -\> zeichnet ein Rechteck mit einem Scheitelpunkt ausgehend vom Punkt (x1, y1) und dem gegenüberliegenden Punkt (x2, y2)\
76* **Ellipse** (x1, y1, x2, y2) -\> zeichnet eine Ellipse in einem durch die Punkte (x1, y1) und (x2, y2) definierten Rechteck\
87![](/wiki-images/d/d7/Canvas2.png)
98
109Beispiel: Der folgende Code zeichnet zwei Diagonalen auf dem Formular:
1110
1211``` pascal
1312procedure TForm1.Form1Paint(Sender: TObject);
1413begin
1514 Canvas.Line(0, 0, Width-1, Height-1);
1615 Canvas.Line(0, Height-1, Width-1, 0);
1716end;
1817```
1918
2019Wie kann man das Innere der Rechtecke und Ellipsen malen?\
2120Im Canvas-Objekt, gibt es ein Objekt namens'' `Brush` (Pinsel) und ein Objekt namens `Pen` (Stift), beide haben Farbeigenschaften (`Color`) für die Fläche und die Kontur der Objekte.\
2221Um ein Objekt in einer Farbe zu malen müssen die Eigenschaften von `Brush` und `Pen` entsprechend angepasst werden.
2322
2423``` pascal
2524 Canvas.Brush.Color := clRed;
2625 Canvas.Ellipse(195, 117, 205, 128);
2726 Canvas.Brush.Color:= clBlue;
2827 Canvas.Rectangle (192, 130,208,160);
2928 Canvas.Brush.Color:= clGreen;
3029 Canvas.Rectangle (187, 130,191,162);
3130 Canvas.Brush.Color:= clYellow;
3231 Canvas.Rectangle (209, 130,213,162);
3332 Canvas.Brush.Color:= clMaroon;
3433 Canvas.Rectangle (193,161,199,200);
3534 Canvas.Brush.Color:= clPurple;
3635 Canvas.Rectangle (201,161,207,200);
3736```
3837
39-\
4038Falls Sie die obenstehenden Schritte nachvollzogen haben, dann sehen Sie folgendes Bild:\
4139![](/wiki-images/d/dd/Canvas.png)
4240
4341---
4442*From the Free Pascal wiki, page "Drawing with canvas/de", 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).*

Back to history