Sunteți pe pagina 1din 6

MINISTERUL

EDUCAIEI

AL REPUBLICII MOLDOVA

UNIVERSITATEA TEHNIC A MOLDOVEI


CATEDRA ATI

Lucrarea de Laborator Nr.1

Tema: Sinteza figurilor grafice


Varianta 5

Elaborat

St. gr. TI-122:

Cobla A.

Verificat

profesorul :

Gangan T.

Chiinu 2014

Scopul lucrrii: Obinerea cunotinelor practice n sinteza figurilor i suprafetelor n baza bibliotecii
grafice a oricrui limbaj de programare (Pascal, C++, ori Java).
Sarcina lucrrii:
1. De a elabora un program pentru sintezarea i afiarea figurilor grafice conform variantelor tabelul 1 i
2.
2. De a utiliza operaiuni de salvare i restaurare a imaginilor n/din fiiere
Tabelul 1. Figuri grafice
Nr.
Denumirea figurii
1
Linia
2
Triunghi
3
Dreptungi
4
Poligon numrul de vrfuri este egal
cu nr de ordin al studentului n registru
+ 4
5
Paralelepiped
6
Cerc
7
Elipsa
8
Sector de cerc
9
Sector de elips

Codul surs:
//--------------------------------------------------------------------------#include <vcl.h>
#pragma hdrstop
#include "lab1.h"
//--------------------------------------------------------------------------#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//--------------------------------------------------------------------------__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//--------------------------------------------------------------------------void __fastcall TForm1::FormActivate(TObject *Sender)
{
Image1->Width=Form1->ClientWidth;
Image1->Height=Form1->ClientHeight;
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button3Click(TObject *Sender)


{
Image1->Picture->SaveToFile("image.png");
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button2Click(TObject *Sender)


{
Image1->Width=Form1->ClientWidth;
Image1->Height=Form1->ClientHeight-40;
Image1->Canvas->Pen->Width=1;
Image1->Canvas->Pen->Color=RGB(0,0,0);
Image1->Canvas->MoveTo(200,5);
Image1->Canvas->LineTo(200,390);
Image1->Canvas->MoveTo(400,5);
Image1->Canvas->LineTo(400,390);
Image1->Canvas->MoveTo(600,5);
Image1->Canvas->LineTo(600,390);
Image1->Canvas->MoveTo(800,5);
Image1->Canvas->LineTo(800,390);
Image1->Canvas->MoveTo(5,200);
Image1->Canvas->LineTo(995,200);
//---------Elipsa umpluta--------------------------------------Image1->Canvas->Pen->Color=clBlack;
//Specifica grosimea liniei
Image1->Canvas->Pen->Width = 2;
Image1->Canvas->Pen->Color = RGB(225,0,0);
//Specifica stilul pensulei
Image1->Canvas->Brush->Color = RGB(225,0,0);
Image1->Canvas->Brush->Style = bsFDiagonal;
//Se deseneaza o elipsa care este incadrata in dreptunghiul de coordonate X1,Y1
si X2,Y2
Image1->Canvas->Ellipse(5,50,195,150);
//-------------------------------------------------------------//---------Dreptunghi umplut-----------------------------------Image1->Canvas->Pen->Color=clBlack;
//Specifica grosimea liniei
Image1->Canvas->Pen->Width = 2;
Image1->Canvas->Pen->Color = RGB(0,55,115);
//Specifica stilul pensulei
Image1->Canvas->Brush->Color = RGB(0,55,115);
Image1->Canvas->Brush->Style = bsCross;
//Se deseneaza o elipsa care este incadrata in dreptunghiul de coordonate X1,Y1
si X2,Y2
Image1->Canvas->Rectangle(206,50,395,150);
//-------------------------------------------------------------//---------Linie-----------------------------------------------Image1->Canvas->Pen->Color=clBlack;
//Specifica grosimea liniei
Image1->Canvas->Pen->Width = 2;
Image1->Canvas->Pen->Color = RGB(0,155,115);
Image1->Canvas->MoveTo(406,50);
Image1->Canvas->LineTo(595,150);
//-------------------------------------------------------------//---------Triunghi umplut------------------------------------TPoint points[4];
points[0] = Point(606,50);
points[1] = Point(606,150);
points[2] = Point(795,150);
points[3] = Point(605,50);
Image1->Canvas->Pen->Color=clBlack;
//Specifica grosimea liniei
Image1->Canvas->Pen->Width = 2;
Image1->Canvas->Pen->Color = RGB(162,44,181);
//Specifica stilul pensulei
Image1->Canvas->Brush->Color = RGB(74,160,182);
Image1->Canvas->Brush->Style = bsDiagCross;
Image1->Canvas->Polygon(points, 3);

//-------------------------------------------------------------//---------Sector de cerc umplut-------------------------------Image1->Canvas->Pen->Color=clBlack;


//Specifica grosimea liniei
Image1->Canvas->Pen->Width = 2;
Image1->Canvas->Pen->Color = RGB(154,169,22);
//Specifica stilul pensulei
Image1->Canvas->Brush->Color = RGB(201,183,25);
Image1->Canvas->Brush->Style = bsBDiagonal;
Image1->Canvas->Pie(820, 20, 970, 180, 970, 20, 970, 180);
//-------------------------------------------------------------//---------Poligon cu 7 laturi---------------------------------TPoint points2[8];
points2[0] = Point(5,250);
points2[1] = Point(100,260);
points2[2] = Point(100,290);
points2[3] = Point(150,250);
points2[4] = Point(195,340);
points2[5] = Point(150,350);
points2[6] = Point(100,340);
points2[7] = Point(5,250);
Image1->Canvas->Pen->Color=clBlack;
//Specifica grosimea liniei
Image1->Canvas->Pen->Width = 2;
Image1->Canvas->Pen->Color = RGB(62,119,70);
//Specifica stilul pensulei
Image1->Canvas->Brush->Color = RGB(255,255,255);
Image1->Canvas->Brush->Style = bsSolid;
Image1->Canvas->Polygon(points2, 6);
//-------------------------------------------------------------//---------Sector de elipsa umplut-------------------------------Image1->Canvas->Pen->Color=clBlack;
//Specifica grosimea liniei
Image1->Canvas->Pen->Width = 2;
Image1->Canvas->Pen->Color = RGB(118,19,65);
//Specifica stilul pensulei
Image1->Canvas->Brush->Color = RGB(255,255,255);
Image1->Canvas->Brush->Style = bsSolid;
Image1->Canvas->Pie(206, 250, 395, 350, 206, 250, 350, 206);
//-------------------------------------------------------------//---------Paralelepiped umplut--------------------------------TPoint points3[5];
points3[0] = Point(415,270);
points3[1] = Point(575,270);
points3[2] = Point(565,350);
points3[3] = Point(405,350);
points3[4] = Point(415,270);
TPoint points4[5];
points4[0] = Point(415,270);
points4[1] = Point(435,250);
points4[2] = Point(595,250);
points4[3] = Point(575,270);
points4[4] = Point(415,270);
TPoint points5[5];
points5[0] = Point(575,270);
points5[1] = Point(565,350);
points5[2] = Point(585,330);
points5[3] = Point(595,250);
points5[4] = Point(575,270);

Image1->Canvas->Pen->Color=clBlack;
//Specifica grosimea liniei
Image1->Canvas->Pen->Width = 2;
//Specifica culoarea liniei
Image1->Canvas->Pen->Color = RGB(10,7,119);
//Specifica stilul pensulei
Image1->Canvas->Brush->Color = RGB(255,255,255);
Image1->Canvas->Brush->Style = bsSolid;
Image1->Canvas->Polygon(points4, 4);
Image1->Canvas->Polygon(points5, 4);
Image1->Canvas->Pen->Color = RGB(9,71,65);
Image1->Canvas->Brush->Color = RGB(9,71,65);
Image1->Canvas->Brush->Style = bsVertical;
Image1->Canvas->Polygon(points3, 4);
//-------------------------------------------------------------//---------Cerc umplut-----------------------------------------Image1->Canvas->Pen->Color=clBlack;
//Specifica grosimea liniei
Image1->Canvas->Pen->Width = 2;
Image1->Canvas->Pen->Color = RGB(0,0,0);
//Specifica stilul pensulei
Image1->Canvas->Brush->Color = RGB(0,0,0);
Image1->Canvas->Brush->Style = bsHorizontal;
//Se deseneaza o elipsa care este incadrata in dreptunghiul de coordonate X1,Y1
si X2,Y2
Image1->Canvas->Ellipse(625,230,775,370);
//-------------------------------------------------------------}
//--------------------------------------------------------------------------void __fastcall TForm1::Button1Click(TObject *Sender)
{
Graphics::TBitmap *BrushBmp=new Graphics::TBitmap;
BrushBmp->LoadFromFile("image.png");
Image1->Canvas->Brush->Bitmap=BrushBmp;
Image1->Canvas->FillRect(Rect(0,0,Image1->Width,Image1->Height));
Form1->Canvas->Brush->Bitmap=NULL;
delete BrushBmp;
}
//---------------------------------------------------------------------------

Rezultatele:

Concluzii: Efectund lucrarea dat am facut cunotin cu bazele graficii n limbajul C++,
am fcut cunotin cu funciile de desenare a figurilor primitive i cu modurile de colorare a
lor i afiare unor sectiuni a acestor figuri.