Presentation on the topic "Graphics in ABC Pascal". Electronic presentation of the lesson on the topic "Graphics in Turbo Pascal programming" Presentation on the topic Pascal ABC graphics mode

Window control
SetWindowSize(w,h);
sets the size of the graphics window
SetWindowWidth(w);
sets the width of the graphics window
SetWindowHeight(h);
sets the height of the graphics window
SetWindowTitle('Title');
change window title

Clearing the graphic
window
ClearWindow;
clears the graphics window with white
ClearWindow(color);
clears the graphics window with the specified color.
uses GraphABC;
begin
ClearWindow;
ClearWindow(clMoneyGreen);
end.
green money color

Graphic
primitives
Dot
Line
Rectangle
Circle
Ellipse
Sector
Arc

Dot
SetPixel(x,y,color);
paints one pixel with coordinates (x,y)
color
uses GraphABC;
begin
SetPixel(300,200,clred);
end.

lines
LineTo(x,y);
draws a line from the current pen position to a point
(x,y)
the pen coordinates also become
equal to (x,y)
x,y
uses GraphABC;
Begin
LineTo(300,200);
end.

lines
MoveTo(x,y);
sets the current drawing position
point (x,y)
x1,y1
x2,y2
uses GraphABC;
Begin
MoveTo(150,50);
LineTo(500,250);
end.

lines
Line(x1,y1,x2,y2);
draws a line segment starting at (x1,y1) and ending
at the point (x2,y2)
x1,y1
x2,y2
uses GraphABC;
begin
line(100,50,500,250);
end.

colors
clAquamarine
clBisque
cl Blue
clBurlyWood
clChocolate
clCornsilk
clDarkBlue
clDarkGray
clDarkMagenta
clDarkOrchid
clDarkSeaGreen
clDarkViolet
clDeepSkyBlue
clAzure
clBlack
clBlueViolet
clCadetBlue
clCoral
cl Crimson
clDarkCyan
clDarkGreen
clDarkOliveGreen
clDarkRed
clDarkSlateBlue
clDeepPink
clDimGray
clBeige
clBlanchedAlmond
clBrown
clChartreuse
clCornflowerBlue
clCyan
clDarkGoldenrod
clDarkKhaki
clDarkOrange
clDarkTurquoise
clDarkSlateGray
clDarkSalmon
clDodgerBlue

colors
clFuchsia
clGold
clGreen
clHotPink
clIvory
clLavenderBlush
clLightBlue
clGainsboro
clGoldenrod
clGreenYellow
clIndianRed
clKhaki
clLawnGreen
clLightCoral
clGhostWhite
clGray
clHoneydew
clIndigo
clLavender
clLemonChiffon
clLightCyan
clLightGoldenrodYe
clLightGray
clLightGreen
llow
clLightPink
clLightSalmon
clLightSeaGreen
clLightSkyBlue
clLightSlateGray
clLightSteelBlue
clLightYellow
clLime
clLimeGreen
clLinen
clMagenta
clMaroon
clMediumAquamari
clMediumBlue
clMediumOrchid
ne
clMediumPurple
clMediumSeaGreen clMediumSlateBlue
clMoneyGreen
clPlum
clMistyRose
clRandom - random
color from the whole palette
Pascal colors

Line color
SetPenColor(color);
sets the pen color specified by the parameter
color
uses GraphABC;
begin
SetPenColor(clred);
line(30,30,400,350);
end.

Dotted line
SetPenStyle(<…>);
sets pen style
uses GraphABC;
begin
setpencolor(clred);
SetPenWidth(4);
SetPenStyle(psSolid);(Solid)
Line(10,75,350,75);
SetPenStyle(psDash);(Dashed)
Line(10,100,350,100);
SetPenStyle(psDot); (dotted)
Line(10,125,350,125);
SetPenStyle(psDashDot); (dash-dot)
Line(10,150,350,150);
SetPenStyle(psDashDotDot);
(Alternative dashed line)
Line(10,175,350,175);
end.

Line thickness
SetPenWidth(n);
sets the width (thickness) of the pen to n
pixels
uses GraphABC;
begin
setpenwidth(20);
setpencolor(clred);
line(30,30,400,350);
end.

Triangle
Line(x1,y1,x2,y2);
LineTo(x,y);
uses GraphABC;
begin
setpenwidth(20);
setpencolor(clred);
line(300,100,500,300);
lineto(100,300);
lineto(300,100);
floodfill(300,200,clgreen);
end.

Rectangle
Rectangle(x1,y1,x2,y2);
draws a rectangle given by coordinates
opposite vertices (x1,y1) and (x2,y2)
x1,y1
x2,y2
uses GraphABC;
begin
Rectangle(50,50,200,200);
end.

Color fill
FloodFill(x,y,color);
fills an area of ​​the same color with color, starting at a dot
(x,y)
x1,y1
x2,y2
uses GraphABC;
begin
Rectangle(50,50,200,200);
FloodFill(100,100,clBlue);
end.

brush fill
SetBrushColor(color);
sets brush color, extends to closed
circuit whose description follows the installation procedure
brush colors
uses GraphABC;
Begin
SetBrushColor(clGreen);
Rectangle(50,50,300,300);
end.

brush fill
SetBrushStyle(<…>);
sets the brush style type
bsSolid
Solid brush (according to
default)
bsClear
Transparent brush
bshatch
line brush
bsGradient
gradient brush

brush fill
Brush stroke styles are specified by the enumerated type
SetBrushHatch(<…>);
Constants are defined for brush stroke styles:
uses GraphABC;
Begin
SetBrushStyle(bsHatch);
By
default
style is set to 0 -
solid
pouring
color.
SetBrushHatch(bhHorizont
al);
Rectangle(10,10,100,100);

end.

brush fill
For a stroke brush, you can additionally set
property:
SetHatchBrushBackgroundColor(clGold) ;
uses GraphABC;
Begin
SetBrushStyle(bsHatch);
By
default
style is set to 0 -
SetHatchBrushBackgroundColor(cl
solid
pouring
Gold);
color.
SetBrushColor(clCoral);
SetBrushHatch(bhHorizontal);

Outline color and thickness
SetPenWidth(w);
SetPenColor(color);
uses GraphABC;
begin
SetPenColor(clred);
SetPenWidth(20);
Rectangle(50,50,200,200);
FloodFill(100,100,clBlue);
end.

Circle
circle(x,y,r);
draws a circle centered at (x,y) and
radius r
r
x1,y1
uses GraphABC;
begin
Circle(500,200,100);
FloodFill(500,200,clred);
end.

Ellipse
Ellipse(x1,y1,x2,y2);
draws an ellipse given its described
rectangle with coordinates of opposite
vertices (x1,y1) and (x2,y2).
x1,y
1
x1,y
1
uses GraphABC;
begin
Ellipse(50,50,200,350);
FloodFill(50+100,50+100,clred);
Ellipse(250,150,550,300);
FloodFill(250+100,150+100,clBlue);
end.
x2,y
2
x2,y
2

arc of a circle
Arc(x,y,r,a1,a2);
draws a circular arc centered at (x,y) and with radius r,
enclosed between two rays forming angles a1 and a2
with the OX axis (a1 and a2 are real, specified in degrees and
counted counterclockwise)
r
x,y
uses GraphABC;
Begin
SetPenWidth(10);
*
Arc(300,250,150,45,135)
;
end.

Sector
Pie(x,y,r,a1,a2);
draws a sector of a circle bounded by an arc (parameters
procedures have the same meaning as in procedure Arc)
uses GraphABC;
begin
Pie(300,200,100,0,90);
FloodFill(300+10,200-10,
clAquamarine);
end.

Text output
TextOut(x,y,'string');
outputs a line of text at position (x,y) (point (x,y) specifies
the top left corner of the rectangle that will contain
text)
uses GraphABC;
begin
TextOut(100,30,"Square");
Rectangle(50,50,200,200);
FloodFill(55,55,clBlue);
end.

Font actions
SetFontName('name');
sets the name of the font
SetFontColor(color);
sets the font color
SetFontSize(sz);
sets the font size in points
SetFontStyle(fs);
sets the font style

Font name
The default font is set to
Name MS Sans Serif
The most common fonts are
Times New Roman, Arial and Courier New
The font name can be typed without taking into account
register
For example:
SetFontName('Times New Roman');

Font style
fsNormal - normal
Specified by named constants:
fsBold - bold
fsItalic - italic
fsBoldItalic - bold italic
fsUnderline - underlined
fsBoldUnderline - bold underline
fsItalicUnderline - italic underline
fsBoldItalicUnderline - bold italic underline

For example:
uses GraphABC;
Begin
SetFontName('Arial');
SetFontSize(20);
SetFontColor(clRed);
TextOut(10,10,'regular");
SetFontStyle(fsItalic);
SetFontColor(clBlue);
TextOut(10,50,'Italic');
SetFontStyle(fsBold);
SetFontColor(clRandom);
TextOut(10,90,'bold");
SetFontStyle(fsUnderline);
SetFontColor(clRandom);
TextOut(10,130,'underlined');
SetFontStyle(fsBoldItalicUnderline);
SetFontColor(clRandom);
TextOut(10,170,'bold, italic, underline");
end.

Used
colors
The color can also be set using the function
RGB(r,g,b) where r, g and b are integers in
range from 0 to 255.
The function returns an integer value that is
color code that contains red, green and
blue components with intensities r, g and b
respectively (0 corresponds to the minimum
intensity, 255 - maximum).
RGB(255,255,255) - matches
white color.
RGB(0,0,0) - corresponds to black color.

For example:
uses GraphABC;
begin
clearwindow(rgb(200,150,250));
TextOut(93,30, "Square");
Rectangle(50,50,200,200);
FloodFill(55,55,clRed);
TextOut(275,30," Ellipse");
Ellipse(250,50,350,200);
FloodFill(250+50,50+50,clYellow);


Serogodskaya N.I. GBOU school №118 SWAO

Graphics mode

Informatics teacher GBOU school №118 SWAO

Serogodskaya N.I.

Moscow city


Lesson #1


Serogodskaya N.I. GBOU secondary school №1 building 2

Goals

Tutorials:

to acquaint students with the Pascal ABC software environment, with the structure of the program in Pascal;

to form students' primary knowledge on the application of the studied material.

Developing:

to teach to analyze, generalize and systematize;

enrich students' vocabulary.

Educational:

develop information culture students, the ability for independent and collective activity, reflection.


Serogodskaya N.I. GBOU secondary school №1 building 2

  • Students should know:
  • basic commands and functions in the GraphPascal ABC environment;
  • rules for the design and operation of the program;
  • Students should be able to:
  • develop programs for drawing graphic primitives;
  • perform the necessary actions with the program;
  • develop procedures with and without parameters for drawing objects;
  • develop programs based on typical algorithm constructions;
  • Additionally: solve more complex graphics problems

Serogodskaya N.I. GBOU secondary school №1 building 2

To work in graphics mode, you need to connect the module GraphABC :

The PascalABC graphic screen contains 640 points by horizontal and 400 points vertically.

Please note that the origin is the upper left corner of the screen, in contrast to the coordinate axes in mathematics


Serogodskaya N.I. GBOU secondary school №1 building 2

SCREEN CONTROL

SetWindowWidth(w) - sets the width of the graphics window;

SetWindowHeight(h) - sets the height of the graphics window;


Serogodskaya N.I. GBOU secondary school №1 building 2

ClearWindow; - clears the graphics window with white color.

ClearWindow(cl color name ); - Clears the graphics window with the specified color.

ClearWindow(clMoneyGreen);

green money color


Serogodskaya N.I. GBOU secondary school №1 building 2

Graphics Primitives

  • Dot
  • Line
  • Rectangle
  • Circle
  • Ellipse
  • Sector

Serogodskaya N.I. GBOU secondary school №1 building 2

SetPixel(x,y,cl color name ) - paints one pixel at coordinates (x,y,) with a color

SetPixel(300,200,clred);


Serogodskaya N.I. GBOU secondary school №1 building 2

LineTo(x,y) - draws a segment from the current pen position to the point (x,y); the pen coordinates also become equal to (x,y).

beginLineTo(300,200);


Serogodskaya N.I. GBOU secondary school №1 building 2

lines

Line(x1,y1,x2,y2) - draws a segment with the beginning at the point (x1,y1) and the end at the point (x2,y2).

line(100,50,500,250);


Serogodskaya N.I. GBOU secondary school №1 building 2

Colors Used

clBlack - black clPurple - violet clWhite - white clMaroon - Dark red clRed - red clNavy - dark blue clGreen - green clBrown - brown cl Blue - blue clSkyBlue – blue clYellow - yellow clCream – cream

clAqua - turquoise clOlive – olive clFuchsia - lilac clTeal – blue-green clGray - dark grey clLime - bright green clMoneyGreen - the color of green money clLtGray – light gray clDkGray - dark grey clMedGray - grey clSilver – silver

Random(16777215) - a random color from the entire Pascal color palette


Serogodskaya N.I. GBOU secondary school №1 building 2

Line color

SetPenColor(color) - sets the pen color specified by the parameter color .

setpencolor(clred);

line(30,30,400,350);


Serogodskaya N.I. GBOU secondary school №1 building 2

Dotted line

SetPenStyle(); -

sets the pen style specified by the number.

setpencolor(clred);

SetPenStyle(1); (1 - long stroke)

Line(10,100,350,100);

SetPenStyle(2); (2 - short stroke)

Line(10,125,350,125);

SetPenStyle(3); (3 - dash-dotted line)

Line(10,150,350,150);


Serogodskaya N.I. GBOU secondary school №1 building 2

Line thickness

SetPenWidth(n) - sets the width (thickness) of the pen to n pixels.

setpenwidth(20);

setpencolor(clred);

line(30,30,400,350);


Serogodskaya N.I. GBOU secondary school №1 building 2

Triangle

Drawn by procedures

Line(x1,y1,x2,y2); LineTo(x,y);

Program treugolnik;

setpenwidth(20);

setpencolor(clPurple);

line(300,100,500,300);

lineto(100,300);

lineto(300,100);

floodfill(300,200, clSkyBlue) ;


Serogodskaya N.I. GBOU secondary school №1 building 2

Rectangle

Rectangle(x1,y1,x2,y2) - draws a rectangle given by the coordinates of opposite vertices (x1,y1) and (x2,y2).

Program pryamougolnik;

Rectangle(50,50,200,200);


Serogodskaya N.I. GBOU secondary school №1 building 2

Color fill

FloodFill(x,y,color) - fills an area of ​​the same color with color, starting at (x,y).

Program pryamougolnik;

Rectangle(50,50,200,200);


Serogodskaya N.I. GBOU secondary school №1 building 2

brush fill

SetBrushColor(color) - sets the color of the brush.

The brush fill extends to closed loop , whose description follows the procedure for setting the brush color.

Program zalivka_kist;

SetBrushColor( clMoneyGreen);

Rectangle(50,50,300,300);


Serogodskaya N.I. GBOU secondary school №1 building 2

brush fill

SetBrushStyle(number from 0 to 7 or title) - sets the style of the brush, given by a number or a symbolic constant.

Program p12_filling;

uses GraphABC;

SetBrushColor(clAqua);

SetBrushStyle(1);

Rectangle(10,10,100,100);

SetBrushColor(clRed);

SetBrushStyle(2);

Rectangle(110,10,200,100);

SetBrushColor(clBlue);

SetBrushStyle(3);

Rectangle(210,10,300,100);

SetBrushColor(clGreen);

SetBrushStyle(4);

Rectangle(10,110,100,210);

SetBrushColor(clYellow);

SetBrushStyle(5);

Rectangle(110,110,200,210);

SetBrushColor(clBlack);

SetBrushStyle(6);

Rectangle(210,110,300,210);

The default style is 0 - solid color fill.


Serogodskaya N.I. GBOU secondary school №1 building 2

brush fill

SetBrushPicture('fname') -

sets the pattern stored in file fname as the brush pattern, while the current color of the brush is ignored when painting.

begin SetBrushPicture("brush4.bmp"); Ellipse(0,0,640,400);


Serogodskaya N.I. GBOU secondary school №1 building 2

Outline color and thickness

set by procedures SetPenWidth(w); SetPenColor(color);

Program pryamougolnik;

SetPenColor(clred);

SetPenWidth(20);

Rectangle(50,50,200,200);

FloodFill(100,100, clSkyBlue);


Serogodskaya N.I. GBOU secondary school №1 building 2

Circle

Circle(x,y,r) - draws a circle centered at (x,y) with radius r .

Circle(500,200,100);

FloodFill(500,200, clGreen);


Serogodskaya N.I. GBOU secondary school №1 building 2

Ellipse

Ellipse(x1,y1,x2,y2) - draws an ellipse given by its circumscribed rectangle with coordinates of opposite vertices (x1,y1) and (x2,y2).

Ellipse(50,50,200,350);

FloodFill(50+100,50+100,clred);

Ellipse(250,150,550,300);

FloodFill(250+100,150+100,clBlue);


Serogodskaya N.I. GBOU secondary school №1 building 2

arc of a circle

Arc(x,y,r,a1,a2)- Draws an arc of a circle centered at (x,y) and with radius r enclosed between two rays forming angles a1 and a2 with the OX axis (a1 and a2 are real, given in degrees and counted counterclockwise).

SetPenWidth(10);

Arc(300,250,150,45,135);


Serogodskaya N.I. GBOU secondary school №1 building 2

Sector

Pie(x,y,r,a1,a2) - draws a circle sector bounded by an arc (the procedure parameters have the same meaning as in the Arc procedure).

Pie(300,200,100,0,90);

FloodFill(300+10,200-10,clAqua);


Serogodskaya N.I. GBOU secondary school №1 building 2

Bibliography

  • Fedorenko Yu. Algorithms and programs in Turbo Pascal .
  • Faronov V.V. Turbo Pascal 7.0. Starting course. - Knowledge, 1998. -620 p.
  • Gryzlov V.I., Gryzlova T.P. Turbo Pascal 7.0. - M.: "DMK", 2000. - 416 p.
  • Zuev E.A. Turbo Pascal 6.0 programming language. - M.: Unitech, 1992. - 298s., ill.
  • Zuev E.A. TurboPascal. Practical Programming .

Serogodskaya N.I. GBOU secondary school №1 building 2

Thank you for your attention!

Graphics in the programming environment

TurboPascal

EADC teacher: Neverova I.Yu.


Lesson plan:

  • Features of connecting the graphics mode in the Turbo Pascal programming environment
  • Drawing up the structure of the program
  • Calculation of coordinates for procedures
  • Features of drawing with a contour and filling with color
  • Review of sample programs

I.G. Semakin, A.P. Shestakov. Fundamentals of Programming, pp.88-98, 398-409.


Graphical features of the Turbo Pascal language - the Graph library

  • The connection of the graphic library is prescribed in the program by the procedure:
  • To set the graphics mode of the screen, use the procedure:

InitGraph(Var Driver, Mode: Integer, Path: String);

Path to graphics library

Driver mode

Driver code


Operating modes of the graphics program

  • Text mode. Used to write a program. The transition from the program text mode to the graphical program execution mode is carried out by the RUN procedure or by pressing Ctrl+F9.
  • Graphic mode. The image is built from individual dots (pixels). The operating mode of the VGAHi graphics driver corresponds to a graphics grid of 640x480 pixels, with a palette of 16 colors, automatic driver type detection and graphics mode setting. Exit the program to program text mode with the Enter key.

Program Structure

Program ricunok ; (program title)

Use Graph ; (graphics library connection)

Var Dr , Md: integer ; (description of driver variables)

Begin (beginning of program body)

Dr:= Detect ; (driver type)

InitGraph(Dr , Md ,‘ C:\ TP 70\ BGI ’); (activation of graphics with

graph library)

Readln ; (program delay)

end. (end of program)


Calculation of coordinates for geometric shapes output procedures

Bar(50,100,150,150)

Fillellipse(250,125,25,25)

VGA type monitor


Using graphic procedures

A program that displays the Japanese flag in white with a red circle in the center

on a turquoise screen background.

VarDr, Md: Integer;

InitGraph(Dr, Md, 'C:\TP70\BGI');

ClearView Port ; (Screen cleaning, to set the screen background)

SetBkColor(Cyan); (Set screen background color to cyan)

SetFillStyle(1, 15); (Rectangle fill color by pattern and color)

Bar(10, 10, 410, 210); (Drawing a filled rectangle by coordinates)

setcolor(4); (Setting the color of the circle lines)

Circle(210, 110, 30); (Drawing a circle with center coordinate and radius)

SetFillStyle(1, 4); (Circle fill color by pattern and color)

FloodFill(200, 100, 4); (Filling the color of a closed figure around the coordinate to the borders)

Readln ; (program delay)

Close Graph ; (exit graphics mode)

end. (end of program body)


Program that displays a flowchart

vardr,md:integer;

begin dr:=detect;

setlinestyle(0,1,3);

ellipse(320,40,0,360,50,10);

line(320,50,320,70);

line(270,70,390,70); line(390,70,370,100); line(370,100,250,100); line(250,100,270,70); line(320,100,320,120);

rectangle(260,120,380,150);

line(320,150,320,170); line(320,170,400,190); line(400,190,320,210); line(320,210,240,190); line(240,190,320,170);

line(240,190,200,190); line(200,190,200,210);

rectangle(140,210,260,240);

line(200,240,200,260);

rectangle(140,260,260,290);

line(200,290,200,310);

Line(140,310,260,310); Line(260,310,240,340); Line(240,340,120,340); Line(120,340,140,310); line(200,340,200,360);

line(200,360,100,360); line(100,360,100,170); line(100,170,320,170); line(400,190,440,190);

line(440,190,440,380); line(440,380,320,380); line(320,380,320,400);

ellipse(320,410,0,360,50,10);

settextstyle(7,0,2);

outtextXY(300,75,'F"); outtextXY(300,125,"N:=0"); outtextXY(292,178,'N


The result of the program execution


Write a program that displays the following figure

Program paravoz;

vardr,md:integer;

begin dr:=detect;

initgraph(dr,md,"C:\tp70\bgi");

SetFillStyle(1, 2);

Bar(150,30,250,225);

SetFillStyle(1, 1);

bar(180,55,220,115);

SetFillStyle(1, 2);

Bar(250,120,450,225);

Line(350,65,390,65);

Line(350,65,360,120);

Line(390,65,380,120);

Line(380,120,360,120);

SetFillStyle(1,1);

Sector(420,245,0,360,20,20);

Sector(300,245,0,360,20,20);

Sector(185,245,0,360,20,20);

SetFillStyle(1,7);

Sector(400,50,0,360,30,10);

Sector(425,25,0,360,20,10);

Sector(445,5,0,360,10,5);


Homework

In the workbooks Topic No. 4, complete tasks 1 and 2, on the use of graphic procedures.

Table of basic graphic procedures in Appendix 4.

slide 2

Each pixel (point) has two coordinates: x and y. The geometric dimensions of a pixel are determined by the resolution of the monitor.

slide 3

Example 1. Demonstration of connecting the GraphAbc program tochka module; uses graphabc; (connecting the GraphAbc module) begin setwindowsize(640,480);(sets the size of the graphics window) setpixel(100,120,clBlack); (sets the pen color to black and draws a point at coordinates (100,120)) end. AT this example we have seen the use of the setpixel command in a particular case. AT general view this command looks like this: setpixel (x: integer, y: integer, c: color) - draws a point with coordinates (x, y) with color c. clBlack - black clPurple - purple clWhite - white clRed - red clGreen - green clBrown - brown clBlue - blue clSkyBlue - blue clYellow - yellow

slide 4

The program for drawing a line connecting two points with coordinates (120,150) and (150,80) with a red pen color might look like this: Example 2. Demonstration of drawing a line program Linii; uses graphabc; beginsetwindowsize(640,480); setpencolor(clred); (sets pen color to red) line(120,150,300,100); (draws a segment from (120,150) to (300,100)) end.

slide 5

Example 3. Demonstration of drawing lines with different pen colors program treugolnik; uses graphabc; beginsetwindowsize(640,480); setpenwidth(5); (sets the width of the current pen. The number of pixels that form the width of the line is indicated in brackets) setpencolor(clred); (sets pen color to red) line(100,200,170,70); (draws a segment from the point at coordinates (100,200) to the point at coordinates at (170,70)) setpencolor(clGreen); (sets pen color to green) line(170,70,250,200); (draws a line from point(170,70) to point(250,200)) setpencolor(clBlue); (sets the pen color to blue) line(250,200,100,200);(draws a line from point(250,200) to point(100,200)) (results in a triangle with sides of different colors) end.

slide 6

It is important to remember: 1. When drawing a line, you can set its size (coordinates of its ends), color, width (thickness) and style. 2. To set the line style in the GraphAbc module, there is a SetPenStyle (Style) procedure, where Style are pen style constants (see Appendix to Chapter 3). 3. The line can be solid, dotted, dash-dotted, dashed. Closed figures can be painted over.

Slide 7

Example 4. Demonstration of drawing closed shapes using lines and painting them Program treug_zakrash; uses graphabc; beginsetwindowsize(640,480); clearwindow(clWhite); (clears the graphics window white) setpenwidth(3); (sets the width of the current pen) setpenstyle(pssolid); (sets the line style to a solid line) setpencolor(clgreen);(sets the pen color to green) line(100,200,170,70); (draws lines in green) line(170,70,250,200); line(250,200,100,200); floodfill(440,120,clred); (Paints triangle red) end.

Slide 8

As a result of the program execution, a triangle drawn in green and filled in red will appear on the monitor screen in the graphics window. 2. In the floodfill(x, y, c) procedure, specify the coordinate of the point (x, y), which must necessarily fall into the inner area of ​​the figure being filled.

Slide 9

Rectangles and circles can be drawn using the rectangle(x1,y1,x2,y2) and circle(x,y,r) commands, respectively. How to do this, consider the example of a program that draws a rectangle and a circle. Example 5. Demonstration of drawing a rectangle and a circle program geometry; uses graphabc; beginsetwindowsize(640,480); setpencolor(clBlue); (sets the pen color for drawing the outline of the rectangle to blue) setpenwidth(6); (sets the pen width) rectangle(50,50,250,150); (draws a rectangle given by opposite vertex coordinates) setpencolor(clred); (sets the pen color for drawing the circle outline to red) circle(350,100,60); (draws a circle centered at (350,100) with radius 60) end.

Slide 10

Demonstration of filling a rectangle and a circle and their inscriptions program geometry3; uses graphabc; beginsetwindowsize(640,480); clearwindow(clYellow); (sets background color to yellow) setpencolor(clteal); (sets the blue-green color of the pen) setpenwidth(5); (sets the line width) setbrushcolor(clolive); (sets the brush color olive) rectangle(100,100,300,200); (draws an olive-colored rectangle) setbrushcolor(clblue); (sets the brush color to blue) circle(400,150,50); (draws a blue-filled circle) setfontstyle(fsbold);(sets the font style) setfontsize(15);(sets the font size) setbrushcolor(clwhite);(sets the brush color to white) setfontcolor(clolive);(sets the font color to olive) textout (100,220,"Rectangle"); (makes an inscription) setfontcolor(clblue); (sets the font color to blue) textout(380,220,"Circle"); (makes an inscription) end.

slide 11

Graphical procedures ABC Pascal: 1. SetPixel(x,y,color: integer); - paints one pixel with coordinates (x,y) with color color. 2. Line(x1,y1,x2,y2: integer); - draws a segment from the point (x1,y1) to the point (x2,y2). 3. Circle(x,y,r: integer); - draws a circle centered at (x,y) with radius r. 4. Rectangle(x1,y1,x2,y2: integer); -draws a rectangle given by the coordinates of the opposite vertices (x1,y1) and (x2,y2). 5. TextOut(x,y: integer; s: string); - displays string s at position (x,y) (point (x,y) specifies the upper left corner of the rectangle that will contain the text from string s). 6. FloodFill(x,y,color: integer); - fills an area of ​​the same color with the color color, starting from the point (x, y). 7. FillRect(x1,y1,x2,y2: integer); - fills the rectangle specified by the coordinates of the opposite vertices (x1,y1) and (x2,y2) with the color of the current brush.

slide 12

What will be displayed on the monitor screen as a result of the execution of these programs? program graphics1; uses graphabc; beginsetpenwidth(10); setpencolor(clred); Line(100,100,270,90); end. Program graphica2; uses graphabc; beginsetpenwidth(8); setpencolor(clblue); circle(200,150,50); end.

slide 13

Rewrite in a notebook: Subject: Graphic features of the programming language. 1. Line(x1,y1,x2,y2; - segment from (x1,y1) to (x2,y2). 2. Circle(x, y, r); - circle with center at (x,y) and radius r. 3. Rectangle(x1,y1,x2,y2) - a rectangle defined by the coordinates of opposite vertices (x1,y1) and (x2,y2) 4. FloodFill(x, y, color) - fills an area of ​​the same color color color, starting from the point (x,y).

View all slides