Class TAsphyreCanvas

Description Hierarchy Fields Methods Properties

Unit

Declaration

type TAsphyreCanvas = class(TObject)

Description

2D canvas specification for rendering points, lines, filled shapes and images using gradient color fills, different blending effects, and alpha transparency.

Hierarchy

  • TObject
  • TAsphyreCanvas

Overview

Methods

Public procedure Circle(const Pos: TPoint2; Radius: Single; Steps: Integer; Color: Cardinal);
Public procedure DrawIndexedTriangles(Vertices: PPoint2; Colors: PLongWord; Indices: PLongInt; NoVertices, NoTriangles: Integer; Effect: TBlendingEffect = beNormal); virtual; abstract;
Public procedure Ellipse(const Pos, Radius: TPoint2; Steps: Integer; Color: Cardinal);
Public procedure FillArc(x, y, Radius, InitPhi, EndPhi: Single; Steps: Integer; const Colors: TColor4; Effect: TBlendingEffect = beNormal); overload;
Public procedure FillArc(const Pos, Radius: TPoint2; InitPhi, EndPhi: Single; Steps: Integer; const Colors: TColor4; Effect: TBlendingEffect = beNormal); overload;
Public procedure FillCircle(x, y, Radius: Single; Steps: Integer; const Colors: TColor4; Effect: TBlendingEffect = beNormal);
Public procedure FillEllipse(const Pos, Radius: TPoint2; Steps: Integer; const Colors: TColor4; Effect: TBlendingEffect = beNormal);
Public procedure FillHexagon(const Mtx: TMatrix3; c1, c2, c3, c4, c5, c6: Cardinal; Effect: TBlendingEffect = beNormal);
Public procedure FillQuad(const Points: TPoint4; const Colors: TColor4; Effect: TBlendingEffect = beNormal);
Public procedure FillRect(Left, Top, Width, Height: Integer; Color: Cardinal; Effect: TBlendingEffect = beNormal); overload;
Public procedure FillRect(const Rect: TRect; const Colors: TColor4; Effect: TBlendingEffect = beNormal); overload;
Public procedure FillRect(const Rect: TRect; Color: Cardinal; Effect: TBlendingEffect = beNormal); overload;
Public procedure FillRibbon(const Pos, InRadius, OutRadius: TPoint2; InitPhi, EndPhi: Single; Steps: Integer; const Colors: TColor4; Effect: TBlendingEffect = beNormal); overload;
Public procedure FillRibbon(const Pos, InRadius, OutRadius: TPoint2; InitPhi, EndPhi: Single; Steps: Integer; InColor1, InColor2, InColor3, OutColor1, OutColor2, OutColor3: Cardinal; Effect: TBlendingEffect = beNormal); overload;
Public procedure FillTri(const p1, p2, p3: TPoint2; c1, c2, c3: Cardinal; Effect: TBlendingEffect = beNormal);
Public procedure Flush(); virtual; abstract;
Public procedure FrameHexagon(const Mtx: TMatrix3; Color: Cardinal);
Public procedure FrameRect(const Rect: TRect; const Colors: TColor4; Effect: TBlendingEffect = beNormal); overload;
Public procedure FrameRect(const Points: TPoint4; const Colors: TColor4; Effect: TBlendingEffect = beNormal); overload;
Public procedure HorizLine(Left, Top, Width: Single; Color: Cardinal; Effect: TBlendingEffect = beNormal); overload;
Public procedure HorizLine(Left, Top, Width: Single; Color1, Color2: Cardinal; Effect: TBlendingEffect = beNormal); overload;
Public procedure Line(const Src, Dest: TPoint2; Color: Cardinal); overload;
Public procedure Line(x1, y1, x2, y2: Single; Color: Cardinal); overload;
Public procedure Line(const Src, Dest: TPoint2; Color1, Color2: Cardinal); overload; virtual; abstract;
Public procedure LineArray(Points: PPoint2; Color: Cardinal; NoPoints: Integer); virtual;
Public procedure PutPixel(const Point: TPoint2; Color: Cardinal); overload; virtual; abstract;
Public procedure PutPixel(x, y: Single; Color: Cardinal); overload;
Public procedure QuadHole(const Pos, Size, Center, Radius: TPoint2; OutColor, InColor: Cardinal; Steps: Integer; Effect: TBlendingEffect = beNormal); overload;
Public procedure ResetStates(); virtual;
Public procedure TexMap(const Points: TPoint4; const Colors: TColor4; Effect: TBlendingEffect = beNormal); virtual; abstract;
Public procedure UseImage(Image: TAsphyreImage; const Mapping: TPoint4; TextureNo: Integer = 0);
Public procedure UseImagePt(Image: TAsphyreImage; Pattern: Integer = 0); overload;
Public procedure UseImagePt(Image: TAsphyreImage; Pattern: Integer; const SrcRect: TRect; Mirror: Boolean = False; Flip: Boolean = False); overload;
Public procedure UseImagePx(Image: TAsphyreImage; const Mapping: TPoint4; TextureNo: Integer = 0);
Public procedure UseTexture(Texture: TAsphyreCustomTexture; const Mapping: TPoint4); virtual; abstract;
Public procedure UseTexturePx(Texture: TAsphyreCustomTexture; const Mapping: TPoint4);
Public procedure VertLine(Left, Top, Height: Single; Color1, Color2: Cardinal; Effect: TBlendingEffect = beNormal); overload;
Public procedure VertLine(Left, Top, Height: Single; Color: Cardinal; Effect: TBlendingEffect = beNormal); overload;
Public procedure WireQuad(const Points: TPoint4; const Colors: TColor4);
Public procedure WuLine(Src, Dest: TPoint2; Color1, Color2: Cardinal);

Properties

Public property Antialias: Boolean read GetAntialias write SetAntialias;
Public property CacheStall: Integer read FCacheStall;
Public property ClipRect: TRect read GetClipRect write SetClipRect;
Public property MipMapping: Boolean read GetMipMapping write SetMipMapping;

Description

Methods

Public procedure Circle(const Pos: TPoint2; Radius: Single; Steps: Integer; Color: Cardinal);

Draws circle at the given position, radius and color. This routine uses Line routine. Steps parameter indicates the number of divisions in the circle.

Public procedure DrawIndexedTriangles(Vertices: PPoint2; Colors: PLongWord; Indices: PLongInt; NoVertices, NoTriangles: Integer; Effect: TBlendingEffect = beNormal); virtual; abstract;

Draws multiple filled triangles using the specified vertices, vertex colors and index buffers. This is a low-level routine and can be used for drawing complex shapes quickly and efficiently.

Public procedure Ellipse(const Pos, Radius: TPoint2; Steps: Integer; Color: Cardinal);

Draws ellipse at the given position, radius and color. This routine uses Line routine. Steps parameter indicates the number of divisions in the ellipse.

Public procedure FillArc(x, y, Radius, InitPhi, EndPhi: Single; Steps: Integer; const Colors: TColor4; Effect: TBlendingEffect = beNormal); overload;

Draws filled arc at the given coordinates and radius. The arc begins at InitPhi and ends at EndPhi (in radians), subdivided into a number of triangles specified in Steps. The arc's shape is filled with 4-color gradient.

Public procedure FillArc(const Pos, Radius: TPoint2; InitPhi, EndPhi: Single; Steps: Integer; const Colors: TColor4; Effect: TBlendingEffect = beNormal); overload;

Draws filled arc at the given position and radius. The arc begins at InitPhi and ends at EndPhi (in radians), subdivided into a number of triangles specified in Steps. The arc's shape is filled with 4-color gradient.

Public procedure FillCircle(x, y, Radius: Single; Steps: Integer; const Colors: TColor4; Effect: TBlendingEffect = beNormal);

Draws filled circle at the given position and radius. The circle is subdivided into a number of triangles specified in Steps. The shape of circle is filled with 4-color gradient.

Public procedure FillEllipse(const Pos, Radius: TPoint2; Steps: Integer; const Colors: TColor4; Effect: TBlendingEffect = beNormal);

Draws filled ellipse at the given position and radius. The ellipse is subdivided into a number of triangles specified in Steps. The shape of ellipse is filled with 4-color gradient.

Public procedure FillHexagon(const Mtx: TMatrix3; c1, c2, c3, c4, c5, c6: Cardinal; Effect: TBlendingEffect = beNormal);

Draws hexagon where vertices are spaced 0.5 pixels apart from its center (so diameter is 1) in all directions, multiplied by the given matrix and filled with gradient of six colors at the corresponding vertices. The size, position and rotation of hexagon can be given using one or a combination of several 3x3 matrices multiplied together.

Public procedure FillQuad(const Points: TPoint4; const Colors: TColor4; Effect: TBlendingEffect = beNormal);

Draws filled quad between the specified vertices and vertex colors.

Public procedure FillRect(Left, Top, Width, Height: Integer; Color: Cardinal; Effect: TBlendingEffect = beNormal); overload;

Draws rectangle at the given coordinates filled with solid color.

Public procedure FillRect(const Rect: TRect; const Colors: TColor4; Effect: TBlendingEffect = beNormal); overload;

Draws rectangle filled with the specified 4-color gradient.

Public procedure FillRect(const Rect: TRect; Color: Cardinal; Effect: TBlendingEffect = beNormal); overload;

Draws rectangle filled with solid color.

Public procedure FillRibbon(const Pos, InRadius, OutRadius: TPoint2; InitPhi, EndPhi: Single; Steps: Integer; const Colors: TColor4; Effect: TBlendingEffect = beNormal); overload;

Draws filled ribbon at the given position between inner and outer radiuses. The ribbon begins at InitPhi and ends at EndPhi (in radians), subdivided into a number of triangles specified in Steps. The ribbons's shape is filled with 4-color gradient.

Public procedure FillRibbon(const Pos, InRadius, OutRadius: TPoint2; InitPhi, EndPhi: Single; Steps: Integer; InColor1, InColor2, InColor3, OutColor1, OutColor2, OutColor3: Cardinal; Effect: TBlendingEffect = beNormal); overload;

Draws filled ribbon at the given position between inner and outer radiuses. The ribbon begins at InitPhi and ends at EndPhi (in radians), subdivided into a number of triangles specified in Steps. The ribbons's shape is filled with continuous gradient set by three pairs of inner and outer colors.

Public procedure FillTri(const p1, p2, p3: TPoint2; c1, c2, c3: Cardinal; Effect: TBlendingEffect = beNormal);

Draws filled triangle between the specified vertices and vertex colors.

Public procedure Flush(); virtual; abstract;

Flushes the canvas cache and presents the pending primitives on the screen or render target. This can be useful to make sure that nothing remains in canvas cache before starting to draw, for instance, a 3D scene.

Public procedure FrameHexagon(const Mtx: TMatrix3; Color: Cardinal);

Draws lines between each vertex in hexagon. The vertices are spaced 0.5 pixels apart from its center (so diameter is 1) in all directions, multiplied by the given matrix and filled with gradient of six colors at the corresponding vertices. The size, position and rotation of hexagon can be given using one or a combination of several 3x3 matrices multiplied together.

Public procedure FrameRect(const Rect: TRect; const Colors: TColor4; Effect: TBlendingEffect = beNormal); overload;

Draws lines that form the specified rectangle using colors from the given 4-color gradient. This primitive uses filled shapes and not actual lines for pixel-perfect mapping.

Public procedure FrameRect(const Points: TPoint4; const Colors: TColor4; Effect: TBlendingEffect = beNormal); overload;

Draws lines between four corners of the given rectangle where the lines are filled using 4-color gradient. This method uses filled shapes instead of line primitives for pixel-perfect mapping but assumes that the four vertex points are aligned to form rectangle.

Public procedure HorizLine(Left, Top, Width: Single; Color: Cardinal; Effect: TBlendingEffect = beNormal); overload;

Draws horizontal line using the specified coordinates and filled with solid color. This primitive uses a filled shape and not line primitive for pixel-perfect mapping.

Public procedure HorizLine(Left, Top, Width: Single; Color1, Color2: Cardinal; Effect: TBlendingEffect = beNormal); overload;

Draws horizontal line using the specified coordinates and filled with two color gradient. This primitive uses a filled shape and not line primitive for pixel-perfect mapping.

Public procedure Line(const Src, Dest: TPoint2; Color: Cardinal); overload;

Draws line between the two specified 2D floating-point vectors using solid color.

Public procedure Line(x1, y1, x2, y2: Single; Color: Cardinal); overload;

Draws line between the specified coordinates using solid color.

Public procedure Line(const Src, Dest: TPoint2; Color1, Color2: Cardinal); overload; virtual; abstract;

Draws line between the two specified 2D floating-point vectors using gradient of two colors.

Public procedure LineArray(Points: PPoint2; Color: Cardinal; NoPoints: Integer); virtual;

Draws series of lines between specified vertices using solid color.

Public procedure PutPixel(const Point: TPoint2; Color: Cardinal); overload; virtual; abstract;

Draws a single pixel on the screen or render target using the specified 2D floating-point vector.

Public procedure PutPixel(x, y: Single; Color: Cardinal); overload;

Draws a single pixel on the screen or render target using the specified coordinates.

Public procedure QuadHole(const Pos, Size, Center, Radius: TPoint2; OutColor, InColor: Cardinal; Steps: Integer; Effect: TBlendingEffect = beNormal); overload;

Draws a filled rectangle at the given position and size with a hole (in form of ellipse) inside at the given center and radius. The quality of the hole is defined by the value of Steps in number of subdivisions. This entire shape is filled with gradient starting from outer color at the edges of rectangle and inner color ending at the edge of hole. This shape can be particularly useful for highlighting items on the screen by darkening the entire area except the one inside the hole.

Public procedure ResetStates(); virtual;

Resets all the states necessary for canvas operation. This can be useful when custom state changes have been made (for instance, in a 3D scene) so to restore the canvas to its working condition this method should be called.

Public procedure TexMap(const Points: TPoint4; const Colors: TColor4; Effect: TBlendingEffect = beNormal); virtual; abstract;

Draws textured rectangle at the given vertices and multiplied by the specified 4-color gradient. The texture must be set prior to this call by one of UseTexture[...] or UseImage[...] calls. For every call of TexMap there must be a corresponding UseTexture[...] orUseImage[...] call to specify the image or texture. All pixels of the rendered texture are multiplied by the gradient color before applying alpha-blending. If the texture has no alpha-channel present, alpha value of the gradient will be used instead.

Public procedure UseImage(Image: TAsphyreImage; const Mapping: TPoint4; TextureNo: Integer = 0);

Defines the specified image with one of its textures to be used in next call to TexMap. The coordinates inside the texture are defined in logical units in range of [0..1].

Public procedure UseImagePt(Image: TAsphyreImage; Pattern: Integer = 0); overload;

Defines the specified image with one of its patterns to be used in next call to TexMap. If the image has none or just one pattern, the value of Pattern should be set to zero; in this case, the entire texture is used instead of pattern.

Public procedure UseImagePt(Image: TAsphyreImage; Pattern: Integer; const SrcRect: TRect; Mirror: Boolean = False; Flip: Boolean = False); overload;

Defines the specified image with one of its patterns to be used in next call to TexMap. Only part of pattern is used for rendering defined by the given coordinates; these coordinates can also be mirrored horizontally and/or flipped vertically, if needed. If the image has no or just one pattern, the value of Pattern should be set to zero; in this case, the entire texture is used instead of pattern.

Public procedure UseImagePx(Image: TAsphyreImage; const Mapping: TPoint4; TextureNo: Integer = 0);

Defines the specified image with one of its textures to be used in next call to TexMap. The coordinates inside the texture are defined in pixels using floating-point coordinates.

Public procedure UseTexture(Texture: TAsphyreCustomTexture; const Mapping: TPoint4); virtual; abstract;

Defines the specified texture to be used in next call to TexMap. The coordinates inside the texture are defined in logical units in range of [0..1].

Public procedure UseTexturePx(Texture: TAsphyreCustomTexture; const Mapping: TPoint4);

Defines the specified texture to be used in next call to TexMap. The coordinates inside the texture are defined in pixels using floating-point coordinates.

Public procedure VertLine(Left, Top, Height: Single; Color1, Color2: Cardinal; Effect: TBlendingEffect = beNormal); overload;

Draws vertical line using the specified coordinates and filled with two color gradient. This primitive uses a filled shape and not line primitive for pixel-perfect mapping.

Public procedure VertLine(Left, Top, Height: Single; Color: Cardinal; Effect: TBlendingEffect = beNormal); overload;

Draws vertical line using the specified coordinates and filled with solid color. This primitive uses a filled shape and not line primitive for pixel-perfect mapping.

Public procedure WireQuad(const Points: TPoint4; const Colors: TColor4);

Draws lines between the specified vertices (making it a wireframe quad) and vertex colors.

Public procedure WuLine(Src, Dest: TPoint2; Color1, Color2: Cardinal);

Draws antialiased "wu-line" using PutPixel primitive between the specified 2D floating-point vectors using two color gradient.

Properties

Public property Antialias: Boolean read GetAntialias write SetAntialias;

Determines whether antialiasing should be used when stretching images and textures. If this parameter is set to False, no antialiasing will be made and stretched images will appear pixelated. There is little to none performance gain from not using antialiasing, so this parameter should typically be set to True.

Public property CacheStall: Integer read FCacheStall;

Number of times the rendering cache was reseted during last rendering frame. Each cache reset is typically a time-consuming operation so high number of such events could be detrimental to the application's rendering performance. If this parameter happens to be considerably high (above 20) in the rendered scene, the rendering code should be revised for better grouping of images, shapes and blending types.

Public property ClipRect: TRect read GetClipRect write SetClipRect;

The clipping rectangle in which the rendering will be made. This can be useful for restricting the rendering to a certain part of screen.

Public property MipMapping: Boolean read GetMipMapping write SetMipMapping;

Determines whether mipmapping should be used when rendering images and textures. Mipmapping can improve visual quality when extreme shrinking of original images is made at the expense of performance.


Generated by PasDoc 0.12.1 on 2012-09-14 11:55:49

posted on 2014-07-29 20:36  ★苍冥★  阅读(201)  评论(0编辑  收藏  举报