Mã:
#include <stdio.h>
#include <conio.h>
#include <graphics.h>
#include <stdlib.h>
#include <math.h>
#include <iostream.h>
float goc=3.14/8;
float xw1, xw2,yw1,yw2,tlx,tly,s;
int xv1,xv2,yv1,yv2;
void cuaso(float x1, float y1,float x2, float y2)
{
xw1=x1;
yw1=y1;
xw2=x2;
yw2=y2;
}
void khungnhin(int x1, int y1, int x2, int y2)
{
xv1=x1;
yv1=y1;
xv2=x2;
yv2=y2;
tlx=(xv2-xv1)/(xw2-xw1);
tly=(yv2-yv1)/(yw2-yw1);
}
void chuyenden( float x, float y)
{
int xm=(int)(tlx*(x-xw1)+xv1);
int ym=(int)(tly*(yw2-y)+yv1);
moveto(xm,ym);
}
void veden(float x, float y)
{
int xm=(int)(tlx*(x-xw1)+xv1);
int ym=(int)(tly*(yw2-y)+yv1);
lineto(xm,ym);
}
using namespace std;
void Loang(int tx,int ty,int mb,int mt)
{
if(getpixel(tx,ty)!=mb&&getpixel(tx,ty)!=mt)
{
putpixel(tx,ty,mt);
Loang(tx+1,ty,mb,mt);
Loang(tx-1,ty,mb,mt);
Loang(tx,ty+1,mb,mt);
Loang(tx,ty-1,mb,mt);
}
}
void Duongtron_BRE(int xc, int yc, int R, int color)
{
int x, y, d;
x = 0;
y = R;
d = 3 - 2 * R;
while (x <= y)
{
putpixel(xc + x, yc + y,color);
putpixel(xc - x, yc + y,color);
putpixel(xc + x, yc - y,color);
putpixel(xc - x, yc - y,color);
putpixel(xc + y, yc + x,color);
putpixel(xc - y, yc + x,color);
putpixel(xc + y, yc - x,color);
putpixel(xc - y, yc - x,color);
if (d < 0)
d += 4 * x + 6;
else
{
d += 4 * (x-y) + 10;
y--;
}
x++;
}
}
void MidPoint(int x1,int y1,int x2,int y2,int color)
{
int x=x1;
int y=y1;
int dx=x2-x1;
int dy=y2-y1;
putpixel(x1,y1,color);
if (dy<dx)
{
float P=dy-dx/2;
while (x<x2)
{
if (P>=0)
{
putpixel(x+1,y+1,color);
y++;
P+=dy-dx;
}
else
{
putpixel(x+1,y,color);
P+=dy;
}
x++;
}
}
else
{
float P=dx/2-dy;
while (y<=y2)
{
if (P>=0)
{
putpixel(x+1,y+1,color);
x++;
P+=dx-dy;
}
else
{
putpixel(x,y+1,color);
P+=dx;
}
y++;
}
}
putpixel(x2,y2,color);
}
void buocnhay(int x1,int y1,int x2,int y2,int x3,int y3,int x4,int y4)
{
MidPoint(x1,y1,x2,y2,0);
MidPoint(x2,y2,x3,y3,0);
MidPoint(x1,y1,x4,y4,0);
MidPoint(x4,y4,x3,y3,0);
}
void vehinh(int x1,int y1,int x2,int y2,int x3,int y3,int x4,int y4)
{
MidPoint(x1,y1,x2,y2,15);
MidPoint(x2,y2,x3,y3,15);
MidPoint(x1,y1,x4,y4,15);
MidPoint(x4,y4,x3,y3,15);
MidPoint(x1,y1,x4,y4,15);
MidPoint(x3,y3,x2,y2,15);
MidPoint(x4,y4,x1,y1,15);
}
void batPhim()
{
char c;
int x1=420,y1=670,x2=510,y2=670,x3=510,y3=630,x4=420,y4=630;
vehinh(x1,y1,x2,y2,x3,y3,x4,y4);
do{
c=getch();
buocnhay(x1,y1,x2,y2,x3,y3,x4,y4);
switch(c)
{
case 75 : x1-=10; x2-=10; x3-=10; x4-=10; break;
case 77 : x1+=10; x2+=10; x3+=10; x4+=10; break;
case 72 : y1-=10; y2-=10; y3-=10; y4-=10; break;
case 80 : y1+=10; y2+=10; y3+=10; y4+=10;break;
}
vehinh(x1,y1,x2,y2,x3,y3,x4,y4);
}while(c!=27);
}
void FloodFill(int x, int y, int in_color, int new_color)//hàm tô màu
{
if (getpixel(x, y) == in_color)
{
putpixel(x, y, new_color);
FloodFill(x-1, y, in_color, new_color);
FloodFill(x+1, y, in_color, new_color);
FloodFill(x, y-1, in_color, new_color);
FloodFill(x, y+1, in_color, new_color);
}
}
void VeBong()
{
Duongtron_BRE(150, 150, 100, 3);
Loang(150,150,3,3);
Duongtron_BRE(350, 175, 15, 4);
Loang(350,175,4,4);
Duongtron_BRE(400, 150, 20, 5);
Loang(400,150,5,5);
Duongtron_BRE(200, 113, 25, 6);
Loang(200,113,6,6);
Duongtron_BRE(141, 143, 30, 7);
Loang(141,143,7,7);
Duongtron_BRE(130, 120, 5, 8);
Loang(130,120,8,8);
Duongtron_BRE(250, 213, 10, 9);
Loang(250,213,9,9);
Duongtron_BRE(670, 113, 35, 1);
Loang(670,113,1,1);
Duongtron_BRE(345, 234, 23, 2);
Loang(345,234,2,2);
Duongtron_BRE(123, 345, 45, 11);
Loang(123,345,11,11);
Duongtron_BRE(550, 113, 30, 13);
Loang(550,113,13,13);
Duongtron_BRE(700, 205, 33, 12);
Loang(700,205,12,12);
Duongtron_BRE(600, 205, 20, 14);
Loang(600, 205,14,14);
}
int main()
{ //tructoado();
//int driver=DETECT,mode;
//initgraph(&driver,&mode,"C:\\Dev-Cpp\\include");
initwindow(800,700);
int xc,yc,R;
//cout<<"nhap x= "<<x;
//cout<<"nhap y= "<<y;
//ve duong tron
//vehinhthang();
VeBong();
int x1=420,y1=670,x2=510,y2=670,x3=510,y3=630,x4=420,y4=630;
buocnhay(x1,y1,x2,y2,x3,y3,x4,y4);
vehinh(x1,y1,x2,y2,x3,y3,x4,y4);
Loang(450, 650,15,15);
batPhim();
getch();
closegraph();
}
Tuy nhiên, việc thi công và bảo dưỡng đường bê tông nhựa đòi hỏi sự chuyên nghiệp và kỹ thuật cao từ các nhà thầu và kỹ sư. Sự linh hoạt và độ bền cao của đường bê tông nhựa cũng giúp giảm thiểu chi...
Xây Dựng Đẳng Cấp: Cùng Đại Thanh,...