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

Current graphics brush Brush

The object of the current brush returned by the Brush and is of type GraphABCBrush:

function Brush: GraphABCBrush;

Class GraphABCBrush has the following interface:

type   GraphABCBrush = class     property NETBrush: System.Drawing.Brush;     property Color: GraphABC.Color;     property Style: BrushStyleType;     property Hatch: HatchStyle;     property HatchBackgroundColor: GraphABC.Color;     property GradientSecondColor: GraphABC.Color;   end;

Class properties GraphABCBrush are described in the following table:

property Brush: System.Drawing.Brush; Current brush

property Color: GraphABC.Color; Color brushes

property Style: BrushStyleType; Styling brush

property Hatch: HatchStyle; Shading brushes

property HatchBackgroundColor: GraphABC.Color; The color of the background brush stroke

property GradientSecondColor: GraphABC.Color; The second color gradient brush

Example .

Brush.Color := clRed;

Brush.Style := bsHatch;

Brush.Hatch := bhBackwardDiagonal;

The brush styles

The brush styles are defined enum type BrushStyleType:

type BrushStyleType = (bsSolid, bsClear, bsHatch, bsGradient);

Constants have the following meanings:

bsSolid Solid brush (default)

bsClear Transparent brush

bsHatch Dashed brush

bsGradient Gradient brush

For all brushes used the Color property. For the stroke of the brush additionally, you can set properties Hatch and HatchBackgroundColor, for the gradient - property GradientSecondColor.

Example

// Graphics. Properties of a brush and pen

uses GraphABC;

begin

Window.Title := ' Properties of a brush and pen ‘;

Pen.Color := Color.Red;

Pen.Width := 3;

Pen.Style := psDashDot;

Brush.Style := bsHatch;

Brush.Color := Color.Green;

Brush.Hatch := bhDiagonalBrick;

Brush.HatchBackgroundColor := Color.Bisque;

Rectangle(20, 20, Window.Width - 20, Window.Height - 20);

end.

Routines for working with font

Output text in the current font. Access to the properties of the current font can be carried out both in procedural and object-oriented style.

Procedures and functions for accessing the properties of the font are grouped in pairs: if Prop - property name pen, the function PenProp returns the value of this property and the procedure SetPenProp(p) sets this property:

procedure SetFontSize(size: integer);

Sets the size of the current font in points

function FontSize: integer;

Returns the size of the current font in points

procedure SetFontName(name: string);

Sets the name of the current font

function FontName: string;

Returns the name of the current font

procedure SetFontColor(c: Color);

Sets the current font color

function FontColor: Color;

Returns the current font color

procedure SetFontStyle(fs: integer);

Sets the current font style

function FontStyle: integer;

Returns the current font style. In order to determine the width and height of the string in the current font settings use the following functions:

function TextWidth(s: string): integer;

Returns the width of the string s, in pixels, using the current settings font

function TextHeight(s: string): integer;

Returns the height of the string s, in pixels, using the current settings font

The current font Font

The object of the current font returned by the Font and type is GraphABCFont:

function Font: GraphABCFont;

Class GraphABCFont has the following interface: you can also change the properties of the current pen via the Font object.

type

GraphABCFont = class

property NETFont: System.Drawing.Font;

property Color: GraphABC.Color;

property Style: integer;

property Size: integer;

property Name: string;

end;

Class properties GraphABCFont are described in the following table:

property Font: System.Drawing.Font;

The current font .

property Color: GraphABC.Color;

Font color

property Style: FontStyleType;

Font style

property Size: integer;

Font size in points

property Name: string;

Font name

Font styles

The font style specifies the enum type FontStyleType, which contains the following constants:

fsNormal - normal;

fsBold - bold;

fsItalic - sloping.

fsBoldItalic - bold italic;

fsUnderline - underlined;

fsBoldUnderline - bold underline;

fsItalicUnderline - italic underline;

fsBoldItalicUnderline - bold italic or underlined.