unit Unit9; { 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} function macht(x,y : double) : double; { x^y } begin macht := exp(y*ln(x)); end; procedure one; { Functions y=x^c } const waarde : array[0..12] of double = (-3,-2,-1,-0.5,-0.25,0,0.25,0.5,0.75,1,1.5,2,3); var k,i : integer; x,y,c : double; begin with Form1.Image1.Canvas do begin Pen.Color := clYellow; Pen.Width := 2; MoveTo(x2i(xmin),y2j(0)); LineTo(x2i(xmax),y2j(0)); MoveTo(x2i(0),y2j(ymin)); LineTo(x2i(0),y2j(ymax)); MoveTo(x2i(xmin),y2j(1)); LineTo(x2i(xmax),y2j(1)); MoveTo(x2i(1),y2j(ymin)); LineTo(x2i(1),y2j(ymax)); end; for k := 0 to Length(waarde)-1 do begin c := waarde[k]; if c > 0 then begin Form1.Image1.Canvas.MoveTo(x2i(0),y2j(0)); Form1.Image1.Canvas.Pen.Color := clBlue; end; if c = 0 then begin Form1.Image1.Canvas.MoveTo(x2i(0),y2j(1)); Form1.Image1.Canvas.Pen.Color := clBlack; end; if c < 0 then begin Form1.Image1.Canvas.MoveTo(x2i(0),y2j(ymax)); Form1.Image1.Canvas.Pen.Color := clRed; end; for i := x2i(0)+1 to Wijd-1 do begin x := i2x(i); y := macht(x,c); Form1.Image1.Canvas.LineTo(x2i(x),y2j(y)); end; end; end; procedure two; { Functions y=c^x } const waarde : array[0..16] of double = (0.3,0.4,0.5,0.6,0.7,0.8,0.9,1,1.25,1.5,2,2.5,3,3.5,4,4.5,5); var k,i : integer; x,y,c : double; begin with Form1.Image1.Canvas do begin Pen.Color := clYellow; Pen.Width := 2; MoveTo(x2i(xmin),y2j(0)); LineTo(x2i(xmax),y2j(0)); MoveTo(x2i(0),y2j(ymin)); LineTo(x2i(0),y2j(ymax)); end; for k := 0 to Length(waarde)-1 do begin c := waarde[k]; if c > 1 then begin Form1.Image1.Canvas.Pen.Color := clBlue; end; if c = 1 then begin Form1.Image1.Canvas.Pen.Color := clBlack; end; if c < 1 then begin Form1.Image1.Canvas.Pen.Color := clRed; end; x := xmin; y := macht(c,x); Form1.Image1.Canvas.MoveTo(x2i(x),y2j(y)); for i := 1 to Wijd-1 do begin x := i2x(i); y := macht(c,x); Form1.Image1.Canvas.LineTo(x2i(x),y2j(y)); end; end; end; procedure TForm1.Toetsdruk(Sender: TObject; var Key: Char); { On KeyPress } begin xmin := -5; xmax := +5; ymin := 0; ymax := 10; ClearDevice; two; Form1.Image1.Picture.SaveToFile('twee.bmp'); end; procedure TForm1.Scheppen(Sender: TObject); { At moment of creation } begin xmin := 0; xmax := 10; ymin := 0; ymax := 10; TV(Form1.Image1); ClearDevice; one; Form1.Image1.Picture.SaveToFile('een.bmp'); end; END.