You are on page 1of 2

#include <iostream>

#include <stdio.h>
#include <conio.h>
#include <math.h>
#include <windows.h>
#include <graphics.h>
int cul;
using namespace std;
class patrat
{
public:
int tab[10];
int ini1, ini2;
void scal(int *s,int x,int y,int z)
{
for(int k=0;k<10;k+=2)
{
tab[k]=(int)(s[k]-x)*0.6+x; //scalarea
tab[k+1]=(int)(s[k+1]-y)*0.6+y; //scalarea
}
drawpoly(5,tab);
setfillstyle(1,cul);
floodfill(tab[0]+1,tab[1]+1, WHITE);
}
void rot(int *s,int x,int y,double i,int z)
{
for(int k=0;k<10;k+=2)
{
tab[k]=(int)((s[k]-x)*cos(i)-(s[k+1]-y)*sin(i)+x);
tab[k+1]=(int)((s[k]-x)*sin(i)+(s[k+1]-y)*cos(i)+y);
}
setfillstyle(1,cul);
drawpoly(5,tab);
floodfill(tab[0]+1,tab[1]+1,WHITE);
}
void depl(int *s,int z)
{
for(int k=0;k<10;k+=2)
{
tab[k]=s[k]+28; //deplasarea X
tab[k+1]=s[k+1]+41; //deplasarea Y
}
drawpoly(5,tab);
setfillstyle(1,cul);
floodfill(tab[0]+1,tab[1]+1,WHITE);
//floodfill(450,770,WHITE);
}
};
int main()
{
initwindow(900,500,"Laborator 2 GC");
patrat p;
int maxx,maxy,a=450,b=400;
double i=(130*3.1415)/180; //unghiul de rotire
int x[10];
int tabel[8]={700,150,800,25,600,25,700,150};
drawpoly(4,tabel);//Desenam triunghiul
setfillstyle(1,RED);
floodfill(700,100,WHITE);
cul=getpixel(700,100);
int k;
int s[10]={200,200,200,350,350,350,350,200,200,200};
drawpoly(5,s);//Desenam patratul fix

while(true){
outtextxy(10,10,"1 - Scalare --- 0.6");
outtextxy(10,30,"2 - Deplasare --- 28 // 41");
outtextxy(10,50,"3 - Rotire --- 130");
switch(getch()){
case '1':
p.scal(s,a,b,k);
break;
case '2':
p.depl(s,k);
break;
case '3':
p.rot(s,a,b,i,k);
break;
default: return 0;}}
getch();
return 0;
}

You might also like