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



BeitragVerfasst: Mo 23.01.06 13:19 
Mein Problem ist, dass ich jetzt ein Polygon hab was mir ein zufällig großes Dreieck mit zufälliger Farbe liefert. Funktiniert auch alles.
Ich will jetzt aber ein Edit-Fenster haben, wo ich die Anzahl der Ecken reinschreiben kann.
Muss ich dann für jede einzelne Ecke
if edit=1 then Polygon.....

nein oder , bräuchte sehr schnelle hilfe, weil ich es für morgen brauche


ausblenden volle Höhe 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:
26:
27:
28:
29:
30:
31:
32:
procedure TForm1.BitBtn4Click(Sender: TObject);
var a,r1,r2,r3,r4,r5,r6,farbe:integer;
    P : array [0..2] of TPoint;

    begin
    SndPlaySound( 'tada.WAV', SND_ASYNC );

    image1.picture:=nil;

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;
end;




DANKE
Kroko
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1284

W98 W2k WXP
Turbo D
BeitragVerfasst: Mo 23.01.06 13:24 
Bei dir werde ich das Gefühl nicht los, Du schlauchst Dir hier schulische Leistungen zusammen, gib mir doch mal die Email Deines Lehrers :cry:
Und genau deswegen bist Du auch aus dem anderen Forum geflogen!
Tipps zu deinem Problem:

(1) dynamische Arrays und
(2) schleifen

_________________
Die F1-Taste steht nicht unter Naturschutz und darf somit regelmäßig und oft benutzt werden! oder Wer lesen kann, ist klar im Vorteil!
Judil Threadstarter
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 32



BeitragVerfasst: Mo 23.01.06 14:04 
Nein, so ist es nicht der benotet sachen die wir zuhause machen eh nicht, weil der sich sowas denkt. Aber das mit den Tipps hilft mir schon etwas weiter :D

Das Programm verbesser ich nur ständing und erweiter es , damit ich Delphi besser versteh , bin aus dem anderen Forum aus nem Anderen Grund geflogen.

Naja Übung macht den Meister...


Danke trotzdem :P
Kroko
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1284

W98 W2k WXP
Turbo D
BeitragVerfasst: Mo 23.01.06 14:27 
Titel: Q
na gut :roll:

noch einen tipp
ausblenden Delphi-Quelltext
1:
2:
  for J := 0 to 2 // anzahl der Punkte in P
    P[J] := Point (random(image1.width),random(image1.height));

spart 'ne Menge Quelltext;

_________________
Die F1-Taste steht nicht unter Naturschutz und darf somit regelmäßig und oft benutzt werden! oder Wer lesen kann, ist klar im Vorteil!
LLCoolDave
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 212

Win XP
Delphi 2005
BeitragVerfasst: Mo 23.01.06 14:43 
Geht auch gut ohne dynamische Arrays, ist halt nicht gefüllt, aber was solls :P

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
procedure TForm1.Button1Click(Sender: TObject);
var i,j,k: integer;
begin
Randomize;
i := Random(Image1.Width);
j := Random(Image1.height);
image1.Canvas.Moveto(i,j);
for k:= 2 to StrtoInt(Edit1.text) do
image1.Canvas.Lineto(Random(Image1.Width),Random(Image1.height));
image1.Canvas.LineTo(i,j);
end;
Judil Threadstarter
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 32



BeitragVerfasst: Mo 23.01.06 17:16 
Das von LLCoolDAve hilft mir nicht so weiter, aber das von Kroko
Fettes Danke an Kroko, an sowas ähnliches hatte ich auch schon gedacht
Ich finde, das Forum echt Geil

DANKE

Werds mal ausprobieren
Judil Threadstarter
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 32



BeitragVerfasst: Mo 23.01.06 17:49 
Habs Probiert einzubauen, aber diese Zeile macht Probleme, aber warum???
P : array [0..Punkte] of TPoint;

Hier der ganze Quelltext

ausblenden volle Höhe 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:
26:
27:
28:
29:
30:
31:
32:
33:
var a,r1,r2,r3,r4,r5,r6,farbe,code,Anzahl,Ecken,Punkte:integer;
    P : array [0..Punkte] of TPoint;

    begin
    SndPlaySound( 'tada.WAV', SND_ASYNC );

    image1.picture:=nil;

begin
val(Form1.Edit1.Text,Anzahl,code);
val(Form1.Edit2.Text,Ecken,code);
 For a:= 1 to Anzahl 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;

         for Punkte := 0 to Ecken do
         P[Punkte] := Point (random(image1.width),random(image1.height));
         Polygon(P);
       end;
   end;
end;
end;
Kroko
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1284

W98 W2k WXP
Turbo D
BeitragVerfasst: Mo 23.01.06 18:13 
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:
const
  coMaxPkte = 10;

var 
  a,J,farbe,code,
  Anzahl,Ecken: Integer;
  P : array [0..coMaxPkte] of TPoint;

begin
  val(Form1.Edit1.Text,Anzahl,code);
  val(Form1.Edit2.Text,Ecken,code);
  For a:= 1 to Anzahl do
  begin
    with image1.Canvas do
    begin
      for J := 0 to Ecken-1 do
        P[J] := Point (Random(image1.width),random(image1.height));
      farbe:=random($FFFFFF);
      pen.color:=farbe;
      brush.color:=farbe;
      Pen.Width   := 2;
      Polygon(Slice (P,Ecken));
    end;
  end;
end;

ungetestet und ohne dynamische Arrays

_________________
Die F1-Taste steht nicht unter Naturschutz und darf somit regelmäßig und oft benutzt werden! oder Wer lesen kann, ist klar im Vorteil!
Judil Threadstarter
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 32



BeitragVerfasst: Mo 23.01.06 18:36 
habs ausprobiert klappt nicht, wär cool , wenn einer das berichtgt , muss aber nicht sein
Kroko
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1284

W98 W2k WXP
Turbo D
BeitragVerfasst: Mo 23.01.06 19:26 
der Code geht einwandfrei, aber wenn die Punkte nicht in der richtigen Reihenfolge liegen, dann gibt es zBsp. bei 4 Ecken ein gefülltes X :!:

_________________
Die F1-Taste steht nicht unter Naturschutz und darf somit regelmäßig und oft benutzt werden! oder Wer lesen kann, ist klar im Vorteil!
Judil Threadstarter
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 32



BeitragVerfasst: Mo 23.01.06 19:31 
das WAR WOHL MEIN pROBLEM UND ICH AHTE WAS VERGESSEN

Cool und danke für deine geduld