| Autor |
Beitrag |
Funnygirly
Hält's aus hier
Beiträge: 7
|
Verfasst: Mo 24.05.10 10:27
Hallo,
ich habe es mittlerweile geschafft ein Haus zu zeichnen....jetzt muss ich aber noch mehrere zeichnen lassen, die dann im Zufallsprinzip auf der Canvas erscheinen. Ich weiß aber nicht wie ich das machen soll....kann mir jemand helfen?
Lg
|
|
Gausi
      
Beiträge: 8554
Erhaltene Danke: 480
Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
|
Verfasst: Mo 24.05.10 10:31
Hallo,
Da stellt sich erstmal die Frage: Wie zeichnest du das eine Haus? Wenn du eine Prozedur hast wie
procedure ZeichneHaus(Target: Canvas; x, y: integer);, die das Haus auf dem Canvas an Position x/y zeichnet, kann man mit Hilfe von Random sehr leicht gemacht werden, z.B. so:
Delphi-Quelltext 1: 2:
| for i := 1 to 5 do ZeichneHaus(canvas, random(800), random(600)); |
_________________ We are, we were and will not be.
|
|
Funnygirly 
Hält's aus hier
Beiträge: 7
|
Verfasst: Mo 24.05.10 10:51
Mein Haus sieht so aus:....
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: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82:
| unit uHaus;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls;
type TForm1 = class(TForm) Image1: TImage; Button1: TButton; procedure Button1Click(Sender: TObject); private public end;
var Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject); procedure zeichne_Haus(x,y : integer; a : real); var i:integer; begin with Image1.Canvas do moveTo(x,y-round(a*3.5)); lineTo(x,y); lineTo(x+round(4*a),y); lineTo(x+round(4*a),y-round(3.5*a)); moveTo(x-round(a*1),y-round(a*2.5)); lineTo(x+round(a*2),y-round(a*5.5)); lineTo(x+round(5*a),y-round(2.5*a)); moveTo(x+round(a*0.5),y); lineTo(x+round(a*0.5),y-round(a*2.5)); lineTo(x+round(a*1.5),y-round(a*2.5)); lineTo(x+round(a*1.5),y); moveTo(x+round(a*2),y-round(a*1)); lineTo(x+round(a*3.5),y-round(a*1)); lineTo(x+round(a*3.5),y-round(a*2.5)); lineTo(x+round(a*2),y-round(a*2.5)); lineTo(x+round(a*2),y-round(a*1)); moveTo(x+round(a*2),y-round(a*1.5)); lineTo(x+round(a*3.5),y-round(a*1.5)); moveTo(x+round(a*2),y-round(a*2)); lineTo(x+round(a*3.5),y-round(a*2)); moveTo(x+round(a*2.5),y-round(a*2.5)); lineTo(x+round(a*2.5),y-round(a*1)); moveTo(x+round(a*3),y-round(a*2.5)); lineTo(x+round(a*3),y-round(a*1)); moveTo(x+round(a*1.5),y-round(a*3.5)); lineTo(x+round(a*2.5),y-round(a*3.5)); lineTo(x+round(a*2.5),y-round(a*4.5)); lineTo(x+round(a*1.5),y-round(a*4.5)); lineTo(x+round(a*1.5),y-round(a*3.5)); moveTo(x+round(a*2),y-round(a*4.5)); lineTo(x+round(a*2),y-round(a*3.5)); moveTo(x+round(a*1.5),y-round(a*4)); lineTo(x+round(a*2.5),y-round(a*4)); moveTo(x+round(a*1),y-round(a*4.5)); lineTo(x+round(a*1),y-round(a*6)); lineTo(x+round(a*1.5),y-round(a*6)); lineTo(x+round(a*1.5),y-round(a*5)); end; end;
begin zeichne_Haus(300,500,70); end;
end. |
vll kann ich dies ein bisschen kleiner noch machen und dann noch mehrere davon? wie mache ich das dann hier?
Moderiert von Gausi: Delphi-Tags hinzugefügt
|
|
Tryer
      
Beiträge: 226
Erhaltene Danke: 7
|
Verfasst: Mo 24.05.10 10:57
Wenn auch nur eine Zeile davon von dir wäre wüsstest du das.
www.hsg-kl.de/faeche...rafik/haus/index.php
Grüsse, Dirk
|
|
Gausi
      
Beiträge: 8554
Erhaltene Danke: 480
Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
|
Verfasst: Mo 24.05.10 11:03
Na, dann schau dir einfach nochmal mein Posting von eben an und pass das minimal an. Die kopierte Prozedur hat halt keinen Parameter für die Zeichenfläche, auf der das Haus entstehen soll, sondern für die Größe, wenn ich das richtig überblicke.
_________________ We are, we were and will not be.
|
|
Funnygirly 
Hält's aus hier
Beiträge: 7
|
Verfasst: Mo 24.05.10 11:08
@Tryer. stimmt dann wüsste ich dass wahrscheinlich, aber da ich eh nicht so gut mit Delphi umgehen kann und orgen die Arbeit schreib hab ich mir eben schnell eine Haus aus dem inet geshcnappt und versuche dass so anzupassen, wie ichs brauche, weil ich keine zeit mehr habe, denn ich muss noch des mit den Variablenparametern,des Hus, Arrays, Binärcode und noch andere Grafiksachen erlernen bis morgen. Ich mein ich mach ja schon ne ganze Zeit lang was dafür, is trotzdem net so einfach. Ich kann mit Delphi irgendwie net umgehn. Ich dachte älich eigentlich, dass wir in der 11 HTML und programmieren und sowas machen aba doch kein Delphi...^^
@Gausi: okay ich probiere es mal  danke  wie mach ich das eigentlich, dass des in so nem Quelltext angezeigt wird?
|
|
jaenicke
      
Beiträge: 19339
Erhaltene Danke: 1752
W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
|
Verfasst: Mo 24.05.10 11:18
|
|
Funnygirly 
Hält's aus hier
Beiträge: 7
|
Verfasst: Mo 24.05.10 11:30
|
|
|