Sunteți pe pagina 1din 7

# Ministerul Educației al Republicii Moldova

## Departamentul Ingineria Software şi Automatică

Raport
Lucrarea de laborator nr.2
Disciplina: Grafica pe Calculator

## A verificat: conf.univ. M.Osovschi

Chișinău - 2019
Tema: “Crearea scenei grafice bidimensionale dinamice”

grafice simple.

## geometrice asupra figurilor bidimensionale:

 Scalarea
 Deplasarea
 Rotirea în jurul unui punct și în jurul axei sale

Listingul programului:
#include <vcl.h>
#pragma hdrstop

#include "lab2.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
Form1->Width=1000;
Form1->Height=600;
Form1->Brush->Color=clWhite;
}
//---------------------------------------------------------------------------

Scalarea si deplasarea :

## void __fastcall TForm1::FormClick(TObject *Sender)

{
for(int i=0; i<120; i++){
//Pasare
Canvas->Pen->Width=3;
Canvas->Arc(490,195,520,227,520,206,496,200);
Canvas->Arc(520,196,552,228,550,202,520,206);

//Nor
Canvas->Brush->Color=clSkyBlue;
Canvas->Pen->Color=clSkyBlue;
Canvas->Ellipse(695,45,790,77);
Canvas->Ellipse(737,33,823,70);
Canvas->Ellipse(785,36,850,62);
Canvas->Ellipse(755,50,873,90);
Canvas->Ellipse(725,65,792,88);

//Soare
Canvas->Pen->Color=clWhite;
Canvas->Brush->Color=clYellow ;
Canvas->Ellipse(460, 25, 600+i, 156+i);

//Nor
Canvas->Brush->Color=clSkyBlue;
Canvas->Pen->Color=clSkyBlue;
Canvas->Ellipse(340,67,555,120);
Canvas->Ellipse(380,50,460,95);
Canvas->Ellipse(428,39,503,80);
Canvas->Ellipse(400,100,512,138);
Canvas->Ellipse(367,90,420,130);

//Copaci
Canvas->Pen->Color=clBlack;
Canvas->Brush->Color=clMaroon;
Canvas->Rectangle(180,363,212,450);
Canvas->Rectangle(373,362,404,450);
Canvas->Brush->Color=clGreen;
Canvas->Ellipse(155,240,245,370);
Canvas->Ellipse(345,225,435,380);

//Linii
Canvas->Pen->Color=clBlack;
Canvas->MoveTo(176,0);
Canvas->LineTo(372,132);
Canvas->MoveTo(20,318);
Canvas->LineTo(336,264);
Canvas->MoveTo(2,8);
Canvas->LineTo(94,74);
Canvas->MoveTo(0,103);
Canvas->LineTo(53,113);
Canvas->MoveTo(7,190);
Canvas->LineTo(48,210);
Canvas->MoveTo(2,265);
Canvas->LineTo(64,257);

//AngryBird
Canvas->Pen->Color=clWhite;
Canvas->Pen->Width=4;
Canvas->Brush->Color=clRed ;
Canvas->Ellipse(107+i, 50, 200+i, 80);
Canvas->Ellipse(165+i, 18, 205+i, 95);
Canvas->Ellipse(67+i, 74, 296+i, 282);
Canvas->Pen->Color=clWhite;
Canvas->Brush->Color=clWhite ;
Canvas->Ellipse(180+i, 155, 230+i, 203);
Canvas->Ellipse(230+i, 155, 273+i, 200);
Canvas->Pen->Color=clBlack;
Canvas->Brush->Color=clBlack ;
Canvas->Ellipse(203+i, 172, 218+i, 186);
Canvas->Ellipse(236+i, 173, 250+i, 186);

TPoint Pt[6];
Canvas->Brush->Color=clBlack ;
Canvas->Pen->Color=clBlack;
Pt[0]=Point(170+i,137);
Pt[1]=Point(230+i,160);
Pt[2]=Point(280+i,140);
Pt[3]=Point(288+i,162);
Pt[4]=Point(230+i,170);
Pt[5]=Point(163+i,157);
Canvas->Polygon(Pt,5);

TPoint Pt2[10];
Canvas->Pen->Color=clWhite;
Pt2[0]=Point(73+i,157);
Pt2[1]=Point(60+i,135);
Pt2[2]=Point(50+i,145);
Pt2[3]=Point(60+i,160);
Pt2[4]=Point(37+i,147);
Pt2[5]=Point(32+i,166);
Pt2[6]=Point(55+i,172);
Pt2[7]=Point(45+i,180);
Pt2[8]=Point(50+i,190);
Pt2[9]=Point(67+i,178);
Canvas->Brush->Color=clBlack;
Canvas->Polygon(Pt2,9);

Canvas->Pen->Color=clBlack;
Canvas->Brush->Color=clYellow ;
TPoint Pt1[6];
Pt1[0]=Point(190+i,220);
Pt1[1]=Point(229+i,185);
Pt1[2]=Point(275+i,228);
Pt1[3]=Point(190+i,220);
Pt1[4]=Point(225+i,257);
Pt1[5]=Point(259+i,229);
Canvas->Polygon(Pt1,5);

//Iarba
Canvas->Pen->Color=clBlack;
Canvas->Brush->Color=clGreen ;
Canvas->Rectangle(-10,450,1010,610);
//Suport
Canvas->Brush->Color=clMaroon ;
Canvas->Rectangle(600,300,1100,350);
Canvas->Rectangle(650,350,700,610);

//Pig

Canvas->Pen->Color=clWhite;
Canvas->Brush->Color=clGreen ;
Canvas->Ellipse(777,95,818,150);
Canvas->Ellipse(850,80,882,128);
Canvas->Pen->Color=clWhite;
Canvas->Brush->Color=clLime ;
Canvas->Ellipse(788,111,803,125);
Canvas->Ellipse(858,94,872,109);
Canvas->Pen->Color=clWhite;
Canvas->Brush->Color=clGreen ;
Canvas->Ellipse(747,104,971,310);
Canvas->Brush->Color=clLime ;
Canvas->Ellipse(830,200,890,260);
Canvas->Ellipse(810,170,910,240);

Canvas->Brush->Color=clWhite ;
Canvas->Ellipse(758,185,808,230);
Canvas->Brush->Color=clBlack ;
Canvas->Ellipse(770,200,785,215);
Canvas->Brush->Color=clWhite ;
Canvas->Ellipse(912,185,960,230);
Canvas->Brush->Color=clBlack ;
Canvas->Ellipse(923,200,940,215);
Canvas->Ellipse(830,197,845,215);
Canvas->Ellipse(870,200,885,215);
Sleep(30);
}
}
Rotirea în jurul unui punct:

## float x, y; //x și y cu care se incrementează poziția pentru rotație

int rad = 10; // Distanța de la centru de rotație
int pos_x = 770; //Poziția x
int pos_y = 200; //Poziția y
int pos_x1 = 923;
int size = 16; //Marimea figurii
for(int i=1; i<=600;i+=2)
{
PatBlt(Canvas->Handle,0,0,Width,Height,WHITENESS);

Canvas->Brush->Color=clBlack ;
Canvas->Ellipse(pos_x + x, pos_y + y, pos_x + x + size, pos_y + y + size);
Canvas->Ellipse(pos_x1 + x, pos_y + y, pos_x1 + x + size, pos_y + y + size);
Sleep(3);
}
Rezultatele programului:

Concluzii:
In urma efectuarii lucrarii de laborator nr.2 cu tema „Crearea scenei grafice
bidimensionale dinamice” , am obtinut cunostintele despre diverse tipuri de
transformari grafice 2D care se folosesc in procesul de formare a imaginilor si
desenare. Am implementat transformarile grafice ca Scalarea , Translatia ,
Rotatia figurilor geometrice fata de un punct fix.