Provides support for the filling and stroking of vectors with patterns.
The VectorPattern class is used by Vector painting algorithms to fill and stroke vectors with pre-rendered patterns. It is the most efficient way of rendering a common set of graphics multiple times.
The VectorPattern must be registered with a VectorScene via the VectorScene⇒AddDef() method. Any vector within the target scene will be able to utilise the pattern for filling or stroking by referencing its name through the Vector⇒Fill and Vector⇒Stroke fields. For instance url(#dots).
A special use case is made for patterns that are applied as a fill operation in VectorViewport objects. In this case the renderer will dynamically render the pattern as a background within the viewport. This ensures that the pattern is rendered at maximum fidelity whenever it is used, and not affected by bitmap clipping restrictions. It should be noted that this means the image caching feature will be disabled.
It is strongly recommended that the VectorPattern is owned by the VectorScene that is handling the definition. This will ensure that the VectorPattern is deallocated when the scene is destroyed.
The VectorPattern class consists of the following fields:
Access | Name | Type | Comment | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ContentUnits | VUNIT | Not yet implemented. | |||||||||||||||||||||||||||||||
In compliance with SVG requirements, the application of ContentUnits is only effective if the Viewport's X, Y, Width and Height fields have been defined. The default setting is
| |||||||||||||||||||||||||||||||||
| Height | UNIT | Height of the pattern tile. | |||||||||||||||||||||||||||||||
The (Width,Height) field values define the dimensions of the pattern tile. If the provided value is scaled, then the dimension is calculated relative to the bounding box or viewport applying the pattern, dependent on the Units setting. | |||||||||||||||||||||||||||||||||
| Inherit | *VectorPattern | Inherit attributes from a VectorPattern referenced here. | |||||||||||||||||||||||||||||||
Attributes can be inherited from another pattern by referencing it in this field. This feature is provided primarily for the purpose of simplifying SVG compatibility and its use may result in an unnecessary performance penalty. | |||||||||||||||||||||||||||||||||
| Matrices | kt::vector<VectorMatrix> | Applies one or more transforms to a pattern. | |||||||||||||||||||||||||||||||
A transform can be applied to a pattern via one or more matrices. These will influence how pattern fills are rendered within their vector space. Each matrix is represented by a VectorMatrix structure, and the matrices are linked in the order in which they should be applied.
| |||||||||||||||||||||||||||||||||
| Opacity | DOUBLE | The opacity of the pattern. | |||||||||||||||||||||||||||||||
The opacity of the pattern is defined as a value between 0.0 and 1.0, with 1.0 being fully opaque. The default value is 1.0. | |||||||||||||||||||||||||||||||||
| Scene | *VectorScene | Refers to the internal VectorScene that will contain the rendered pattern. | |||||||||||||||||||||||||||||||
The VectorPattern class allocates a VectorScene in this field and inherits its functionality. In addition, a VectorViewport class will be assigned to the scene and is referenced in the Viewport field for managing the vectors that will be rendered. | |||||||||||||||||||||||||||||||||
| SpreadMethod | VSPREAD | The behaviour to use when the pattern bounds do not match the vector path. | |||||||||||||||||||||||||||||||
Indicates what happens if the pattern starts or ends inside the bounds of the target vector. The default value is
| |||||||||||||||||||||||||||||||||
| Transform | STRING | Applies a transform to the pattern during the render process. | |||||||||||||||||||||||||||||||
A transform can be applied to the pattern by setting this field with an SVG compliant transform string. | |||||||||||||||||||||||||||||||||
| Units | VUNIT | Defines the coordinate system for fields X, Y, Width and Height. | |||||||||||||||||||||||||||||||
This field declares the coordinate system that is used for values in the X, Y, Width and Height fields. The default setting is
| |||||||||||||||||||||||||||||||||
| Viewport | *VectorViewport | Refers to the viewport that contains the pattern. | |||||||||||||||||||||||||||||||
The Viewport refers to a VectorViewport object that is created to host the vectors for the rendered pattern. If the Viewport does not contain at least one vector that renders an image, the pattern will be ineffective. | |||||||||||||||||||||||||||||||||
| Width | UNIT | Width of the pattern tile. | |||||||||||||||||||||||||||||||
The (Width,Height) field values define the dimensions of the pattern tile. If the provided value is scaled, the dimension is calculated relative to the bounding box or viewport applying the pattern, dependent on the Units setting. | |||||||||||||||||||||||||||||||||
| X | UNIT | X coordinate for the pattern. | |||||||||||||||||||||||||||||||
The (X,Y) field values define the starting coordinate for mapping patterns. | |||||||||||||||||||||||||||||||||
| Y | UNIT | Y coordinate for the pattern. | |||||||||||||||||||||||||||||||
The (X,Y) field values define the starting coordinate for mapping patterns. | |||||||||||||||||||||||||||||||||
The following actions are currently supported:
| Draw | Draws object graphics to drawable areas. | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
ERR acDraw(*Object, DOUBLE X, DOUBLE Y, DOUBLE Width, DOUBLE Height)
| ||||||||||||
Spread method options define the method to use for tiling filled graphics.
| Name | Description |
|---|---|
| VSPREAD::CLIP | Do not scale the graphic. Clip it if it extends past imposed boundaries. |
| VSPREAD::PAD | Scale the graphic to the object bounds. |
| VSPREAD::REFLECT | Tile the graphic, reflecting the image alternately on the X and Y axis. |
| VSPREAD::REFLECT_X | Tile the graphic, reflecting the image alternately on the X axis only. |
| VSPREAD::REFLECT_Y | Tile the graphic, reflecting the image alternately on the Y axis only. |
| VSPREAD::REPEAT | Tile the graphic repeatedly. |
| VSPREAD::UNDEFINED | Either the default setting will be applied or the setting will be inherited from a parent object. |
| Name | Description |
|---|---|
| VUNIT::BOUNDING_BOX | Coordinates are scaled to the object's bounding box. |
| VUNIT::UNDEFINED | Either the default setting will be applied or the setting will be inherited from a parent object. |
| VUNIT::USERSPACE | Coordinates are scaled to the current viewport. |
Vector transformation matrix.
| Field | Type | Description |
|---|---|---|
| Next | struct VectorMatrix * | The next transform in the list. |
| Vector | objVector * | The vector associated with the transform. |
| ScaleX | DOUBLE | Matrix value A |
| ShearY | DOUBLE | Matrix value B |
| ShearX | DOUBLE | Matrix value C |
| ScaleY | DOUBLE | Matrix value D |
| TranslateX | DOUBLE | Matrix value E |
| TranslateY | DOUBLE | Matrix value F |
| Tag | INT | An optional tag value defined by the client for matrix identification. |