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:
| unit UNT_julia_1; interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Buttons, ExtCtrls, ComCtrls, jpeg;
type TFRM_apfelmann_1 = class(TForm) BTN_zeichnen: TBitBtn; BTN_close: TBitBtn; EDT_xmax: TEdit; EDT_ymin: TEdit; EDT_xmin: TEdit; EDT_ymax: TEdit; EDT_kmax: TEdit; EDT_rmax: TEdit; BTN_Drucken: TBitBtn; BTN_Speichern: TBitBtn; SaveDialog1: TSaveDialog; PGB_dyn: TProgressBar; PrintDialog1: TPrintDialog; IMG_Layout: TImage; LBL_ymin: TLabel; LBL_ymax: TLabel; LBL_xmin: TLabel; LBL_xmax: TLabel; LBL_kmax: TLabel; LBL_fluchtgrenze: TLabel; procedure BTN_closeClick(Sender: TObject); procedure BTN_zeichnenClick(Sender: TObject); procedure FormMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); procedure FormMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); procedure FormMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); procedure FormCreate(Sender: TObject); procedure BTN_SpeichernClick(Sender: TObject); procedure BTN_DruckenClick(Sender: TObject); private public end;
var FRM_apfelmann_1: TFRM_apfelmann_1;
implementation
{$R *.dfm}
var x_bild,y_bild,kmax,k,rmax,xo,xu,yl,yr : integer; x,xalt,y,dx,dy,creal,cimag : real; xmax,xmin,ymax,ymin : real; md : boolean;
procedure TFRM_apfelmann_1.BTN_closeClick(Sender: TObject); begin close; end;
procedure iteration(x_bild,y_bild: integer); begin x := xmin + x_bild*dx; y := ymax - y_bild*dy; creal := (x_bild) *dx+xmin; cimag := (400-y_bild) *dy+ymin; k := 0; repeat xalt := x; x := sqr(x) - sqr(y) + creal; y := 2*xalt*y + cimag; inc(k); until (sqr(x)+sqr(y)>rmax) or (k>kmax); if k >= kmax then k:=0; FRM_apfelmann_1.canvas.pixels[x_bild+152,y_bild+35] := 16000000div(k+1); end;
procedure TFRM_apfelmann_1.BTN_zeichnenClick(Sender: TObject); begin xmax := strtofloat(EDT_xmax.text); xmin := strtofloat(EDT_xmin.text); ymax := strtofloat(EDT_ymax.text); ymin := strtofloat(EDT_ymin.text); kmax := strtoint(EDT_kmax.text); rmax := strtoint(EDT_rmax.Text); dx := (xmax-xmin)/600; dy := (ymax-ymin)/400; PGB_dyn.Step := 1; PGB_dyn.position := 0;
for x_bild := 0 to 539 do for y_bild := 0 to 400 do iteration (x_bild,y_bild); end;
procedure TFRM_apfelmann_1.FormMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); var a,b : real; begin a := xmin + (x-152)*(xmax-xmin)/539; b := ymax - (y-35)*(ymax-ymin)/400; EDT_xmin.Text := floattostrf(a,fffixed,10,8); EDT_ymax.Text := floattostrf(b,fffixed,10,8); xo := x; yl := y; xu := x; yr := y; md := true; end;
procedure TFRM_apfelmann_1.FormMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin md := false; end;
procedure TFRM_apfelmann_1.FormMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); var a,b : real; begin if md then begin a := xmin + (x-152)*(xmax-xmin)/539; b := ymax - (y-35)*(ymax-ymin)/400; EDT_xmax.Text := floattostrf(a,fffixed,10,8); EDT_ymin.Text := floattostrf(b,fffixed,10,8); canvas.Pen.Mode := pmnotxor; canvas.Rectangle(xo,yl,xu,yr); canvas.Rectangle(xo,yl,x,y); canvas.Pen.Mode := pmcopy; xu := x; yr := y; end; end;
procedure TFRM_apfelmann_1.FormCreate(Sender: TObject); begin md := false;
if SaveDialog1.Execute then with TBitmap.Create do try PixelFormat := pf32bit; Width := PaintBox1.Width; Height := PaintBox1.Height; Canvas.CopyRect(Rect(0, 0, Width, Height), PaintBox1.Canvas, Rect(0, 0, PaintBox1.Width, PaintBox1.Height)); SaveToFile(SaveDialog1.FileName); finally Free; end;
end;
end;
procedure TFRM_apfelmann_1.BTN_SpeichernClick(Sender: TObject); begin SaveDialog1.Execute; end;
procedure TFRM_apfelmann_1.BTN_DruckenClick(Sender: TObject); begin
PrintDialog1.Execute;
end;
end. |