Листинги программ к лабораторной работе 6

unit Unit1;

interface

uses

Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

Dialogs;

type

TForm1 = class(TForm)

Button1: TButton;

procedure FormPaint(Sender: TObject);

procedure Button1Click(Sender: TObject);

private

{ Private declarations }

public

{ Public declarations }

end;

var

Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormPaint(Sender: TObject);

//функция преобр.координат точек в координаты на поверхности рисования}

function cx(X:integer):integer; begin

cx:=50+x;

end;

function cy(Y:integer):integer;

begin

cy:=200-y;

end;

var i:integer;

begin

with Form1.Canvas do

begin

//1. прорисовка осей системы координат

pen.Width:=2;

moveTo(cx(0),cy(0));

Lineto(cx(0),cy(160)); //ось х

moveTo(cx(0),cy(0));

Lineto(cx(300),cy(0)); //ось у

//2.Прорисовка координатной сетки с шагом 20 пикселей

pen.Width:=1;

pen.Style:=psDot;

for i:=1 to 8 do

begin

moveTo(cx(0),cy(i*20));

Lineto(cx(300),cy(i*20));

end;

for i:=1 to 15 do

begin

moveTo(cx(i*20),cy(0));

Lineto(cx(i*20),cy(160));

end;

//3.Вывод заголовков осей

font.Size:=15;

TextOut(cx(290),cy(-5),'x');

TextOut(cx(-20),cy(160),'y');

//4. Отображение графика

for i:=0 to 300 do

pixels[cx(i),cy(20+round(i*i/1000))]:=clRed;

end;

end;

procedure TForm1.Button1Click(Sender: TObject);

begin

close;

end;

end.

unit Unit1;

interface

uses

Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

Dialogs, StdCtrls, TeEngine, Series, ExtCtrls, TeeProcs, Chart, TeeFunci,

ComCtrls;

type

TForm1 = class(TForm)

Chart1: TChart;

Series1: TBarSeries;

Button1: TButton;

Button2: TButton;

Series2: TLineSeries;

StatusBar1: TStatusBar;

Timer1: TTimer;

procedure Button2Click(Sender: TObject);

procedure Button1Click(Sender: TObject);

procedure Timer1Timer(Sender: TObject);

private

{ Private declarations }

public

{ Public declarations }

end;

var

Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button2Click(Sender: TObject);

begin

close;

end;

procedure TForm1.Button1Click(Sender: TObject);

var i:integer; a,b:array [1..5] of integer;

begin

for i:=1 to 5 do

begin

a[i]:=i;b[i]:=a[i]*a[i];

{chart1.series[0].AddXY(a[i],b[i],' ',clgreen);}

chart1.Series[1].AddXY(a[i],b[i],' ',clred);

end;

end;

procedure TForm1.Timer1Timer(Sender: TObject);

begin

statusbar1.Panels[1].Text:=timetostr(now);

end;

end.


Список литературы

1. Кандзюба С.П., Громов В.Н. Delphi 6/7. Базы данных и приложения. – СПб: ООО «ДиаСофтЮП», 2002.

2. Желонкин А. В. Основы программирования в интегрированной среде DELPHI. Практикум. – М.: БИНОМ, 2006.

3. Жуков А. Изучаем Delphi. – М.: Питер, 2002.

4. Фленов М. Библия Delphi.- СПб.: БХВ – Петербург, 2008.

5. Культин Н. С++ Builder в задачах и примерах.- СПб.: БХВ-Петербург, 2005.


Понравилась статья? Добавь ее в закладку (CTRL+D) и не забудь поделиться с друзьями:  



double arrow
Сейчас читают про: