IVisual

Description

interface Tinman.Engine.Drawing.IVisual

Derived from

IVersioned
IEquatable<IVisual>
ICopyable<IVisual>

Extended by

Visual abstract

Base interface for classes that describe an arbitrary 2D visual that may be rasterized and then rendered as a whole, using textured quadrilaterals.

The specification of a visual uses coordinates and length in visual units, which refer to an unspecified unit of measure that the application has chosen to use consistently. For example, an application may choose to use inch as visual unit and then express resolution values as dots-per-inch (DPI). As far as the rasterization framework is concerned, no knowledge of the visual unit is required, except the guarantee that the application will use it consistently.

When a visual is rasterized, the application specifies a resolution which is then used to generate the textured quadrilaterals. Vertex and texture coordinates are generated so that the coordinate origin (0,0) in visual units corresponds to the screen coordinates (0,0), which is the top-left corner of the top-left pixel, when the textured quadrilaterals are rendered without transformation.

The data version of a 2D visual is incremented if a change has occurred which affects the pixel content that results from rasterization and is used at runtime to discard cached data. To avoid inconsistencies when a visual is modified while being rasterized in the background, an independent copy (see ICopyable.Copy) is used for rasterization.

With object.Equals, two visuals may be compared for equality: if they are equal, they will rasterize to the same pixel content (for the same rasterizer). The data version of equal visuals may be different, though. The object.GetHashCode method must be implemented accordingly, so that equal visuals also have equal hash codes. The hash code of a visual must not change during its lifetime. The VisualInstance will cache the hash code of its visual, so the implementation does not need to be optimized for performance.

Public / Attributes

Background


public attribute Background → (get)

value : int64

The background color.

Returns the background color to use for clearing the pixel buffer before merging it with the rasterized visual.

Bounds


public attribute Bounds → (get)

value : Box2F

The bounds, in visual units. Will be Box2F.Inverse iff the bounds depend on the used rasterizer.

Returns the bounds of the visual.

The bounds of a visual may always be obtained via IVisualRasterizer.MeasureBounds. This property returns the visual bounds iff they are independent of the used rasterizer. This should be decided at compile-time, so that a rasterizer can easily use the visitor pattern to decide whether to delegate to this property or to compute the bounds by itself.