Sign in Join
Wiki copytemporary

Drawing with canvas/de

Deutsch · English · Français · 中文(中国)

Zurück zur Seite Code Beispiele.\

veröffentlicht von leo_tecnologica@yahoo.com.ar --- Leonardo Gabriel Calautti\

Beispiel: Der folgende Code zeichnet zwei Diagonalen auf dem Formular:

pascal
procedure TForm1.Form1Paint(Sender: TObject);
begin
  Canvas.Line(0, 0, Width-1, Height-1);
  Canvas.Line(0, Height-1, Width-1, 0);
end;

Wie kann man das Innere der Rechtecke und Ellipsen malen?
Im 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.
Um ein Objekt in einer Farbe zu malen müssen die Eigenschaften von Brush und Pen entsprechend angepasst werden.

pascal
   Canvas.Brush.Color := clRed;
   Canvas.Ellipse(195, 117, 205, 128);
   Canvas.Brush.Color:= clBlue;
   Canvas.Rectangle (192, 130,208,160);
   Canvas.Brush.Color:= clGreen;
   Canvas.Rectangle (187, 130,191,162);
   Canvas.Brush.Color:= clYellow;
   Canvas.Rectangle (209, 130,213,162);
   Canvas.Brush.Color:= clMaroon;
   Canvas.Rectangle (193,161,199,200);
   Canvas.Brush.Color:= clPurple;
   Canvas.Rectangle (201,161,207,200);

Falls Sie die obenstehenden Schritte nachvollzogen haben, dann sehen Sie folgendes Bild:


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.

Revision 2, last changed by WikiArchive .

Edited on wiki.freepascal.org by 4 people, 2014–2020

From the official wiki's backup of 26 May 2024: who edited this page there, and when. Edits made there after that date were not recorded, and the earlier versions are not shown here; the main page says why.

WhenWhoWhat changed
OlafCreated page
Olaf (minor)
FTurtle
WpEntferne Fehler (Formvariable im Form-Code, Zeichnen im OnClick-Ereignis)
TrevFixed syntax highlighting; deleted category included in page template (minor)

Talk about this page

Nobody has opened a bench for this page yet. Sign in to open one.