# 计算机画圆程序,计算机图形学画圆的程序.doc

#i

nclude

#pragma hdrstop

#include "Unit1.h"

//---------------------------------------------------------------------------

#pragma package(smart_init)

#pragma resource "*.dfm"

TForm1 *Form1;

//---------------------------------------------------------------------------

__fastcall TForm1::TForm1(TComponent* Owner)

: TForm(Owner)

{

}

//---------------------------------------------------------------------------

void __fastcall TForm1::Button1Click(TObject *Sender)

{

int r,x,y;

float d;

r=StrToInt(Edit1->Text);

x=0;

y=r;

d=5.0/4-r;

Image1->Canvas->Pixels[250][175]=clBlack;

while(y>x)

{if(d<0)

{d+=2.0*x+3;

x++;}

else

{d+=(x-y)*2.0+5;

x++;

y--;}

Image1->Canvas->Pixels[250+x][175-y]=clBlack;

}

x=r;

y=0;

d=5.0/4-r;

while(y

{if(d<0)

{d+=2.0*y+3;

y++;}

else

{d+=(y-x)*2.0+5;

y++;

x--;}

Image1->Canvas->Pixels[250+x][175-y]=clBlack;

}

x=0;

y=r;

d=5.0/4-r;

while(y>(-x))

{if(d<0)

{d+=2.0*(-x)+3;

x--;}

else

{d+=(-x-y)*2.0+5;

(x--);

y--;}

Image1->Canvas->Pixels[250+x][175-y]=clBlack;

}

x=-r;

y=0;

d=5.0/4-r;

while(y

{if(d<0)

{d+=2.0*y+3;

y++;}

else

{d+=(y+x)*2.0+5;

y++;

x++;}

Image1->Canvas->Pixels[250+x][175-y]=clBlack;

}

x=0;

y=-r;

d=5.0/4-r;

while(-y>x)

{if(d<0)

{d+=2.0*x+3;

x++;}

else

{d+=(x+y)*2.0+5;

x++;

y++;}

Image1->Canvas->Pixels[250+x][175-y]=clBlack;

}

x=r;

y=0;

d=5.0/4-r;

while(-y

{if(d<0)

{d+=2.0*(-y)+3;

y--;}

else

{d+=(-y-x)*2.0+5;

y--;

x--;}

Image1->Canvas->Pixels[250+x][175-y]=clBlack;

}

x=0;

y=-r;

d=5.0/4-r;

while(-y>-x)

{if(d<0)

{d+=2.0*(-x)+3;

x--;}

else

{d+=(-x+y)*2.0+5;

x--;

y++;}

Image1->Canvas->Pixels[250+x][175-y]=clBlack;

}

x=-r;

y=0;

d=5.0/4-r;

while(-y

{if(d<0)

{d+=2.0*(-y)+3;

y--;}

else

{d+=(-y+x)*2.0+5;

y--;

x++;}

Image1->Canvas->Pixels[250+x][175-y]=clBlack;

}

}

//---------------------------------------------------------------------------

void __fastcall TForm1::Button2Click(TObject *Sender)

{

Image1->Canvas->Brush->Color=clWhite;

Image1->Canvas->FillRect(Rect(0,0,500,350));

}

//----------------------------------------

• 0
点赞
• 0
评论
• 0
收藏
• 一键三连
• 扫一扫，分享海报

11-16 4万+
02-03 646
12-20 4955
10-19 2363
01-18 4万+
10-24 3642
11-24 1191
04-02 1661
04-17 1万+