Работа с графикой в C++ Builder

Slides:



Advertisements
Similar presentations
Operator overloading redefine the operations of operators
Advertisements

For(int i = 1; i
Factorial Preparatory Exercise #include using namespace std; double fact(double); int fact(int); int main(void) { const int n=20; ofstream my_file("results.txt");
Top left is avg Ch for 09Z during June Top right is same but using MYJSFC from WRFv3.0 Bottom left is same but using MYJSFC from WRFv3.1 Bottom right.
Buffer Overflow Prabhaker Mateti Wright State University.
Chapter 7 Sorting Part II. 7.3 QUICK SORT Example left right pivot i j 5 > pivot and should go to the other side. 2 < pivot and should go to.
1 РОБОТА З ГРАФІКОЮ Пашко Анатолій Олексійович Кафедра інформаційних систем і технологій Європейського університету
Introduction to shapes
Tinaliah, S. Kom.. * * * * * * * * * * * * * * * * * #include using namespace std; void main () { for (int i = 1; i
Triana Elizabeth, S.Kom. #include using namespace std; void main () { for (int i = 1; i
Origami Bookmark Your paper should look like a square.
Total Surface Area. Rectangular Prism 6 “ 4 “ 5 “ What is the Total Surface Area?
C++ Graphics Primitives April 15th. void clearscreen(int c) –clear the screen to background color c –If c = 1 screen black.
P247. Figure 9-1 p248 Figure 9-2 p251 p251 Figure 9-3 p253.
Fractions that Equal Whole Numbers
You can type your own categories and points values in this game board. Type your questions and answers in the slides we’ve provided. When you’re in slide.
Area of Trapezoids. A trapezoid can be thought of as half of a parallelogram also. Notice that when we put the 2 trapezoids together we get a parallelogram.
The area of a rectangle equals its length times the width (base times the height). A = length x width = lw or A = base x height = bh Area of a Rectangle.
Area of Irregular Figures
Functions. Functions are named blocks of code. Functions allow complex programs to be broken down into smaller, simpler tasks. Functions allow commonly.
Make an isometric drawing of the cube structure below.
Geometry Vocabulary- transformation- the change in the size, shape, or position of a figure. translation- slide--every point in a figure moves the same.
Warm-Up What 3-d geometric shape will the following nets fold to create? 1) 2) 3)
How to Draw 3D Figures Cube, Cylinder, Cone, Rectangular Pyramid.
Surface Area of Prisms and Cylinders Retrieved from
The Percent Proportion. To solve a proportion, multiply the numbers that are diagonal, divide by the one that’s left.
Surface Area of Triangular Prisms Greg Morrison. Definition: The sum of the areas of all of the faces of a three-dimensional figure. Ex. How much construction.
KNOW WHICH LINE MATTERS WHEN FINDING AREA & VOLUME! IDENTIFYING HEIGHT & BASE.
Print Row Function void PrintRow(float x[ ][4],int i) { int j; for(j=0;j
Surface area of cuboids and prisms Grade C work. Find the area of these shapes.
2.7 Piecewise Functions p In real life functions are represented by a combination of equations, each corresponding to a part of the domain. These.
Int fact (int n) { If (n == 0) return 1; else return n * fact (n – 1); } 5 void main () { Int Sum; : Sum = fact (5); : } Factorial Program Using Recursion.
Use of Modeling. Origami House Start off with an origami paper color side down.
8.2 CPCTC Geometry.
Unit 5 Transformations in the Coordinate Plane. Translations.
14 June بسم الله الرحمن الرحيم MT 262 Putting Computer Systems to Work Block IV: Applications Unit 1 : Introduction to Computer Graphics.
PROCESSING A computer screen is a grid of small light elements called pixels.
♣Multiplying Decimals♣
GEOMETRY LESSON 10-1 Space Figures and Nets
Section 5.3 Dividing Monomials
Dilations Teacher Twins©2014.
قراءة القوائم المالية وفـاء شـريف علي. محلل مالي
عناصر المثلثات المتشابهة Parts of Similar Triangles
Simplify Numerator Or Denominator Adding Fractions What is the Whole
Objective - To find the surface area of a rectangular prism.
VIDEOWALL TOOL KIT Left To Right
Exam1 Review CSE113 B.Ramamurthy 11/29/2018 B.Ramamurthy.
Dilations Teacher Twins©2014.
Polygon Pizzas By: Emma Exton.
Turn to Page S.76 Describe what you know about the triangle listed to the left. What type of triangle is it? What are the labels A , B , and C ? What are.
Shaker.
Piecewise Functions.
!'!!. = pt >pt > \ ___,..___,..
Default Arguments.
class PrintOnetoTen { public static void main(String args[]) {
Web Service.
Surface Area.
Title Slide Alternative 1
Title Slide Alternative 1
Exam1 Review CSE113 B.Ramamurthy 4/17/2019 B.Ramamurthy.
Neighbor search order: Top-Left-Right-Bottom
Unit 1 Transformations in the Coordinate Plane
Determinants of 2 x 2 and 3 x 3 Matrices
Unit 1 Transformations in the Coordinate Plane
Chapter 14 Drawing in a Window
Chapter 11 Classes.
11.7 Perimeters and Areas of Similar Figures
Chapter 16 Drawing in a Window
Building pattern  Complete the following tables and write the rule 
Domain & Range Algebra 1, Unit 3, Lesson 3.
Presentation transcript:

Работа с графикой в C++ Builder Лекция №3 Работа с графикой в C++ Builder

Основные понятия Canvas (канва, холст) – область компонента, на которой можно рисовать или отображать готовые изображения 10 20 Canvas->Pixels[10][20] = clBlue;

Рисование линий void __fastcall MoveTo(int X, int Y); void __fastcall LineTo(int X, int Y); void __fastcall MoveTo(int X, int Y); void __fastcall LineTo(int X, int Y); void __fastcall TForm1::FormPaint(TObject *Sender) { Canvas->MoveTo(20, 15); Canvas->LineTo(255, 82); }

Рисование линий void __fastcall TForm1::FormPaint(TObject *Sender) { Canvas->MoveTo(60, 20); Canvas->LineTo(60, 122); Canvas->LineTo(264, 122); Canvas->LineTo(60, 20); }

Рисование полилинии void __fastcall Polyline(const Types::TPoint* Points, const int Points_Size); void __fastcall TForm1::FormPaint(TObject *Sender) { TPoint Pt[] = { Point(60, 20), Point(60, 122) }; Canvas->MoveTo(Pt[0].x, Pt[0].y); Canvas->LineTo(Pt[1].x, Pt[1].y); } void __fastcall TForm1::FormPaint(TObject *Sender) { TPoint Pt[7]; Pt[0] = Point(20, 50); Pt[1] = Point(180, 50); Pt[2] = Point(180, 20); Pt[3] = Point(230, 70); Pt[4] = Point(180, 120); Pt[5] = Point(180, 90); Pt[6] = Point(20, 90); Canvas->Polyline(Pt, 7); }

Рисование полилинии void __fastcall TForm1::FormPaint(TObject *Sender) { TPoint Pt[7]; Pt[0] = Point(20, 50); Pt[1] = Point(180, 50); Pt[2] = Point(180, 20); Pt[3] = Point(230, 70); Pt[4] = Point(180, 120); Pt[5] = Point(180, 90); Pt[6] = Point(20, 90); HDC hDC = Canvas->Handle; Canvas->MoveTo(20, 30); PolylineTo(hDC, Pt, 7); Canvas->LineTo(20, 110); }

Рисование полилинии void __fastcall TForm1::FormPaint(TObject *Sender) { TPoint Pt[15]; DWORD lpPts[] = { 4, 4, 7 }; // Figure 1 Pt[0] = Pt[3] = Point(50, 20); Pt[1] = Point(20, 60); Pt[2] = Point(80, 60); // Figure 2 Pt[4] = Pt[7] = Point(70, 20); Pt[5] = Point(100, 60); Pt[6] = Point(130, 20); // Figure 3 Pt[8] = Pt[14] = Point(145, 20); Pt[9] = Point(130, 40); Pt[10] = Point(145, 60); Pt[11] = Point(165, 60); Pt[12] = Point(180, 40); Pt[13] = Point(165, 20); HDC hDC = Canvas->Handle; PolyPolyline(hDC, Pt, lpPts, 3); }

Рисование полигона void __fastcall TForm1::FormPaint(TObject *Sender) { TPoint Pt[7]; Pt[0] = Point(20, 50); Pt[1] = Point(180, 50); Pt[2] = Point(180, 20); Pt[3] = Point(230, 70); Pt[4] = Point(180, 120); Pt[5] = Point(180, 90); Pt[6] = Point(20, 90); Canvas->Polygon(Pt, 7); }

Рисование полигона void __fastcall TForm1::FormPaint(TObject *Sender) { TPoint Pt[12]; int lpPts[] = { 3, 3, 3, 3 }; // Top Triangle Pt[0] = Point(125, 10); Pt[1] = Point( 95, 70); Pt[2] = Point(155, 70); // Left Triangle Pt[3] = Point( 80, 80); Pt[4] = Point( 20, 110); Pt[5] = Point( 80, 140); // Bottom Triangle Pt[6] = Point( 95, 155); Pt[7] = Point(125, 215); Pt[8] = Point(155, 155); // Right Triangle Pt[9] = Point(170, 80); Pt[10] = Point(170, 140); Pt[11] = Point(230, 110); HDC hDC = Canvas->Handle; PolyPolygon(hDC, Pt, lpPts, 4); }

Рисование прямоугольников void __fastcall Rectangle(int X1, int Y1, int X2, int Y2); Canvas->Rectangle(20, 20, 226, 144); void __fastcall TForm1::FormPaint(TObject *Sender) { RECT Recto; Recto.left = 328; Recto.top = 125; Recto.right = 48; Recto.bottom = 25; Canvas->Rectangle(Recto); }

Рисование окружностей void __fastcall Ellipse(int X1, int Y1, int X2, int Y2); Canvas->Ellipse(20, 20, 226, 144); void __fastcall TForm1::FormPaint(TObject *Sender) { TRect Recto(328, 125, 28, 8); Canvas->Ellipse(Recto); }

Характеристики линий void __fastcall TForm1::FormPaint(TObject *Sender) { Canvas->Pen->Color = clRed; Canvas->MoveTo(20, 15); Canvas->LineTo(255, 82); }

Характеристики линий void __fastcall TForm1::FormPaint(TObject *Sender) { Canvas->Pen->Style = psDashDotDot; Canvas->Pen->Width = 1; Canvas->Pen->Color = TColor(RGB(255, 25, 5)); Canvas->Rectangle(20, 22, 250, 125); }

Характеристики кисти void __fastcall TForm1::FormPaint(TObject *Sender) { Canvas->Brush->Color = static_cast<TColor>(RGB(255, 2, 5)); TPoint Pt[3]; // Top Triangle Pt[0] = Point(125, 10); Pt[1] = Point( 95, 70); Pt[2] = Point(155, 70); Canvas->Brush->Color = clGreen; Canvas->Polygon(Pt, 2); // Left Triangle Pt[0] = Point( 80, 80); Pt[1] = Point( 20, 110); Pt[2] = Point( 80, 140); Canvas->Brush->Color = clRed; // Bottom Triangle Pt[0] = Point( 95, 155); Pt[1] = Point(125, 215); Pt[2] = Point(155, 155); Canvas->Brush->Color = clYellow; // Right Triangle Pt[0] = Point(170, 80); Pt[1] = Point(170, 140); Pt[2] = Point(230, 110); Canvas->Brush->Color = clBlue; }

Характеристики кисти void __fastcall TForm1::FormPaint(TObject *Sender) { LOGBRUSH LogBrush; LogBrush.lbStyle = BS_HATCHED; LogBrush.lbColor = RGB(255, 0, 255); LogBrush.lbHatch = HS_DIAGCROSS; HBRUSH NewBrush = CreateBrushIndirect(&LogBrush); Canvas->Brush->Handle = NewBrush; Canvas->Rectangle(20, 12, 250, 175); }