Einzelnen Beitrag anzeigen

Benutzerbild von spox
spox

Registriert seit: 23. Sep 2007
47 Beiträge
 
Delphi 7 Personal
 
#6

Re: Windmühle, bei der die Flügelanzahl variabel ist

  Alt 28. Okt 2007, 16:07
Das wäre mein nächster Schritt
Doch zunächst muss ich erstmal die Windräder hinkriegen. Und es will einfach nicht... Ich habe Apollonius Tipp befolgt, da meine Flügel keine Dreiecke, sondern einfach nur Striche sein sollen. Mein Programmcode sieht jetzt wie folgt aus:
Delphi-Quellcode:
unit muehleU;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, StdCtrls;

const
 pi=3.1415;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Image1: TImage;
    procedure Button1Click(Sender: TObject);
    procedure Muehle(anzahl,hoehe,x,y:integer);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
 Muehle (4,150,50,50);
end;

procedure TForm1.Muehle (anzahl,hoehe,x,y:integer);
var flange,nr,bm,x2,y2, FluegelEndPunktX, FluegelEndPunktY:integer;
begin
 with Image1.Canvas do
  begin
   moveTo (x,y);
   rectangle (x,y,x+round(hoehe/5),hoehe);
   moveTo (x+(round(hoehe/5)DIV 2),y+10);
   x2:= x+(round(hoehe/5)DIV 2);
   y2:= y+10;
   flange:= hoehe DIV 2 ;
   bm:= round((2*pi) / anzahl);
   for nr:= 1 to anzahl do
   begin
   FluegelEndPunktX:=(hoehe DIV 10)+round(Cos(bm*nr));
   FluegelEndPunktY:=60+round(Sin(bm*nr));
   //lineTo (round(flange*cos(bm*nr)+(hoehe DIV 10)),round(-flange*sin(bm*nr)+60));
   lineTo (FluegelEndPunktX,FluegelEndPunktY);
   moveTo (x2,y2);
   end;
  end;
end;

end.
  Mit Zitat antworten Zitat