unit Unit12; { This software has been designed and it is CopyLefted by Han de Bruijn: (===) @-O^O-@ #/_\# ### } INTERFACE uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls, Grafisch; type TForm1 = class(TForm) Image1: TImage; procedure Toetsdruk(Sender: TObject; var Key: Char); procedure Scheppen(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; IMPLEMENTATION {$R *.dfm} const veel : integer = 100; procedure test(r : double); var a : double; tel : integer; OK : boolean; begin a := 1; tel := 0; while tel < veel do begin if a < r then begin a := a * 2; end else begin a := a / 3; end; tel := tel + 1; OK := (1/3 < a/r) and (a/r < 2); if not OK then Continue; with Form1.Image1.Canvas do begin MoveTo(x2i(a/r),y2j(0)); LineTo(x2i(a/r),y2j(1)); end; end; with Form1.Image1.Canvas do begin Pen.Color := clRed; Pen.Width := 2; MoveTo(x2i(1),y2j(0)); LineTo(x2i(1),y2j(1)); end; end; procedure proef(r : double); var a,l2,l3,lr : double; m,n,tel : integer; OK : boolean; begin l2 := ln(2); l3 := ln(3); lr := ln(r); m := 0; n := 0; tel := 0; while tel < veel do begin a := m*l2 - n*l3 - lr; if a < 0 then m := m + 1 else n := n + 1; tel := tel + 1; OK := (-ln(3) < a) and (a < ln(2)); if not OK then Continue; with Form1.Image1.Canvas do begin MoveTo(x2i(a),y2j(0)); LineTo(x2i(a),y2j(1)); end; end; with Form1.Image1.Canvas do begin Pen.Color := clRed; Pen.Width := 2; MoveTo(x2i(0),y2j(0)); LineTo(x2i(0),y2j(1)); end; end; procedure tekenen(wat : integer); begin with Form1.Image1.Canvas do begin Pen.Width := 1; Pen.Color := clBlack; end; if wat = 0 then test(0.001) else proef(0.001); with Form1.Image1.Canvas do begin Pen.Width := 2; Pen.Color := clYellow; MoveTo(x2i(xmin),y2j(0)); LineTo(x2i(xmax),y2j(0)); end; end; procedure TForm1.Toetsdruk(Sender: TObject; var Key: Char); { Inactive } begin xmin := -ln(3); xmax := ln(2); ClearDevice; tekenen(1); Form1.Image1.Picture.SaveToFile('logaritm.bmp'); end; procedure TForm1.Scheppen(Sender: TObject); { At moment of creation } begin xmin := 1/3; xmax := 2; ymin := -1 ; ymax := 2; TV(Form1.Image1); ClearDevice; tekenen(0); Form1.Image1.Picture.SaveToFile('original.bmp'); end; END.