unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Menus, ComCtrls, ExtCtrls, jpg, StdCtrls, Buttons, ExtDlgs;
type
TForm1 =
class(TForm)
StatusBar1: TStatusBar;
MainMenu1: TMainMenu;
Datei1: TMenuItem;
Neu1: TMenuItem;
ffnen1: TMenuItem;
Speichern1: TMenuItem;
Beenden1: TMenuItem;
Bearbeiten1: TMenuItem;
Hilfe1: TMenuItem;
SavePictureDialog1: TSavePictureDialog;
Panel1: TPanel;
LabeledEdit2: TLabeledEdit;
LabeledEdit1: TLabeledEdit;
BitBtn1: TBitBtn;
Image1: TImage;
OpenPictureDialog1: TOpenPictureDialog;
PopupMenu1: TPopupMenu;
est11: TMenuItem;
Kreise1: TMenuItem;
Quadrate1: TMenuItem;
Striche1: TMenuItem;
Dreiecke1: TMenuItem;
LabeledEdit3: TLabeledEdit;
est1: TMenuItem;
procedure Beenden1Click(Sender: TObject);
procedure Speichern1Click(Sender: TObject);
procedure ffnen1Click(Sender: TObject);
procedure Veraendern;
procedure BitBtn1Click(Sender: TObject);
procedure Neu1Click(Sender: TObject);
procedure Kreise1Click(Sender: TObject);
procedure Quadrate1Click(Sender: TObject);
procedure Striche1Click(Sender: TObject);
procedure Dreiecke1Click(Sender: TObject);
procedure Hilfe1Click(Sender: TObject);
procedure est1Click(Sender: TObject);
private
method:integer;
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
breite, hoehe,x,y:integer;
implementation
{$R *.dfm}
procedure TForm1.Beenden1Click(Sender: TObject);
begin
Close;
end;
procedure TForm1.Speichern1Click(Sender: TObject);
begin
If SavePictureDialog1.execute
then
Image1.Picture.SaveToFile(SavepictureDialog1.FileName);
end;
procedure TForm1.ffnen1Click(Sender: TObject);
begin
if Openpicturedialog1.Execute
then
begin
loadpicture(openpicturedialog1.FileName,image1,breite,hoehe);
Image1.Visible:=True;
end;
end;
procedure TForm1.Veraendern;
var
n,breite,hoehe,x,y,maxzahl,r,g:integer;
farbe:Tcolor;
begin
n:=0;
r:=StrtoInt(LabeledEdit2.Text);
g:=StrtoInt(LabeledEdit3.Text);
g:=round(g/360*1.7321);
maxzahl:=StrtoInt(LabeledEdit1.Text);
breite:=Image1.Picture.Width;
hoehe:=Image1.Picture.Height;
repeat
x:=random(breite);
y:=random(hoehe);
farbe:=Image1.Canvas.pixels[x,y];
Image1.Canvas.pen.color:=farbe;
Image1.Canvas.brush.color:=farbe;
case method
of
1: Image1.Canvas.ellipse(x-r,y-r,x+r,y+r);
2: Image1.Canvas.Rectangle(x-r,y-r,x+r,y+r);
3:
begin
Image1.Canvas.Polygon([Point(x-r,y-r), Point(x+r*g,y+r*g)]);
end;
5:
begin
r:=STRTOINT(LabeledEdit2.Text);
g:=STRTOINT(LabeledEdit3.text);
Image1.Canvas.Polygon([Point(x,y) , point(x+(x*round((sin(g)/2*pi)/sin(g))),y-r)]) ;
end;
4: Image1.Canvas.Polygon([Point(x-r,y), Point(x+r,y), Point(x,y-2*r)]);
end;
inc(n);
until n>=maxzahl;
Image1.Refresh;
end;
procedure TForm1.BitBtn1Click(Sender: TObject);
begin
Veraendern;
end;
procedure TForm1.Neu1Click(Sender: TObject);
begin
Image1.Visible:=False;
LabeledEdit1.Text:='
';
LabeledEdit2.Text:='
';
end;
procedure TForm1.Kreise1Click(Sender: TObject);
begin
begin method:=1;
LabeledEdit3.Visible:=False;
BitBtn1.Left:=304;
Kreise1.Checked:=True;
end;
end;
procedure TForm1.Quadrate1Click(Sender: TObject);
begin
begin method:=2;
LabeledEdit3.Visible:=False;
BitBtn1.Left:=304;
Quadrate1.Checked:=True;
end;
end;
procedure TForm1.Striche1Click(Sender: TObject);
begin
begin method:=3;
LabeledEdit3.Visible:=True;
BitBtn1.Left:=424;
Striche1.Checked:=True;
end;
end;
procedure TForm1.Dreiecke1Click(Sender: TObject);
begin
begin method:=4;
LabeledEdit3.Visible:=False;
BitBtn1.Left:=304;
Dreiecke1.Checked:=True;
end;
end;
procedure TForm1.Hilfe1Click(Sender: TObject);
begin
showmessage('
1. Bild öffnen, 2. Methode auswählen, 3. Werte für Radius, Wiederholungen und ggf. Grad bestimmen, 4. Button "Verändern" verwenden, 5. ggf. speichern');
end;
procedure TForm1.est1Click(Sender: TObject);
begin
begin method:=5;
LabeledEdit3.Visible:=True;
BitBtn1.Left:=424;
est1.Checked:=True;
end;
end;
end.