Show / Hide Table of Contents

Interface IDrawing

Drawing Operations Build draw queues containing lists of triangles and their properties (colouring and texturing, layer, coordinate space and depth) Draw queues exist for standard drawing (DrawStage) as well as drawing to distortion height maps (DistortionStage) Bitmap font rendering is supported

Namespace: Yak2D
Assembly: Yak2D.Api.dll
Syntax
public interface IDrawing

Properties

Helpers

Provides access to functions to simplify common drawing operations (lines, quads, regular polygons and arrows) Includes a fluent interface option for building flexible partial shapes and iterating / modifying

Declaration
IDrawingHelpers Helpers { get; }
Property Value
Type Description
IDrawingHelpers

Methods

ClearDynamicDistortionRequestQueue(UInt64)

Clears the Dynamic (non-persistent-on-clear) Draw Queue from a DistortionStage

Declaration
void ClearDynamicDistortionRequestQueue(ulong stage)
Parameters
Type Name Description
System.UInt64 stage

DistortionStage id

ClearDynamicDistortionRequestQueue(IDistortionStage)

Clears the Dynamic (non-persistent-on-clear) Draw Queue from a DistortionStage

Declaration
void ClearDynamicDistortionRequestQueue(IDistortionStage stage)
Parameters
Type Name Description
IDistortionStage stage

DistortionStage reference

ClearDynamicDrawRequestQueue(UInt64)

Clears the Dynamic (non-persistent-on-clear) Draw Queue from a DrawStage

Declaration
void ClearDynamicDrawRequestQueue(ulong stage)
Parameters
Type Name Description
System.UInt64 stage

DrawStage id

ClearDynamicDrawRequestQueue(IDrawStage)

Clears the Dynamic (non-persistent-on-clear) Draw Queue from a DrawStage

Declaration
void ClearDynamicDrawRequestQueue(IDrawStage stage)
Parameters
Type Name Description
IDrawStage stage

DrawStage reference

CreatePersistentDistortQueue(UInt64, DistortionDrawRequest[], Boolean)

A persistent distortion draw queue has a collection of distortion draw requests that persist even after clearing the dynamic portion of a DistortionStage's draw queue

Declaration
IPersistentDistortionQueue CreatePersistentDistortQueue(ulong stage, DistortionDrawRequest[] requests, bool validate = false)
Parameters
Type Name Description
System.UInt64 stage

DistortionStage id that the persistent queue will be added too

DistortionDrawRequest[] requests

Distortion Draw requests that will for the persistent part of the draw queue

System.Boolean validate

Check whether the content of distortion draw request array appears valid. If this fails, null is returned

Returns
Type Description
IPersistentDistortionQueue

CreatePersistentDistortQueue(IDistortionStage, DistortionDrawRequest[], Boolean)

A persistent distortion draw queue has a collection of distortion draw requests that persist even after clearing the dynamic portion of a DistortionStage's draw queue

Declaration
IPersistentDistortionQueue CreatePersistentDistortQueue(IDistortionStage stage, DistortionDrawRequest[] requests, bool validate = false)
Parameters
Type Name Description
IDistortionStage stage

DistortionStage Reference that the persistent queue will be added too

DistortionDrawRequest[] requests

Distortion Draw requests that will for the persistent part of the draw queue

System.Boolean validate

Check whether the content of distortion draw request array appears valid. If this fails, null is returned

Returns
Type Description
IPersistentDistortionQueue

CreatePersistentDrawQueue(UInt64, DrawRequest[], Boolean)

A persistent draw queue has a collection of draw requests that persist even after clearing the dynamic portion of a DrawStage's draw queue

Declaration
IPersistentDrawQueue CreatePersistentDrawQueue(ulong stage, DrawRequest[] requests, bool validate = false)
Parameters
Type Name Description
System.UInt64 stage

DrawStage id that the persistent queue will be added too

DrawRequest[] requests

Draw requests that will for the persistent part of the draw queue

System.Boolean validate

Check whether the content of draw request array appears valid. If this fails, null is returned

Returns
Type Description
IPersistentDrawQueue

CreatePersistentDrawQueue(IDrawStage, DrawRequest[], Boolean)

A persistent draw queue has a collection of draw requests that persist even after clearing the dynamic portion of a DrawStage's draw queue

Declaration
IPersistentDrawQueue CreatePersistentDrawQueue(IDrawStage stage, DrawRequest[] requests, bool validate = false)
Parameters
Type Name Description
IDrawStage stage

DrawStage reference that the persistent queue will be added too

DrawRequest[] requests

Draw requests that will for the persistent part of the draw queue

System.Boolean validate

Check whether the content of draw request array appears valid. If this fails, null is returned

Returns
Type Description
IPersistentDrawQueue

Draw(UInt64, CoordinateSpace, FillType, Vertex2D[], Int32[], Colour, UInt64, UInt64, TextureCoordinateMode, TextureCoordinateMode, Single, Int32, Boolean)

Add draw request to the DrawStage's dynamic (non-persistent-on-clear) draw queue by specifying the request's components

Declaration
void Draw(ulong stage, CoordinateSpace target, FillType type, Vertex2D[] vertices, int[] indices, Colour colour, ulong texture0, ulong texture1, TextureCoordinateMode texWrap0, TextureCoordinateMode texWrap1, float depth, int layer, bool validate = false)
Parameters
Type Name Description
System.UInt64 stage

DrawStage id

CoordinateSpace target

The coordinate space (world or screen) that the vertices should be transformed by

FillType type

Fill / Texturing type - Coloured, Single Textured or Dual Textured

Vertex2D[] vertices

The vertices that make up the triangles to draw

System.Int32[] indices

The indices that reference vertices that make up the triangles to draw

Colour colour

An overall colour applied to all vertices at drawing

System.UInt64 texture0

Primary Texture id (the only texture used for single texturing)

System.UInt64 texture1

Secondary Texture id (used for dual texturing)

TextureCoordinateMode texWrap0

Primary Texture Coordinate Wrap behaviour

TextureCoordinateMode texWrap1

Secondary Texure Coordinate Wrap behaviour

System.Single depth

Z depth of vertices defining ordering within a layer (0.0 [front] to 1.0 [back])

System.Int32 layer

= 0. The layer that these vertices belong too, lower layers are drawn behind higher layers

System.Boolean validate

Check whether the content of the draw request appears valid before adding to the queue

Draw(UInt64, DrawRequest, Boolean)

Adds draw request to the DrawStage's dynamic (non-persistent-on-clear) draw queue

Declaration
void Draw(ulong stage, DrawRequest request, bool validate = false)
Parameters
Type Name Description
System.UInt64 stage

DrawStage id

DrawRequest request

Draw request to add to queue

System.Boolean validate

Check whether the content of the draw request appears valid before adding to the queue

Draw(UInt64, ref DrawRequest, Boolean)

Adds draw request to the DrawStage's dynamic (non-persistent-on-clear) draw queue

Declaration
void Draw(ulong stage, ref DrawRequest request, bool validate = false)
Parameters
Type Name Description
System.UInt64 stage

DrawStage id

DrawRequest request

Draw request to add to queue

System.Boolean validate

Check whether the content of the draw request appears valid before adding to the queue

Draw(IDrawStage, CoordinateSpace, FillType, Vertex2D[], Int32[], Colour, ITexture, ITexture, TextureCoordinateMode, TextureCoordinateMode, Single, Int32, Boolean)

Add draw request to the DrawStage's dynamic (non-persistent-on-clear) draw queue by specifying the request's components

Declaration
void Draw(IDrawStage stage, CoordinateSpace target, FillType type, Vertex2D[] vertices, int[] indices, Colour colour, ITexture texture0, ITexture texture1, TextureCoordinateMode texWrap0, TextureCoordinateMode texWrap1, float depth, int layer, bool validate = false)
Parameters
Type Name Description
IDrawStage stage

DrawStage reference

CoordinateSpace target

The coordinate space (world or screen) that the vertices should be transformed by

FillType type

Fill / Texturing type - Coloured, Single Textured or Dual Textured

Vertex2D[] vertices

The vertices that make up the triangles to draw

System.Int32[] indices

The indices that reference vertices that make up the triangles to draw

Colour colour

An overall colour applied to all vertices at drawing

ITexture texture0

Primary Texture Reference (the only texture used for single texturing)

ITexture texture1

Secondary Texture Reference (used for dual texturing)

TextureCoordinateMode texWrap0

Primary Texture Coordinate Wrap behaviour

TextureCoordinateMode texWrap1

Secondary Texure Coordinate Wrap behaviour

System.Single depth

Z depth of vertices defining ordering within a layer (0.0 [front] to 1.0 [back])

System.Int32 layer

= 0. The layer that these vertices belong too, lower layers are drawn behind higher layers

System.Boolean validate

Check whether the content of the draw request appears valid before adding to the queue

Draw(IDrawStage, DrawRequest, Boolean)

Adds draw request to the DrawStage's dynamic (non-persistent-on-clear) draw queue

Declaration
void Draw(IDrawStage stage, DrawRequest request, bool validate = false)
Parameters
Type Name Description
IDrawStage stage

DrawStage reference

DrawRequest request

Draw request to add to queue

System.Boolean validate

Check whether the content of the draw request appears valid before adding to the queue

Draw(IDrawStage, ref DrawRequest, Boolean)

Adds draw request to the DrawStage's dynamic (non-persistent-on-clear) draw queue

Declaration
void Draw(IDrawStage stage, ref DrawRequest request, bool validate = false)
Parameters
Type Name Description
IDrawStage stage

DrawStage reference

DrawRequest request

Draw request to add to queue

System.Boolean validate

Check whether the content of the draw request appears valid before adding to the queue

DrawDistortion(UInt64, CoordinateSpace, FillType, Vertex2D[], Int32[], Colour, UInt64, UInt64, TextureCoordinateMode, TextureCoordinateMode, Single, Boolean)

Add distortion draw request to the DistortionStage's dynamic (non-persistent-on-clear) draw queue by specifying the request's components

Declaration
void DrawDistortion(ulong stage, CoordinateSpace target, FillType type, Vertex2D[] vertices, int[] indices, Colour colour, ulong texture0, ulong texture1, TextureCoordinateMode texWrap0, TextureCoordinateMode texWrap1, float intensity, bool validate = false)
Parameters
Type Name Description
System.UInt64 stage

DistortionStage id

CoordinateSpace target

The coordinate space (world or screen) that the vertices should be transformed by

FillType type

Fill / Texturing type - Coloured, Single Textured or Dual Textured

Vertex2D[] vertices

The vertices that make up the triangles to draw

System.Int32[] indices

The indices that reference vertices that make up the triangles to draw

Colour colour

An overall colour applied to all vertices at drawing

System.UInt64 texture0

Primary Texture id (the only texture used for single texturing)

System.UInt64 texture1

Secondary Texture id (used for dual texturing)

TextureCoordinateMode texWrap0

Primary Texture Coordinate Wrap behaviour

TextureCoordinateMode texWrap1

Secondary Texure Coordinate Wrap behaviour

System.Single intensity

Scalar quantity to multply the height factor of the drawn pixels

System.Boolean validate

DrawDistortion(UInt64, DistortionDrawRequest, Boolean)

Adds distortion draw request to the DistortionStage's dynamic (non-persistent-on-clear) draw queue

Declaration
void DrawDistortion(ulong stage, DistortionDrawRequest request, bool validate = false)
Parameters
Type Name Description
System.UInt64 stage

DistortionStage id

DistortionDrawRequest request

Distortion Draw request to add to queue

System.Boolean validate

Check whether the content of the distortion draw request appears valid before adding to the queue

DrawDistortion(UInt64, ref DistortionDrawRequest, Boolean)

Adds distortion draw request to the DistortionStage's dynamic (non-persistent-on-clear) draw queue

Declaration
void DrawDistortion(ulong stage, ref DistortionDrawRequest request, bool validate = false)
Parameters
Type Name Description
System.UInt64 stage

DistortionStage id

DistortionDrawRequest request

Distortion Draw request to add to queue

System.Boolean validate

Check whether the content of the distortion draw request appears valid before adding to the queue

DrawDistortion(IDistortionStage, CoordinateSpace, FillType, Vertex2D[], Int32[], Colour, ITexture, ITexture, TextureCoordinateMode, TextureCoordinateMode, Single, Boolean)

Add distortion draw request to the DistortionStage's dynamic (non-persistent-on-clear) draw queue by specifying the request's components

Declaration
void DrawDistortion(IDistortionStage stage, CoordinateSpace target, FillType type, Vertex2D[] vertices, int[] indices, Colour colour, ITexture texture0, ITexture texture1, TextureCoordinateMode texWrap0, TextureCoordinateMode texWrap1, float intensity, bool validate = false)
Parameters
Type Name Description
IDistortionStage stage

DistortionStage reference

CoordinateSpace target

The coordinate space (world or screen) that the vertices should be transformed by

FillType type

Fill / Texturing type - Coloured, Single Textured or Dual Textured

Vertex2D[] vertices

The vertices that make up the triangles to draw

System.Int32[] indices

The indices that reference vertices that make up the triangles to draw

Colour colour

An overall colour applied to all vertices at drawing

ITexture texture0

Primary Texture Reference (the only texture used for single texturing)

ITexture texture1

Secondary Texture Reference (used for dual texturing)

TextureCoordinateMode texWrap0

Primary Texture Coordinate Wrap behaviour

TextureCoordinateMode texWrap1

Secondary Texure Coordinate Wrap behaviour

System.Single intensity

Scalar quantity to multply the height factor of the drawn pixels

System.Boolean validate

DrawDistortion(IDistortionStage, DistortionDrawRequest, Boolean)

Adds distortion draw request to the DistortionStage's dynamic (non-persistent-on-clear) draw queue

Declaration
void DrawDistortion(IDistortionStage stage, DistortionDrawRequest request, bool validate = false)
Parameters
Type Name Description
IDistortionStage stage

DistortionStage reference

DistortionDrawRequest request

Distortion Draw request to add to queue

System.Boolean validate

Check whether the content of the distortion draw request appears valid before adding to the queue

DrawDistortion(IDistortionStage, ref DistortionDrawRequest, Boolean)

Adds distortion draw request to the DistortionStage's dynamic (non-persistent-on-clear) draw queue

Declaration
void DrawDistortion(IDistortionStage stage, ref DistortionDrawRequest request, bool validate = false)
Parameters
Type Name Description
IDistortionStage stage

DistortionStage reference

DistortionDrawRequest request

Distortion Draw request to add to queue

System.Boolean validate

Check whether the content of the distortion draw request appears valid before adding to the queue

DrawString(UInt64, CoordinateSpace, String, Colour, Single, Vector2, TextJustify, Single, Int32, Boolean)

Create a draw request from a Text String and Font and add to the DrawStage's dynamic (non-persistent-on-clear) draw queue Uses default font

Declaration
void DrawString(ulong stage, CoordinateSpace target, string text, Colour colour, float fontSize, Vector2 position, TextJustify justify, float depth, int layer, bool useKerningsWhereAvaliable = true)
Parameters
Type Name Description
System.UInt64 stage

DrawStage id

CoordinateSpace target

The coordinate space (world or screen) that the vertices should be transformed by

System.String text

Text string to draw

Colour colour

Text colour

System.Single fontSize

Font size in pixels

Vector2 position

Position of text string (x dependent on justify, y is top)

TextJustify justify

Horizontal positioning of text relative to position

System.Single depth

Z depth of vertices defining ordering within a layer (0.0 [front] to 1.0 [back])

System.Int32 layer

= 0. The layer that these vertices belong too, lower layers are drawn behind higher layers

System.Boolean useKerningsWhereAvaliable

Use font kerning data for spacing adjustments if font contains this data

DrawString(UInt64, CoordinateSpace, String, Colour, Single, Vector2, TextJustify, Single, Int32, UInt64, Boolean)

Create a draw request from a Text String and Font and add to the DrawStage's dynamic (non-persistent-on-clear) draw queue

Declaration
void DrawString(ulong stage, CoordinateSpace target, string text, Colour colour, float fontSize, Vector2 position, TextJustify justify, float depth, int layer, ulong font, bool useKerningsWhereAvaliable = true)
Parameters
Type Name Description
System.UInt64 stage

DrawStage id

CoordinateSpace target

The coordinate space (world or screen) that the vertices should be transformed by

System.String text

Text string to draw

Colour colour

Text colour

System.Single fontSize

Font size in pixels

Vector2 position

Position of text string (x dependent on justify, y is top)

TextJustify justify

Horizontal positioning of text relative to position

System.Single depth

Z depth of vertices defining ordering within a layer (0.0 [front] to 1.0 [back])

System.Int32 layer

= 0. The layer that these vertices belong too, lower layers are drawn behind higher layers

System.UInt64 font

Font id to use

System.Boolean useKerningsWhereAvaliable

Use font kerning data for spacing adjustments if font contains this data

DrawString(IDrawStage, CoordinateSpace, String, Colour, Single, Vector2, TextJustify, Single, Int32, IFont, Boolean)

Create a draw request from a Text String and Font and add to the DrawStage's dynamic (non-persistent-on-clear) draw queue

Declaration
void DrawString(IDrawStage stage, CoordinateSpace target, string text, Colour colour, float fontSize, Vector2 position, TextJustify justify, float depth, int layer, IFont font = null, bool useKerningsWhereAvaliable = true)
Parameters
Type Name Description
IDrawStage stage

DrawStage reference

CoordinateSpace target

The coordinate space (world or screen) that the vertices should be transformed by

System.String text

Text string to draw

Colour colour

Text colour

System.Single fontSize

Font size in pixels

Vector2 position

Position of text string (x dependent on justify, y is top)

TextJustify justify

Horizontal positioning of text relative to position

System.Single depth

Z depth of vertices defining ordering within a layer (0.0 [front] to 1.0 [back])

System.Int32 layer

= 0. The layer that these vertices belong too, lower layers are drawn behind higher layers

IFont font

Font reference to use, null uses a default font

System.Boolean useKerningsWhereAvaliable

Use font kerning data for spacing adjustments if font contains this data

GetSurfaceDimensions(UInt64)

Get size of texture in pixels

Declaration
Size GetSurfaceDimensions(ulong texture)
Parameters
Type Name Description
System.UInt64 texture

Texture id"

Returns
Type Description
Size

GetSurfaceDimensions(ITexture)

Get size of texture in pixels

Declaration
Size GetSurfaceDimensions(ITexture texture)
Parameters
Type Name Description
ITexture texture

Texture reference"

Returns
Type Description
Size

MeasureStringLength(String, Single, UInt64)

Measure pixel length (width) of a string

Declaration
float MeasureStringLength(string text, float fontSize, ulong font)
Parameters
Type Name Description
System.String text

Text string

System.Single fontSize

Size of font in pixels

System.UInt64 font

Font id to use

Returns
Type Description
System.Single

MeasureStringLength(String, Single, IFont)

Measure pixel length (width) of a string

Declaration
float MeasureStringLength(string text, float fontSize, IFont font = null)
Parameters
Type Name Description
System.String text

Text string

System.Single fontSize

Size of font in pixels

IFont font

Font reference to use, null uses a default font

Returns
Type Description
System.Single

RemovePersistentDistortQueue(UInt64, UInt64)

Removes (destroys) a persistent distortion draw queue from a DistortionStage

Declaration
void RemovePersistentDistortQueue(ulong stage, ulong queue)
Parameters
Type Name Description
System.UInt64 stage

DistortionStage id from which to remove the persistent queue (if attached)

System.UInt64 queue

PersistentDistortionQueue id to remove from the DistortionStage

RemovePersistentDistortQueue(IDistortionStage, IPersistentDistortionQueue)

Removes (destroys) a persistent distortion draw queue from a DistortionStage

Declaration
void RemovePersistentDistortQueue(IDistortionStage stage, IPersistentDistortionQueue queue)
Parameters
Type Name Description
IDistortionStage stage

DistortionStage reference from which to remove the persistent queue (if attached)

IPersistentDistortionQueue queue

PersistentDistortionQueue reference to remove from the DistortionStage

RemovePersistentDrawQueue(UInt64, UInt64)

Removes (destroys) a persistent draw queue from a DrawStage

Declaration
void RemovePersistentDrawQueue(ulong stage, ulong queue)
Parameters
Type Name Description
System.UInt64 stage

DrawStage id from which to remove the persistent queue (if attached)

System.UInt64 queue

PersistentDrawQueue id to remove from the DrawStage

RemovePersistentDrawQueue(IDrawStage, IPersistentDrawQueue)

Removes (destroys) a persistent draw queue from a DrawStage

Declaration
void RemovePersistentDrawQueue(IDrawStage stage, IPersistentDrawQueue queue)
Parameters
Type Name Description
IDrawStage stage

DrawStage reference from which to remove the persistent queue (if attached)

IPersistentDrawQueue queue

PersistentDrawQueue reference to remove from the DrawStage

WrapTextureId(UInt64)

Create a Texture reference object from an id DrawRequests require Texture References (currently), so if the user is storing raw ulong references instead, this method allows an easy conversion back to a reference object

Declaration
ITexture WrapTextureId(ulong id)
Parameters
Type Name Description
System.UInt64 id

The Texture's unique ulong identifier

Returns
Type Description
ITexture
In This Article
Back to top yak2D - Alex Paterson