
06.06.2014, 21:19
|
Прохожий
|
|
Регистрация: 11.02.2014
Сообщения: 23
Версия Delphi: Delphi 7
Репутация: 10
|
|
Не знаю.. Я должн был взять функцию внутрь бэгин- энд. Иначе она не может реагировать на нажатие кнопки. Верно? ....Выходит [Error] Unit1.pas(28): Statement expected but 'TYPE' found
У меня пока код выглядит так
Код:
unit Risuem1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
type TFunc = function (x: real): real;
procedure DrawGraph (f: TFunc; a: real; b: real; C: TCanvas);
var x, y, h, max, min, sx, sy: real;
xmid, ymid: integer;
begin sx:= (c.ClipRect.Right) / (b-a);
h:= 1 / sx;
xmid:= c.ClipRect.Right div 2;
ymid:= c.ClipRect.Bottom div 2;
x:= a; max:= f(x);
min:= max;
while x <= b do begin y:= f(x);
if y < min then min:= y;
if y > max then max:= y;
x:= x + h; end;
sy:= c.ClipRect.Bottom / (max - min);
c.Brush.Color:= clBlack;
c.FillRect(Rect(0, 0, c.ClipRect.Right, c.ClipRect.Bottom));
c.Pen.Color:= clYellow; c.MoveTo(0, ymid);
c.LineTo(c.ClipRect.Right, ymid); c.MoveTo(xmid, 0);
c.LineTo(xmid, c.ClipRect.Bottom); x:= a; y:= f(x);
c.Pen.Color:= clWhite; c.MoveTo(xmid + round(sx * x), ymid - round(sy * y));
while x <= b do begin y:= f(x);
c.LineTo(xmid + round(sx * x), ymid - round(sy * y));
x:= x + h; end; end; end;
end.
|