{******************************************* {Point-by-point comparison method to generate straight lines, Computer graphics experiment. } {Disigned by WHBO, first quadrant, counterclockwise. {CopyRight (C) 2003-2004 reserved.} {With any questions, tel: 07146526270} {email: WanghongBottt123@163.com} {******************************************************************************* *******************} Unit UNITCIRCLE;
Interface
Uses Windows, Messages, Sysutils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls, stdctrls
type Tcirclefrm = class (TForm) input1: TEdit; input2: TEdit; input3: TEdit; input4: TEdit; Button1: TButton; StaticText1: TStaticText; StaticText2: TStaticText; GroupBox1: TGroupBox; Image1: TImage; StaticText3: TStaticText; input5: TEdit ; INPUT6: TEDIT; Procedure Button1Click (Sender: Tobject); Procedure Formcreate (Sender: TOBJECT); private {private declarations}
Var CircleFrm: TcircLefrm;
IMPLEMENTATION
{$ R * .dfm}
Procedure Tcirclefrm.Button1Click (Sender: Tobject); VARX0, Y0, R0, R1, X, Y, XE, YE, I, N1, N2, N, K: INTEGER; // Starting point (X0, Y0), end point (XE , Ye), round (R0, R1) // N: Remember the number of points f: array [1..1024] of integer; Begin // The following three lines of code have a poor setting effect because the Form display is not good, I make StaticText3. Visible: = false; Input5.visible: = false; input6.visible: = false
Groupbox1.visible: = true; groupbox1.align: = alclient; image1.align: = alclient; x0: = start (TRIM (INPUT1.TEXT)); Y0: = STRTOINT (TRIM (Input2.text)); xe: = STRTOINT (Trim (Input3.Text)); YE: = StrtOINT (Trim (Input4.Text)); R0: = STRTOINT (Trim (Input5.Text)); R1: = STRTOINT (Trim (Input6.Text)); x : = X0; Y: = Y0; // As finding N value N1: = ABS (XE-X0); N: = ABS (YE-Y0); N: = N1 N2; // The following start loop point f [1]: = 1-2 * (X0-R0); // PASCAL array from 1st // The result is obtained by the textbook P64 (first step moving X) Try for i: = 1 to n DO Begin IFIN [I]> = 0 THEN BEGIN F [I 1]: = F [i] -2 * ABS (R0-x); x: = x-1; ELSE BEGIN F [i 1]: = f [ I] 2 * ABS (R1-Y); Y: = Y 1; End; circlefrm.image1.canvas.pixels [x, y]: = CLRED; // showMessage (INTTOSTR (X) '' INTOSTR (y); End; Except Application.MessageBox ('Your input has an error!', 'warning', MB_OK); end; end; procedure tcirclefrm.formcreate (sender: Tobject); begincirclefrm.Height: = 450; CircleFRM .WIDTH: = 600; end; end.