Autor Beitrag
Judil
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 32



BeitragVerfasst: Mi 18.01.06 16:45 
So hier mal die Frage genauer...
Ich will in einem Image ein ZUFÄLLIG großes Dreieck an einer ZUFÄLLIGEN Position zeichnen, aber das Problem was ich habe ist, dass das Dreieck mit einer Farbe gefüllt ist.
So hier mal mit der Variante RECHTECK

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
procedure TForm1.Button2Click(Sender: TObject);
var r1,r2,r3,r4,a,farbe:integer;
begin
For a:=1 to 1000 do
with image1.canvas do
begin
r1:=random(image1.width);
r2:=random(image1.height);
r3:=random(image1.width);
r4:=random(image1.height);
farbe:=random($FFFFFF);
pen.color:=farbe;
brush.color:=farbe;
rectangle(r1,r2,r3,r4);
end;
end;


Solche kann ich ja mit MoveTo und LineTo
[url=img64.imageshack.us/...e=unbenannt2eq1.jpg]user defined image[/URL]

So sollte es ausehen
[url=img80.imageshack.us/...e=unbenannt17hy.jpg]user defined image[/URL]

das selbe brauch ich für Dreiecke

Also gibt es einen Befehl für Dreiecke, sowie RECTANGLE???

GEIL WÄRE AUCH WENN MIR JEMAND SAGEN KÖNNTE , WIE ICH ES STATT MIT EINER FARBE GEFÜLLT MACHE MIT EINEN FARBÜBERLAUF

Ein Quelltext wär nicht schlecht, brauche es bis Sonntag , wenns geht...

Und ich benutze Delphi 5 , nur so zur INFO

Bitte genaue Erklärungen , da ich mich recht wenig auskenne, mache nur SChultechnisch Informathik

Moderiert von user profile iconGausi: Quote- durch Delphi-Tags ersetzt und Titel geändert (hier ist alles wichtig).
Moderiert von user profile iconChristian S.: Topic aus Sonstiges (Delphi) verschoben am Mi 18.01.2006 um 17:08
Tastaro
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 414
Erhaltene Danke: 23



BeitragVerfasst: Mi 18.01.06 17:02 
Hallo,

guck dir mal in der Delphi-Hilfe die Methode polygon der Klasse TCanvas an. Die kann genau das tun, was du möchtest.

Beste Grüße
Tastaro
Blackheart666
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2195

XP
D3Prof, D6Pers.
BeitragVerfasst: Mi 18.01.06 17:03 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
procedure TForm1.Button1Click(Sender: TObject);
var
  P : array [0..2] of TPoint;
begin
  Canvas.Brush.Color := clred;
  Canvas.Pen.Width   := 2;
  Canvas.Pen.Color   := clBlack;
  P[0] := Point(200,20);
  P[1] := Point(10,200);
  P[2] := Point(400,200);
  Canvas.Polygon(P);
end;
Judil Threadstarter
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 32



BeitragVerfasst: Mi 18.01.06 17:28 
cool danke werde es mal gleich ausprobieren
geiles forum hier, bin hier durch google draufgekommen
im anderen forum , wo ich zuerst war wurde dieser beitrag gesperrt
kp , warum war sowieso *mist*e

naja egal, wenn ich weitere hilfe meld ich mich :wink2: :les:

Edit:
Noch ne Frage , habe es Soweit verstanden nur , was bedeutet
Zitat:
P : array [0..2] of TPoint;


Noch ne Wichtige Frage wie kann ich das in eine For-Schleife einbinden???
Judil Threadstarter
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 32



BeitragVerfasst: Mi 18.01.06 21:39 
Wie kann ich das Polygon in eine For-Schleife einbinden???
Du hattest den Quelltext ja gepostet?

Wollte das so machen
ausblenden Delphi-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:
procedure TForm1.Button1Click(Sender: TObject);
var a,r1,r2,r3,r4,r5,r6,farbe:integer;
For a=1 to 1000 do
begin
with image1.Canvas do
var
  P : array [0..2] of TPoint;
begin
  r1:=random(image1.width);
  r2:=random(image1.height);
  r3:=random(image1.width);
  r4:=random(image1.height);
  r5:=random(image1.width);
  r6:=random(image1.height);
  farbe:=random($FFFFFF);
  pen.color:=farbe;
  brush.color:=farbe;
  Pen.Width   := 2;
  P[0] := Point(r1,r2);
  P[1] := Point(r3,r4);
  P[2] := Point(r5,r6);
  Polygon(P);
end;
end;


geht aber nicht warum???

Moderiert von user profile iconGausi: Quote- durch Delphi-Tags ersetzt
LH_Freak
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 385

Win XP
D7 PE, D2k5 Trial
BeitragVerfasst: Mi 18.01.06 21:50 
ausblenden Delphi-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:
procedure TForm1.Button1Click(Sender: TObject);
var a,r1,r2,r3,r4,r5,r6,farbe:integer;
    P : array [0..2] of TPoint;
begin
 For a:= 1 to 1000 do
   begin
     with image1.Canvas do
       begin
         r1:=random(image1.width);
         r2:=random(image1.height);
         r3:=random(image1.width);
         r4:=random(image1.height);
         r5:=random(image1.width);
         r6:=random(image1.height);
         farbe:=random($FFFFFF);
         pen.color:=farbe;
         brush.color:=farbe;
         Pen.Width   := 2;
         P[0] := Point(r1,r2);
         P[1] := Point(r3,r4);
         P[2] := Point(r5,r6);
         Polygon(P);
       end;
   end;
end;


So müsste es gehen. Hab's nicht getestet, hab nur deinen Quelltext umgestellt!
Judil Threadstarter
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 32



BeitragVerfasst: Mi 18.01.06 21:55 
jo war nur zu doof, weißt du zufällig statt einer gefüllten farbe , sonern mit farbüblauf von rot nach blau oder so


und wie kann ich ich , das machen, das das der inhalt von image1 gelöscht wieder, also sozusagen, bei erneuten kilck , es wieder zurückgestzt wird

und wie kann ich sounds einbauen????


Was natürlich der Hammer wäre, wenn ich ein Edit Fenster habe, wo ich die Anzahl der Ecken eintragen könnte, und der Rest so bleibt
delfiphan
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2684
Erhaltene Danke: 32



BeitragVerfasst: Do 19.01.06 01:57 
Farbüberläufe werden nicht direkt unterstützt. Das müsstest du selbst programmieren (Es sei denn du verwendest OpenGL oder andere Bibliotheken, die sowas unterstützen)
LH_Freak
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 385

Win XP
D7 PE, D2k5 Trial
BeitragVerfasst: Do 19.01.06 16:05 
Wie du einen Farbverlauf zeichnen kannst in Delphi steht hier: www.dsdt.info/tipps/?id=334