计算机画圆程序,计算机图形学画圆的程序.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
    收藏
  • 一键三连
    一键三连
  • 扫一扫,分享海报

表情包
插入表情
评论将由博主筛选后显示,对所有人可见 | 还能输入1000个字符
©️2021 CSDN 皮肤主题: 游动-白 设计师:白松林 返回首页
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值