trigger9871
Сообщений: 1
Оценки: 0
Присоединился: 2011-02-24 07:09:29.783333
|
Программа Графика Построение определенного количества квадратов разного цвета При запуске ругается Divizion by zero -но программу запускает ругается на строку mas:= round(cx div k); Все перепроверил - не должен ругаться Спасибо заранее за любой совет Код: unit tank; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls, StdCtrls, ComCtrls, Spin; type TForm1 = class(TForm) PageControl1: TPageControl; TabSheet1: TTabSheet; PaintBox1: TPaintBox; SpinEdit_Count: TSpinEdit; SpinEdit_Razmer: TSpinEdit; Label1: TLabel; Label2: TLabel; procedure PaintBox1Paint(Sender: TObject); procedure SpinEdit_CountChange(Sender: TObject); procedure SpinEdit_RazmerChange(Sender: TObject); private procedure resize; procedure kvadrat; public { Public declarations } end; var Form1: TForm1; v,kolVistrel,begining :Integer; cx, cy, xb, yb, Xe,Ye,X,Y,X1,Y1,dlina : integer; implementation {$R *.dfm} procedure TForm1.resize; var dlina : integer; begin dlina:=strToint(SpinEdit_Razmer.text); PaintBox1.Width:=dlina; PaintBox1.Height:= dlina; PaintBox1.Left:=(Form1.Width-PaintBox1.Width)div 2 ; PaintBox1.Top:=(Form1.Height-PaintBox1.Height)div 2 ; with PaintBox1 do begin Xe:=Height; Ye:=Width; end; Xb:=0; Yb:=0; cx:=round(Xe div 2); cy:=round(Ye div 2); end; procedure TForm1.kvadrat; var mas,k,i : integer; begin k:=strToInt(SpinEdit_Count.Text); x:=0; with PaintBox1 do begin canvas.Pen.Color:=RGB(Random (255),Random (255),Random (255)); canvas.Brush.Color:=RGB(Random (255),Random (255),Random (255)); canvas.Rectangle(rect(Xb,Yb,Xe,Ye)); mas:= round(cx div k); for i:=1 to k-1 do begin x:=x + mas; x1:=xe-x; //y1:=ye-y; canvas.Pen.Color:=RGB(Random (255),Random (255),Random (255)); canvas.Brush.Color:=RGB(Random (255),Random (255),Random (255)); canvas.Rectangle(x,x,x1,x1); end; end; // Canvas.Pen.Mode := pmNotXor; end; //————————————– procedure TForm1.PaintBox1Paint(Sender: TObject); begin //PaintBox1.Canvas.FillRect(ClientRect); //resize; kvadrat; end; procedure TForm1.SpinEdit_CountChange(Sender: TObject); var znachRazm:integer; begin znachRazm:= strToInt(SpinEdit_Count.Text); if (znachRazm >= 1)and (znachRazm <= 10) then begin kvadrat;resize end else begin if znachRazm < 1 then SpinEdit_Count.Text:='1'; if znachRazm >10 then SpinEdit_Count.Text:='10'; end; end; procedure TForm1.SpinEdit_RazmerChange(Sender: TObject); var znachRazm:integer; begin znachRazm:= strToInt(SpinEdit_Razmer.Text); if (znachRazm >= 50)and (znachRazm <= 500) then resize else begin if znachRazm < 50 then SpinEdit_Razmer.Text:='50'; if znachRazm >500 then SpinEdit_Razmer.Text:='500'; end; end; end.
|