Кадрирование, диаграмма и график. Геометрическое моделирование

Сдавался/использовался1. KSP,КГТУСА, 1998. ас.Голенкову и Лященко
Загрузить архив:
Файл: vdv-1083.zip (108kb [zip], Скачиваний: 66) скачать

unit Unit1;

interface

uses

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

Buttons, StdCtrls, Spin, ExtCtrls;

type

TForm1 = class(TForm)

    SpinEdit2: TSpinEdit;

    SpinEdit3: TSpinEdit;

    SpinEdit4: TSpinEdit;

    SpinEdit5: TSpinEdit;

    SpeedButton1: TSpeedButton;

    SpinEdit1: TSpinEdit;

    procedure SpeedButton1Click(Sender: TObject);

private

    { Private declarations }

public

    { Public declarations }

end;

var

Form1: TForm1;

   k3,k2,max,sum,i,xx:integer;

   s,ss:array[1..5]of integer;

   pr:extended;

   r1,r2,r3,r4,r5:trect;

implementation

{$R *.DFM}

procedure p1;

begin

   form1.refresh;

form1.canvas.pen.width:=2;

form1.canvas.pen.color:=clblack;

   for i:=0 to 627 do

     begin

if i=ss[1] then  form1.canvas.pen.color:=clred;

if i=(ss[1]+ss[2]) then  form1.canvas.pen.color:=clblue;

if i=(ss[1]+ss[2]+ss[3]) then  form1.canvas.pen.color:=clgreen;

if i=(ss[1]+ss[2]+ss[3]+ss[4]) then  form1.canvas.pen.color:=clwhite;

form1.canvas.moveto(75,75);

form1.canvas.lineto(trunc(75+60*cos(i/100)),trunc(75+60*sin(i/100)));

     end;

{-------- линейныйграфик --------------}

     form1.canvas.pen.width:=1;

     form1.canvas.moveto(200,20);

     form1.canvas.lineto(200,150);

     form1.canvas.lineto(400,150);

     form1.canvas.moveto(200,150);

     xx:=240;

     for i:=1 to 5 do

       begin

       form1.canvas.lineto(xx,(150-s[i]*k2));

       xx:=xx+40;

       end;

{--------- гистограмма ------------}

form1.canvas.pen.width:=2;

form1.canvas.moveto(48,190);

form1.canvas.lineto(48,402);

form1.canvas.lineto(402,402);

r1:=rect(50,400,120,(400-s[1]*k3));

r2:=rect(120,400,190,(400-s[2]*k3));

r3:=rect(190,400,260,(400-s[3]*k3));

r4:=rect(260,400,330,(400-s[4]*k3));

r5:=rect(330,400,400,(400-s[5]*k3));

form1.canvas.brush.color:=clblack;

form1.canvas.fillrect(r1);

form1.canvas.brush.color:=clred;

form1.canvas.fillrect(r2);

form1.canvas.brush.color:=clblue;

form1.canvas.fillrect(r3);

form1.canvas.brush.color:=clgreen;

form1.canvas.fillrect(r4);

form1.canvas.brush.color:=clwhite;

form1.canvas.fillrect(r5);

end;

procedure TForm1.SpeedButton1Click(Sender: TObject);

begin

     s[1]:=SpinEdit1.value;

     s[2]:=SpinEdit2.value;

     s[3]:=SpinEdit3.value;

     s[4]:=SpinEdit4.value;

     s[5]:=SpinEdit5.value;

    sum:=0;

    for i:=1 to 5 do

         sum:=sum+s[i];

     pr:=628/sum;

     for i:=1 to 5 do

         ss[i]:=trunc(s[i]*pr);

     max:=0;

     for i:=1 to 5 do if s[i]>=max then max:=s[i];

     k2:=trunc(140/max);

     k3:=trunc(200/max);

     p1; { процедура которая может все }

end;

end.