Autor Beitrag
axja
Hält's aus hier
Beiträge: 15



BeitragVerfasst: Mo 17.03.03 21:06 
gibt es in delphi die möglichkeit eine ganz primitive linie zu zeichnen? von einem punkt zu dem anderen? am besten noch in verschiedenen farben?
tommie-lie
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 4373

Ubuntu 7.10 "Gutsy Gibbon"

BeitragVerfasst: Mo 17.03.03 21:13 
kommt drauf an, worauf du zeichnen willst.
Einige Komponenten haben einen Canvas, auf den kann man malen. Such mal in der Hilfe nach Canvas, da findest du dann alles wichtige. PenPos und LineTo dürften interessant für dich sein. Pen und Brush sind für die Farben auch noch wichtig. Irgendwo hab' ich sogar mal eine Benutzung des kompletten Desktops (im Gegensatz zu einzelnen Komponenten wie der eigenen Form oder einem TImage) als Canvas gesehen, weiß aber nicht mehr wo.

_________________
Your computer is designed to become slower and more unreliable over time, so you have to upgrade. But if you'd like some false hope, I can tell you how to defragment your disk. - Dilbert
Tomac
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 113

Win XP
D6 Ent
BeitragVerfasst: Mo 17.03.03 21:15 
das geht mit der TImage Komponente

ausblenden Quelltext
1:
2:
3:
4:
image1.canvas.brush.color:=clblue;
image1.canvas.pen.color:=clred;
image1.canvas.moveto(10,10);
image1.canvas.lineto(100,100);


dieser Code zeichnet eine diagonale rote Linie auf blauem Hintergrund.

mfG
Tomac
tommie-lie
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 4373

Ubuntu 7.10 "Gutsy Gibbon"

BeitragVerfasst: Mo 17.03.03 21:27 
Ich habe doch gesagt, es kommt auf den Zweck drauf an.
Wenn ein oder zwei Linien reichen, braucht man kein TImage, weil die Form auch schon einen Canvas hat.

_________________
Your computer is designed to become slower and more unreliable over time, so you have to upgrade. But if you'd like some false hope, I can tell you how to defragment your disk. - Dilbert
MathiasH
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 699

WinXP, Win98SE, Debian, Win95
D5 Stand, D6 Prof
BeitragVerfasst: Mo 17.03.03 21:29 
Lo
nicht ganz tomac, damit malst du zwar die rote Linie, aber am Hintergrund ändert sich nichts 8) , du veränderst nur die Farbe des pinsels, um den Hintergrund auchnoch zu ändern müsste man beispielsweise ein Rechteck mit deisem Brush malen!!!

IO-sys/MathiasH

_________________
"Viel von sich reden, kann auch ein Mittel sein, sich zu verbergen."
Friedrich Nietzsche
Raphael O.
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1596


VS 2013
BeitragVerfasst: Mo 17.03.03 22:03 
stimmt nicht...
probiers doch aus:
mit
ausblenden Quelltext
1:
2:
canvas.moveto(x,y);
canvas.lineto(x2,y2);

zeichnet man eine linie ;)
Raphael O.
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1596


VS 2013
BeitragVerfasst: Mo 17.03.03 22:07 
sorry mein Fehler @MathiasH
Tomac
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 113

Win XP
D6 Ent
BeitragVerfasst: Di 18.03.03 15:16 
hast recht, sry, hab in der Eile wohl drauf vergessen.
tommie-lie
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 4373

Ubuntu 7.10 "Gutsy Gibbon"

BeitragVerfasst: Di 18.03.03 15:36 
axja? Gibt's auch Rückmeldung? Hat das jetzt geklappt mit dem Canvas, oder hast du was ganz anderes vor?

_________________
Your computer is designed to become slower and more unreliable over time, so you have to upgrade. But if you'd like some false hope, I can tell you how to defragment your disk. - Dilbert
Tomac
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 113

Win XP
D6 Ent
BeitragVerfasst: Di 18.03.03 15:41 
Linien mit der Maus zeichnen geht so:

ausblenden volle Höhe Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
var
  Form1: TForm1;
  x_Anfang, x_Ende, y_Anfang, y_Ende:integer;
  zeichnen: boolean;

{...}

procedure TForm1.FormCreate(Sender: TObject);
begin
doublebuffered:=true;
Image1.canvas.pen.mode:=pmNotXor; {dadurch erreicht man die Gummilinie!}
Image1.canvas.pen.style:=pssolid;
Image1.canvas.brush.style:=bsclear;
end;

procedure TForm1.Image1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
 x_anfang:=x; y_anfang:=y;
 x_ende:=x; y_ende:=y;
 zeichnen:=true;
end;

procedure TForm1.Image1MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
if zeichnen then
     with Image1.Canvas do
       begin
       moveto(x_anfang,y_anfang);
       lineto(x_ende,y_ende);
       x_ende:=x;
       y_ende:=y;
       moveto(x_anfang,y_anfang);
       lineto(x_ende,y_ende);
       end;
end;

procedure TForm1.Image1MouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
zeichnen:=false;
end;


mfG

EDIT: tommie_lie du bist immer ein bisschen schneller als ich :)