Visual

Description

abstract class Tinman.Engine.Drawing.Visual

Derived from

VersionedBase abstract
IVisual

Abstract base class for IVisual implementations.

The default implementation of IEquatable.Equals and object.GetHashCode use object identity, subclasses may override them in order to provide other definitions for equality.

Public / Constructors

Image


public static method Image → (5)

image in : IImage

[not-null]
The image to read.

resolution opt : float32 = 96

[>0]
The resolution to use, in visual units per pixel.

width opt : int32 = 0

[>=0]
The image width or 0 if not known up-front.

height opt : int32 = 0

[>=0]
The image height or 0 if not known up-front.

error opt : int64 = Colors.Magenta

If an error occurs while reading the given image in, this color will be used to fill the target pixel buffer (see Colors).

returns → IVisual

The IVisual object that wraps image in.

Creates a new instance of IVisual that reads an image.

Shape


public static method Shape → (3)

shape in : IShape

[not-null]
The shape to wrap.

factory in : IShapeRasterizerFactory<ColorBuffer>

[not-null]
The shape rasterizer factory to use.

bounds opt : Box2D = default(Box2D)

The shape bounds to rasterize. If empty, IShape.VisibleBounds will be used. In either case, Box2D.TopLeft will be mapped to (0,0) in visual units.

returns → IVisual

The IVisual object that wraps shape in.

Creates a new instance of IVisual that wraps a IShape.

Vector


public static method Vector → (2)

image in : IVectorImage

[not-null]
The vector image to wrap.

scale opt : float32 = 1

[>0]
Scale factor from vector image units to visual units.

returns → IVisual

The IVisual object that wraps image in.

Creates a new instance of IVisual that wraps a IVectorImage.

The calling code is responsible for making sure that image in does not get disposed while the returned IVisual is in use.

Public / Methods

Compute​Aligned​Bounds


[Pure]
public static method ComputeAlignedBounds → (5)

visualBounds in : Box2F

The visual bounds to align.

resolution in : float32

[>0]
The resolution to use, pixels per visual unit.

visualBoundsAligned out : Box2F

Output of the aligned visual bounds. Will always fully contain visualBounds in. This value will be written after visualBounds in has been fully read.

pixelOffset out : Vec2F

Offset from the top-left corner of the enlarged pixel bounds to the original pixel bounds.

pixelSize out : Vec2I

Output of the size of the enlarged pixel bounds.

Computes the pixel alignment of the given visualBounds in when using the given resolution in.

First, the resolution in is used to convert visualBounds in to pixel coordinates, which will usually have non-integral value. Then, the pixel bounds are enlarged, so that top-left and bottom-right corners align with the respective pixel corner, which makes pixel coordinate values integral. Finally, the enlarged pixel bounds are scaled back to visual units, which yields the aligned visual bounds.

Compute​Transform


[Pure]
public static method ComputeTransform → (2)

visualBounds in : Box2F

The bounds in visual units that get rasterized into the given pixelBounds in.

pixelBounds in : Box2I

The bounds in the pixel buffer that holds the rasterization result of the given visualBounds in.

returns → Mat3F

The affine 2D transformation matrix that converts visual units to pixels.

Computes the transformation matrix that converts visual units to pixel coordinates.