Class GorgonPolySpriteBuilder
A builder used to create a new GorgonPolySprite object.
Implements
Inherited Members
Namespace: Gorgon.Renderers
Assembly: Gorgon.Renderers.Gorgon2D.dll
Syntax
public class GorgonPolySpriteBuilder : IGorgonFluentBuilder<GorgonPolySpriteBuilder, GorgonPolySprite>, IEnumerable<GorgonPolySpriteVertex>, IEnumerable, IGorgonGraphicsObject
Remarks
Because the GorgonPolySprite cannot be created using the new keyword, this builder is used to build GorgonPolySprite objects.
The polygonal sprite created by this builder is built up by adding multiple GorgonPolySpriteVertex objects to the builder and calling the Build() method. These vertices make up the "hull" of the polygon (basically the outer shape of the polygon), which gets turned into triangles so it can be rendered by Gorgon. Vertex manipulation is not the only functionality provided by the builder, other initial values may also be assigned for the created sprite as well.
important
A minimum of 3 vertices are required to build a polygonal sprite. Attempting to do so with less will cause an exception.
This builder is not the only way to create a polygonal sprite, users can define a series of triangle vertices and indices and use Create(GorgonGraphics, IReadOnlyList<GorgonPolySpriteVertex>, IReadOnlyList<int>) on the GorgonPolySprite.
The resulting polygonal sprite from this builder implements IDisposable. Therefore, it is the user's responsibility to dispose of the object when they are done with it.
Constructors
| Edit this page View SourceGorgonPolySpriteBuilder(Gorgon2D)
Initializes a new instance of the GorgonPolySpriteBuilder class.
Declaration
public GorgonPolySpriteBuilder(Gorgon2D renderer)
Parameters
Type | Name | Description |
---|---|---|
Gorgon2D | renderer | The renderer interface to use for building the polygon sprite. |
See Also
Properties
| Edit this page View SourceGraphics
Property to return the graphics interface that built this object.
Declaration
public GorgonGraphics Graphics { get; }
Property Value
Type | Description |
---|---|
GorgonGraphics |
See Also
| Edit this page View SourceVertexCount
Property to return the number of vertices in the polysprite.
Declaration
public int VertexCount { get; }
Property Value
Type | Description |
---|---|
int |
See Also
Methods
| Edit this page View SourceAddVertex(GorgonPolySpriteVertex)
Function to add a vertex to the polysprite.
Declaration
public GorgonPolySpriteBuilder AddVertex(GorgonPolySpriteVertex vertex)
Parameters
Type | Name | Description |
---|---|---|
GorgonPolySpriteVertex | vertex | The vertex to add. |
Returns
Type | Description |
---|---|
GorgonPolySpriteBuilder | The fluent interface for this builder. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown when the |
See Also
| Edit this page View SourceAddVertices(IEnumerable<GorgonPolySpriteVertex>)
Function to add multiple vertices to the polysprite.
Declaration
public GorgonPolySpriteBuilder AddVertices(IEnumerable<GorgonPolySpriteVertex> vertices)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<GorgonPolySpriteVertex> | vertices | The vertices to add. |
Returns
Type | Description |
---|---|
GorgonPolySpriteBuilder | The fluent interface for this builder. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown when the |
See Also
| Edit this page View SourceAlphaTest(GorgonRangeF?)
Function to assign the inital alpha test value for the sprite.
Declaration
public GorgonPolySpriteBuilder AlphaTest(GorgonRangeF? alphaTest = null)
Parameters
Type | Name | Description |
---|---|---|
GorgonRangeF? | alphaTest | [Optional] The alpha test value to assign. |
Returns
Type | Description |
---|---|
GorgonPolySpriteBuilder | The fluent interface for this builder. |
Remarks
If the alphaTest
value is null, then alpha testing will be turned off for the sprite.
See Also
| Edit this page View SourceAnchor(Vector2)
Function to assign anchor value to the polygon sprite.
Declaration
public GorgonPolySpriteBuilder Anchor(Vector2 anchor)
Parameters
Type | Name | Description |
---|---|---|
Vector2 | anchor | The anchor for the sprite. |
Returns
Type | Description |
---|---|
GorgonPolySpriteBuilder | The fluent interface for this builder. |
Remarks
This value is in relative unit coordinates. For example, 0.5, 0.5 would mean the center of the sprite.
See Also
| Edit this page View SourceAngle(float)
Function to assign an initial rotation value to the polygon sprite.
Declaration
public GorgonPolySpriteBuilder Angle(float degrees)
Parameters
Type | Name | Description |
---|---|---|
float | degrees | The angle, in degrees, to rotate. |
Returns
Type | Description |
---|---|
GorgonPolySpriteBuilder | The fluent interface for this builder. |
See Also
| Edit this page View SourceBuild()
Function to return the object.
Declaration
public GorgonPolySprite Build()
Returns
Type | Description |
---|---|
GorgonPolySprite | The object created or updated by this builder. |
Remarks
This will return a GorgonPolySprite for use with the DrawPolygonSprite(GorgonPolySprite) method. The object returned implements IDisposable, so it is the responsibility of the user to dispose of the object when they are done with it.
warning
A polygon sprite must have a minimum of 3 vertices. If it does not, then this method will throw an exception.
Exceptions
Type | Condition |
---|---|
GorgonException | Thrown if the polygonal sprite has less than 3 vertices. |
See Also
| Edit this page View SourceClear()
Function to clear the builder to a default state.
Declaration
public GorgonPolySpriteBuilder Clear()
Returns
Type | Description |
---|---|
GorgonPolySpriteBuilder | The fluent builder interface. |
See Also
| Edit this page View SourceColor(GorgonColor)
Function to assign the color for the polygon sprite.
Declaration
public GorgonPolySpriteBuilder Color(GorgonColor color)
Parameters
Type | Name | Description |
---|---|---|
GorgonColor | color | The color to assign. |
Returns
Type | Description |
---|---|
GorgonPolySpriteBuilder | The fluent interface for this builder. |
See Also
| Edit this page View SourceFlip(bool, bool)
Function to flip the texture coordinates for the polygon sprite.
Declaration
public GorgonPolySpriteBuilder Flip(bool horizontal = false, bool vertical = false)
Parameters
Type | Name | Description |
---|---|---|
bool | horizontal | [Optional] true to flip horizontally. |
bool | vertical | [Optional] true to flip vertically. |
Returns
Type | Description |
---|---|
GorgonPolySpriteBuilder | The fluent interface for this builder. |
See Also
| Edit this page View SourceGetEnumerator()
Returns an enumerator that iterates through the collection.
Declaration
public IEnumerator<GorgonPolySpriteVertex> GetEnumerator()
Returns
Type | Description |
---|---|
IEnumerator<GorgonPolySpriteVertex> | An enumerator that can be used to iterate through the collection. |
See Also
| Edit this page View SourceInsertVertex(int, GorgonPolySpriteVertex)
Function to insert a vertex at the specified index.
Declaration
public GorgonPolySpriteBuilder InsertVertex(int index, GorgonPolySpriteVertex vertex)
Parameters
Type | Name | Description |
---|---|---|
int | index | The index to insert into. |
GorgonPolySpriteVertex | vertex | The vertex to insert. |
Returns
Type | Description |
---|---|
GorgonPolySpriteBuilder | The fluent interface for the this builder. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown when the |
See Also
| Edit this page View SourceInsertVertices(int, IEnumerable<GorgonPolySpriteVertex>)
Function to insert multiple vertices at the specified index.
Declaration
public GorgonPolySpriteBuilder InsertVertices(int index, IEnumerable<GorgonPolySpriteVertex> vertices)
Parameters
Type | Name | Description |
---|---|---|
int | index | The index to insert into. |
IEnumerable<GorgonPolySpriteVertex> | vertices | The vertices to insert. |
Returns
Type | Description |
---|---|
GorgonPolySpriteBuilder | The fluent interface for the this builder. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown when the |
See Also
| Edit this page View SourceMoveVertex(GorgonPolySpriteVertex, int)
Function to move the specified vertex to a new location in the list.
Declaration
public GorgonPolySpriteBuilder MoveVertex(GorgonPolySpriteVertex vertex, int newIndex)
Parameters
Type | Name | Description |
---|---|---|
GorgonPolySpriteVertex | vertex | The vertex to move. |
int | newIndex | The new index for the vertex. |
Returns
Type | Description |
---|---|
GorgonPolySpriteBuilder | The fluent interface for the this builder. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown when the |
See Also
| Edit this page View SourceMoveVertex(int, int)
Function to move the vertex at the specified index to a new location in the list.
Declaration
public GorgonPolySpriteBuilder MoveVertex(int oldIndex, int newIndex)
Parameters
Type | Name | Description |
---|---|---|
int | oldIndex | The index of the vertex to move. |
int | newIndex | The new index for the vertex. |
Returns
Type | Description |
---|---|
GorgonPolySpriteBuilder | The fluent interface for the this builder. |
See Also
| Edit this page View SourcePosition(Vector2, float)
Function to assign an initial position to the polygon sprite.
Declaration
public GorgonPolySpriteBuilder Position(Vector2 position, float depth = 0)
Parameters
Type | Name | Description |
---|---|---|
Vector2 | position | The position of the sprite. |
float | depth | [Optional] A depth value for the sprite. |
Returns
Type | Description |
---|---|
GorgonPolySpriteBuilder | The fluent interface for this builder. |
See Also
| Edit this page View SourceRemoveVertex(GorgonPolySpriteVertex)
Function to remove a vertex from the polysprite.
Declaration
public GorgonPolySpriteBuilder RemoveVertex(GorgonPolySpriteVertex vertex)
Parameters
Type | Name | Description |
---|---|---|
GorgonPolySpriteVertex | vertex | The vertex to remove. |
Returns
Type | Description |
---|---|
GorgonPolySpriteBuilder | The fluent interface for this builder. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown when the |
See Also
| Edit this page View SourceRemoveVertex(int)
Function to remove a vertex from the polysprite.
Declaration
public GorgonPolySpriteBuilder RemoveVertex(int index)
Parameters
Type | Name | Description |
---|---|---|
int | index | The index of the vertex to remove. |
Returns
Type | Description |
---|---|
GorgonPolySpriteBuilder | The fluent interface for this builder. |
Exceptions
Type | Condition |
---|---|
IndexOutOfRangeException | Thrown when the |
See Also
| Edit this page View SourceRemoveVertices(int, int)
Function to remove multiple vertices from the polysprite.
Declaration
public GorgonPolySpriteBuilder RemoveVertices(int start, int count)
Parameters
Type | Name | Description |
---|---|---|
int | start | The starting index to use. |
int | count | The number of indices to remove. |
Returns
Type | Description |
---|---|
GorgonPolySpriteBuilder | The fluent interface for this builder. |
Exceptions
Type | Condition |
---|---|
IndexOutOfRangeException | Thrown when the |
See Also
| Edit this page View SourceResetTo(GorgonPolySprite)
Function to reset the builder to the specified object state.
Declaration
public GorgonPolySpriteBuilder ResetTo(GorgonPolySprite builderObject = null)
Parameters
Type | Name | Description |
---|---|---|
GorgonPolySprite | builderObject | [Optional] The specified object state to copy. |
Returns
Type | Description |
---|---|
GorgonPolySpriteBuilder | The fluent builder interface. |
See Also
| Edit this page View SourceScale(Vector2)
Function to assign an initial scale to the polygon sprite.
Declaration
public GorgonPolySpriteBuilder Scale(Vector2 scale)
Parameters
Type | Name | Description |
---|---|---|
Vector2 | scale | The scale to assign to the polygon sprite. |
Returns
Type | Description |
---|---|
GorgonPolySpriteBuilder | The fluent interface for this builder. |
See Also
| Edit this page View SourceTexture(GorgonTexture2DView)
Function to assign a texture to the polygon sprite.
Declaration
public GorgonPolySpriteBuilder Texture(GorgonTexture2DView texture)
Parameters
Type | Name | Description |
---|---|---|
GorgonTexture2DView | texture | The texture to assign to the sprite. |
Returns
Type | Description |
---|---|
GorgonPolySpriteBuilder | The fluent interface for this builder. |
See Also
| Edit this page View SourceTextureArrayIndex(int)
Function to assign an array index for a texture array to the polygon sprite.
Declaration
public GorgonPolySpriteBuilder TextureArrayIndex(int textureArrayIndex)
Parameters
Type | Name | Description |
---|---|---|
int | textureArrayIndex | The texture array index to assign. |
Returns
Type | Description |
---|---|
GorgonPolySpriteBuilder | The fluent interface for this builder. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException | Thrown when the |
See Also
| Edit this page View SourceTextureCoordinate(int, Vector2)
Function to assign a texture coordinate to a vertex at the specified index.
Declaration
public GorgonPolySpriteBuilder TextureCoordinate(int index, Vector2 textureCoordinate)
Parameters
Type | Name | Description |
---|---|---|
int | index | The index of the vertex to update. |
Vector2 | textureCoordinate | The texture coordinate to assign. |
Returns
Type | Description |
---|---|
GorgonPolySpriteBuilder | The fluent interface for this builder. |
Exceptions
Type | Condition |
---|---|
IndexOutOfRangeException | Thrown when the |
See Also
| Edit this page View SourceTextureSampler(GorgonSamplerState)
Function to assign a texture sampler to the polygon sprite.
Declaration
public GorgonPolySpriteBuilder TextureSampler(GorgonSamplerState sampler)
Parameters
Type | Name | Description |
---|---|---|
GorgonSamplerState | sampler | The sampler to assign to the sprite. |
Returns
Type | Description |
---|---|
GorgonPolySpriteBuilder | The fluent interface for this builder. |
See Also
| Edit this page View SourceTextureTransform(Vector2, Vector2)
Function to assign the transformation to apply to a texture on the sprite.
Declaration
public GorgonPolySpriteBuilder TextureTransform(Vector2 textureOffset, Vector2 textureScale)
Parameters
Type | Name | Description |
---|---|---|
Vector2 | textureOffset | The translation amount to apply to the UV coordinates of the vertices in the polygon sprite. |
Vector2 | textureScale | The scale amount to apply to the UV coordinates of the vertices in the polygon sprite. |
Returns
Type | Description |
---|---|
GorgonPolySpriteBuilder | The fluent interface for this builder. |