Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
the Ministry of education and science of the Re...docx
Скачиваний:
0
Добавлен:
01.05.2025
Размер:
51 Кб
Скачать
☆

Example

// Demonstration of the transformation of the coordinate system

uses GraphABC;

begin

Window.Title := 'Преобразования системы координат';

Window.IsFixedSize := True;

Coordinate.Origin := Window.Center;

Circle(0,0,200);

for var i := 1 to 12 do

begin

Circle(0,180,10);

Coordinate.Angle := Coordinate.Angle + 30;

end;

end.

Subprogramme drawing modes

procedure SetSmoothing(sm: boolean);

Sets the antialiasing mode

procedure SetSmoothingOn;

To enable the smooth mode

procedure SetSmoothingOff;

Disables antialiasing mode

function SmoothingIsOn: boolean;

Returns True if antialiasing mode is set

procedure SetCoordinateOrigin(x0,y0: integer);

Establishes the origin to the point (x0,y0)

Example.

// The graph. Smoothing

uses GraphABC;

begin

Window.Title := 'Демонстрация сглаживания';

TextOut(40,20,'Со сглаживанием');

Pen.Width := 2;

Ellipse(40,60,300,200);

Line(340,60,600,130);

Line(600,130,340,200);

SetSmoothingOff;

TextOut(40,240,'Без сглаживания');

Ellipse(40,280,300,420);

Line(340,280,600,350);

Line(600,350,340,420);

end.

Events module GraphAbc

A graphical program continues to run even after the completed all the operators in the main program. Graphical window respond to mouse events, keyboard, event resizing the window and the window-closing event. These events are defined in the module GraphABC and represent a procedural variables:

OnMouseDown: procedure (x,y,mousebutton: integer);

Event clicking. (x,y) coordinates of the mouse cursor at the time of an event, mousebutton = 1 if the left mouse button is pressed, and 2, if you press the right mouse button

OnMouseUp: procedure (x,y,mousebutton: integer);

Event depressing the mouse button. (x,y) coordinates of the mouse cursor at the time of an event, mousebutton = 1, if pressed left mouse button, and 2, if pressed the right mouse button

OnMouseMove: procedure (x,y,mousebutton: integer);

The mouse move event. (x,y) coordinates of the mouse cursor at the time of an event, mousebutton = 0, if the mouse button is not pressed, 1 if the left mouse button is pressed, and 2, if you press the right mouse button.

OnKeyDown: procedure (key: integer);

Key event. key - virtual code of the key pressed

OnKeyUp: procedure (key: integer);

Event of pressing keys. key - virtual code of pressed keys

OnKeyPress: procedure (ch: char);

Event pressing the character keys. ch - the character generated by a character key is pressed

OnResize: procedure;

Event changes the size of the graphics window

OnClose: procedure;

Closing event of the graphics window

If the variable is an event is assigned to some procedure, it is called a handler for this event and is automatically called when the specified event occurs.

The x and y parameters in handlers, OnMouseDown, OnMouseUp and OnMouseMove define the coordinates of the mouse cursor at the time of occurrence of the event parameter mousebutton is 0 if the mouse button is not pressed, 1 if the left mouse button is pressed, and 2, if you press the right mouse button. The key parameter in handlers, OnKeyDown and OnKeyUp defines a virtual key that was pressed. Option ch in the OnKeyPress handler defines the inserted character.