Show / Hide Table of Contents

Interface IDrawingHelpers

Drawing Helpers for Common Shapes Quad, Regular Polygon, Line and Arrow drawing functions Includes Fluent Interface for building and modifying shape drawing in steps

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

Properties

Common

Operations to help generate vertex lists for regular polygons, lines and arrows Includes some helper functions for rotating 2d vectors and converting degress to radians

Declaration
ICommonOperations Common { get; }
Property Value
Type Description
ICommonOperations

Methods

Construct()

First step for generating shape drawing objects via a fluent interface

Declaration
IBaseDrawable Construct()
Returns
Type Description
IBaseDrawable

DrawArrow(UInt64, CoordinateSpace, Vector2, Vector2, Single, Single, Single, Colour, Single, Int32, Boolean)

Draw Coloured Arrow

Declaration
void DrawArrow(ulong drawStage, CoordinateSpace space, Vector2 from, Vector2 to, float width, float headLength, float headWidth, Colour colour, float depth, int layer = 0, bool rounded = false)
Parameters
Type Name Description
System.UInt64 drawStage

DrawStage id

CoordinateSpace space

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

Vector2 from

Location of the start of the arrow (middle of the line's thickness)

Vector2 to

Location of the end of the arrow head (the arrow point)

System.Single width

Width of the line (thickness)

System.Single headLength

How long the arrow head is (aslong as the total arrow length can support it)

System.Single headWidth

Width arrow head at the widest point

Colour colour

An overall colour applied to all vertices at drawing

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 rounded

Set whether the non-point end of the arrow is rounded

DrawArrow(IDrawStage, CoordinateSpace, Vector2, Vector2, Single, Single, Single, Colour, Single, Int32, Boolean)

Draw Coloured Arrow

Declaration
void DrawArrow(IDrawStage drawStage, CoordinateSpace space, Vector2 from, Vector2 to, float width, float headLength, float headWidth, Colour colour, float depth, int layer = 0, bool rounded = false)
Parameters
Type Name Description
IDrawStage drawStage

DrawStage reference

CoordinateSpace space

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

Vector2 from

Location of the start of the arrow (middle of the line's thickness)

Vector2 to

Location of the end of the arrow head (the arrow point)

System.Single width

Width of the line (thickness)

System.Single headLength

How long the arrow head is (aslong as the total arrow length can support it)

System.Single headWidth

Width arrow head at the widest point

Colour colour

An overall colour applied to all vertices at drawing

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 rounded

Set whether the non-point end of the arrow is rounded

DrawColouredPoly(UInt64, CoordinateSpace, Colour, Vector2, Int32, Single, Single, Int32, Single, Single, Single)

Draw Coloured Regular Polygon (a regular polygon has equal length sides. In the case where xScaling == yScaling, as the number of sides increases, the closer an approximation of a circle is made)

Declaration
void DrawColouredPoly(ulong drawStage, CoordinateSpace space, Colour colour, Vector2 position, int numSides, float radius, float depth, int layer = 0, float xScaling = 1F, float yScaling = 1F, float rotation_clockwise_radians = 0F)
Parameters
Type Name Description
System.UInt64 drawStage

DrawStage id

CoordinateSpace space

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

Colour colour

An overall colour applied to all vertices at drawing

Vector2 position

Centre position of the polygon

System.Int32 numSides

The number of sides that polygon has (minimum 3 == triangle)

System.Single radius

Distance of each outer edge vertex point from centre before scaling

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.Single xScaling

Scalar of polygon's x-dimensions (before rotation)

System.Single yScaling

Scalar of polygon's y-dimensions (before rotation)

System.Single rotation_clockwise_radians

Clockwise rotation of final scaled polygon around centre point in radians

DrawColouredPoly(IDrawStage, CoordinateSpace, Colour, Vector2, Int32, Single, Single, Int32, Single, Single, Single)

Draw Coloured Regular Polygon (a regular polygon has equal length sides. In the case where xScaling == yScaling, as the number of sides increases, the closer an approximation of a circle is made)

Declaration
void DrawColouredPoly(IDrawStage drawStage, CoordinateSpace space, Colour colour, Vector2 position, int numSides, float radius, float depth, int layer = 0, float xScaling = 1F, float yScaling = 1F, float rotation_clockwise_radians = 0F)
Parameters
Type Name Description
IDrawStage drawStage

DrawStage reference

CoordinateSpace space

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

Colour colour

An overall colour applied to all vertices at drawing

Vector2 position

Centre position of the polygon

System.Int32 numSides

The number of sides that polygon has (minimum 3 == triangle)

System.Single radius

Distance of each outer edge vertex point from centre before scaling

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.Single xScaling

Scalar of polygon's x-dimensions (before rotation)

System.Single yScaling

Scalar of polygon's y-dimensions (before rotation)

System.Single rotation_clockwise_radians

Clockwise rotation of final scaled polygon around centre point in radians

DrawColouredQuad(UInt64, CoordinateSpace, Colour, Vector2, Single, Single, Single, Int32, Single)

Draw Coloured Quad (rectangle) made from two triangles

Declaration
void DrawColouredQuad(ulong drawStage, CoordinateSpace space, Colour colour, Vector2 position, float width, float height, float depth, int layer = 0, float rotation_clockwise_radians = 0F)
Parameters
Type Name Description
System.UInt64 drawStage

DrawStage id

CoordinateSpace space

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

Colour colour

An overall colour applied to all vertices at drawing

Vector2 position

Centre position of the quad

System.Single width

Width of the quad

System.Single height

Height of the quad

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.Single rotation_clockwise_radians

Clockwise rotation of quad around centre point in radians

DrawColouredQuad(IDrawStage, CoordinateSpace, Colour, Vector2, Single, Single, Single, Int32, Single)

Draw Coloured Quad (rectangle) made from two triangles

Declaration
void DrawColouredQuad(IDrawStage drawStage, CoordinateSpace space, Colour colour, Vector2 position, float width, float height, float depth, int layer = 0, float rotation_clockwise_radians = 0F)
Parameters
Type Name Description
IDrawStage drawStage

DrawStage reference

CoordinateSpace space

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

Colour colour

An overall colour applied to all vertices at drawing

Vector2 position

Centre position of the quad

System.Single width

Width of the quad

System.Single height

Height of the quad

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.Single rotation_clockwise_radians

Clockwise rotation of quad around centre point in radians

DrawLine(UInt64, CoordinateSpace, Vector2, Vector2, Single, Colour, Single, Int32, Boolean)

Draw Coloured Line

Declaration
void DrawLine(ulong drawStage, CoordinateSpace space, Vector2 from, Vector2 to, float width, Colour colour, float depth, int layer = 0, bool rounded = false)
Parameters
Type Name Description
System.UInt64 drawStage

DrawStage id

CoordinateSpace space

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

Vector2 from

Location of the start of the line (middle of the line's thickness)

Vector2 to

Location of the end of the line (middle of the line's thickness)

System.Single width

Width of the line (thickness)

Colour colour

An overall colour applied to all vertices at drawing

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 rounded

Set whether the ends of the lines are rounded

DrawLine(IDrawStage, CoordinateSpace, Vector2, Vector2, Single, Colour, Single, Int32, Boolean)

Draw Coloured Line

Declaration
void DrawLine(IDrawStage drawStage, CoordinateSpace space, Vector2 from, Vector2 to, float width, Colour colour, float depth, int layer = 0, bool rounded = false)
Parameters
Type Name Description
IDrawStage drawStage

DrawStage reference

CoordinateSpace space

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

Vector2 from

Location of the start of the line (middle of the line's thickness)

Vector2 to

Location of the end of the line (middle of the line's thickness)

System.Single width

Width of the line (thickness)

Colour colour

An overall colour applied to all vertices at drawing

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 rounded

Set whether the ends of the lines are rounded

DrawTexturedQuad(UInt64, CoordinateSpace, UInt64, Colour, Vector2, Single, Single, Single, Int32, Single, Single, Single, Single, Single, TextureCoordinateMode)

Draw Textured Quad (rectangle) made from two triangles

Declaration
void DrawTexturedQuad(ulong drawStage, CoordinateSpace space, ulong texture, Colour colour, Vector2 position, float width, float height, float depth, int layer = 0, float rotation_clockwise_radians = 0F, float texcoord_min_x = 0F, float texcoord_min_y = 0F, float texcoord_max_x = 1F, float texcoord_max_y = 1F, TextureCoordinateMode textureMode = TextureCoordinateMode.Wrap)
Parameters
Type Name Description
System.UInt64 drawStage

DrawStage id

CoordinateSpace space

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

System.UInt64 texture

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

Colour colour

An overall colour applied to all vertices at drawing

Vector2 position

Centre position of the quad

System.Single width

Width of the quad

System.Single height

Height of the quad

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.Single rotation_clockwise_radians

Clockwise rotation of quad around centre point in radians

System.Single texcoord_min_x

Texture coordinate of left edge of quad

System.Single texcoord_min_y

Texture coordinate of top edge of quad

System.Single texcoord_max_x

Texture coordinate of right edge of quad

System.Single texcoord_max_y

Texture coordinate of bottom edge of quad

TextureCoordinateMode textureMode

Texture Coordinate Wrap Type (mirrored or repeated)

DrawTexturedQuad(IDrawStage, CoordinateSpace, ITexture, Colour, Vector2, Single, Single, Single, Int32, Single, Single, Single, Single, Single, TextureCoordinateMode)

Draw Textured Quad (rectangle) made from two triangles

Declaration
void DrawTexturedQuad(IDrawStage drawStage, CoordinateSpace space, ITexture texture, Colour colour, Vector2 position, float width, float height, float depth, int layer = 0, float rotation_clockwise_radians = 0F, float texcoord_min_x = 0F, float texcoord_min_y = 0F, float texcoord_max_x = 1F, float texcoord_max_y = 1F, TextureCoordinateMode textureMode = TextureCoordinateMode.Wrap)
Parameters
Type Name Description
IDrawStage drawStage

DrawStage reference

CoordinateSpace space

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

ITexture texture

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

Colour colour

An overall colour applied to all vertices at drawing

Vector2 position

Centre position of the quad

System.Single width

Width of the quad

System.Single height

Height of the quad

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.Single rotation_clockwise_radians

Clockwise rotation of quad around centre point in radians

System.Single texcoord_min_x

Texture coordinate of left edge of quad

System.Single texcoord_min_y

Texture coordinate of top edge of quad

System.Single texcoord_max_x

Texture coordinate of right edge of quad

System.Single texcoord_max_y

Texture coordinate of bottom edge of quad

TextureCoordinateMode textureMode

Texture Coordinate Wrap Type (mirrored or repeated)

In This Article
Back to top yak2D - Alex Paterson