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: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213:
| type TForm1 = class(TForm) Panel1: TPanel; Figur1: TButton; Figur2: TButton; Figur8: TButton; Figur3: TButton; Figur4: TButton; Figur5: TButton; Figur6: TButton; Figur7: TButton; Image1: TImage; FigurLoeschen: TButton; Abbrechen: TButton; Eingabe: TEdit; procedure FigurLoeschenClick(Sender: TObject); procedure AbbrechenClick(Sender: TObject); procedure Figur1Click(Sender: TObject); procedure Figur2Click(Sender: TObject); procedure Figur4Click(Sender: TObject); procedure Figur3Click(Sender: TObject);
private
procedure quadrat(x1,y1,l,ordnung1:integer); procedure quadrat2(x1,y1,l,ordnung:integer); procedure quadrat3(x1,y1,l,ordnung2:integer); procedure pv(r,th: real); procedure fraktaleLinie(ordnung: integer; l, th:real); procedure quadrat4(x1,y1,l,ordnung3:integer);
public end;
var Form1: TForm1;
implementation procedure Tform1.quadrat(x1,y1,l,ordnung1:integer); begin if ordnung1 = 0 then Image1.Canvas.Rectangle(x1,y1,x1+l,y1+l) else begin quadrat(x1,y1,l div 2, ordnung1-1); quadrat(x1+l div 2,y1,l div 2, ordnung1-1); quadrat(x1,y1+l div 2 ,l div 2,ordnung1-1); quadrat(x1+l div 2, y1+l div 2, l div 2, ordnung1-1);
end;
end; procedure TForm1.quadrat2(x1,y1,l,ordnung:integer); begin if ordnung = 0 then Image1.Canvas.Rectangle(x1,y1,x1+l,y1+l) else if ordnung=1 then begin quadrat2(x1,y1,l div 2, ordnung-1); quadrat2(x1+l div 2,y1,l div 2, ordnung-1); quadrat2(x1,y1+l div 2 ,l div 2,ordnung-1); quadrat2(x1+l div 2, y1+l div 2, l div 2, ordnung-1); end else begin quadrat2(x1,y1,l div 2,0) ; quadrat2(x1+l div 2,y1,l div 2, ordnung-1); quadrat2(x1,y1+l div 2 ,l div 2,ordnung-1); quadrat2(x1+l div 2, y1+l div 2, l div 2, 0); end; end;
procedure TForm1.quadrat3(x1,y1,l,ordnung2:integer); begin if ordnung2 = 0 then Image1.Canvas.Rectangle(x1,y1,x1+l,y1+l) else if odd(ordnung2) then begin quadrat3(x1,y1,l div 2, ordnung2-1) ; quadrat3(x1+l div 2,y1,l div 2, 0); quadrat3(x1,y1+l div 2 ,l div 2,0); quadrat3(x1+l div 2, y1+l div 2, l div 2,ordnung2-1);
end else begin quadrat3(x1,y1,l div 2, 0); quadrat3(x1+l div 2,y1,l div 2, ordnung2-1); quadrat3(x1,y1+l div 2 ,l div 2,ordnung2-1); quadrat3(x1+l div 2, y1+l div 2, l div 2, 0); end; end;
procedure Tform1.pv(r,th: real); var rad: real; begin rad := th*pi/180; with Image1.Canvas do lineTo(round(penpos.x + r*cos(rad)), round(penpos.y + r*sin(rad))); end;
procedure TForm1.fraktaleLinie(ordnung: integer; l, th:real); begin if ordnung = 0 then pv(l,th) else Begin fraktaleLinie(ordnung - 1, l,th); end; end;
procedure TForm1.quadrat4(x1,y1,l,ordnung3:integer); var l1,l2:integer; begin if ordnung3=0 then Image1.Canvas.Rectangle(x1,y1,x1+l,y1+l) else if odd(ordnung3) then begin quadrat4(x1,y1,l div 2, ordnung3-1) ; quadrat4(x1+l div 2,y1,l div 2, 0); quadrat4(x1,y1+l div 2 ,l div 2,0); quadrat4(x1+l div 2, y1+l div 2, l div 2,ordnung3-1)
end; end;
{$R *.dfm}
procedure TForm1.FigurLoeschenClick(Sender: TObject); begin Image1.canvas.Brush.Color:=clwhite; Image1.Canvas.Rectangle(-1,-1,image1.Width+1,image1.Height+1); end;
procedure TForm1.AbbrechenClick(Sender: TObject); begin close; end;
procedure TForm1.Figur1Click(Sender: TObject); VAR x,y,o:INTEGER; BEGIN Image1.Canvas.Rectangle(-1,-1,Image1.Width+1,image1.Height+1); Image1.Canvas.brush.Color:=clwhite; o:=Strtoint(Eingabe.text); x:=image1.Width; y:=image1.Height; IF image1.Height>Image1.Width THEN y:=image1.Width ELSE x:=image1.Height; image1.canvas.rectangle(0,0,0+x,0+x); quadrat(0,0,x,o);
end;
procedure TForm1.Figur2Click(Sender: TObject); VAR x,y,o:INTEGER; BEGIN Image1.Canvas.Rectangle(-1,-1,Image1.Width+1,image1.Height+1); Image1.Canvas.brush.Color:=clwhite; o:=Strtoint(Eingabe.text); x:=image1.Width; y:=image1.Height; IF image1.Height>Image1.Width THEN y:=image1.Width ELSE x:=image1.Height; image1.canvas.rectangle(0,0,0+x,0+x); quadrat2(0,0,x,o);
end;
procedure TForm1.Figur4Click(Sender: TObject); VAR x,y,o,ordnung,l,l1,l2:INTEGER; r:boolean; BEGIN Image1.Canvas.Rectangle(-1,-1,Image1.Width+1,image1.Height+1); Image1.Canvas.brush.Color:=clwhite; o:=Strtoint(Eingabe.text); x:=image1.Width; y:=image1.Height; IF image1.Height>Image1.Width THEN y:=image1.Width ELSE x:=image1.Height; image1.canvas.rectangle(0,0,0+x,0+x); ordnung:=4; l:=625; Image1.Canvas.moveTo(625, 150); Image1.canvas.pen.color:=clblack; fraktaleLinie(ordnung,L,0); fraktaleLinie(ordnung,L,90); fraktaleLinie(ordnung,L,180); fraktaleLinie(ordnung,L,270); Image1.Canvas.moveTo(625,250 ); l1:=round(sqrt(sqr(l/2)+sqr(l/2))); fraktaleLinie(ordnung,L1,-45); fraktaleLinie(ordnung,L1,45); fraktaleLinie(ordnung,L1,135); fraktaleLinie(ordnung,L1,-135); Image1.Canvas.moveTo(625 +l div 4, 250 - l div 4); l2:=round(sqrt(sqr(l1/2)+sqr(l1/2))); fraktaleLinie(ordnung,l1,45); Image1.Canvas.moveTo(625 +l div 4, 250 + l div 4); fraktaleLinie(ordnung,l1,-45);
end;
procedure TForm1.Figur3Click(Sender: TObject); VAR x,y,o:INTEGER; r:boolean; BEGIN Image1.Canvas.Rectangle(-1,-1,Image1.Width+1,image1.Height+1); Image1.Canvas.brush.Color:=clwhite; o:=Strtoint(Eingabe.text); x:=image1.Width; y:=image1.Height; IF image1.Height>Image1.Width THEN y:=image1.Width ELSE x:=image1.Height; image1.canvas.rectangle(0,0,0+x,0+x); quadrat3(0,0,x,o); end;
end. |