Interface IGorgon2DDrawingFluent
A fluent interface for drawing commands on a Gorgon2D object.
Namespace: Gorgon.Renderers
Assembly: Gorgon.Renderers.Gorgon2D.dll
Syntax
public interface IGorgon2DDrawingFluent
Methods
| Edit this page View SourceDrawArc(RectangleF, GorgonColor, float, float, float, float, GorgonTexture2DView, RectangleF?, int, GorgonSamplerState, float)
Function to draw an ellipse.
Declaration
IGorgon2DDrawingFluent DrawArc(RectangleF region, GorgonColor color, float startAngle, float endAngle, float smoothness = 1, float thickness = 1, GorgonTexture2DView texture = null, RectangleF? textureRegion = null, int textureArrayIndex = 0, GorgonSamplerState textureSampler = null, float depth = 0)
Parameters
Type | Name | Description |
---|---|---|
RectangleF | region | The region that will contain the ellipse. |
GorgonColor | color | The color of the ellipse. |
float | startAngle | The starting angle of the arc, in degrees. |
float | endAngle | The ending angle of the arc, in degrees. |
float | smoothness | [Optional] The smoothness of the ellipse. |
float | thickness | [Optional] The ellipse line thickness. |
GorgonTexture2DView | texture | [Optional] The texture to render on the ellipse. |
RectangleF? | textureRegion | [Optional] The texture coordinates to map to the rectangle. |
int | textureArrayIndex | [Optional] The array index for a texture array to use. |
GorgonSamplerState | textureSampler | [Optional] The texture sampler to apply to the texture. |
float | depth | [Optional] The depth value for the ellipse. |
Returns
Type | Description |
---|---|
IGorgon2DDrawingFluent | The fluent interface for drawing. |
DrawEach<T>(IEnumerable<T>, Func<T, IGorgon2DDrawingFluent, bool>)
Function to execute a callback method for each item in an enumerable list of items.
Declaration
IGorgon2DDrawingFluent DrawEach<T>(IEnumerable<T> items, Func<T, IGorgon2DDrawingFluent, bool> drawCommands)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<T> | items | The list of items to enumerate through. |
Func<T, IGorgon2DDrawingFluent, bool> | drawCommands | The callback method containing the drawing commands. |
Returns
Type | Description |
---|---|
IGorgon2DDrawingFluent | The fluent interface for drawing. |
Type Parameters
Name | Description |
---|---|
T | The type of item to draw. |
Remarks
The drawCommands
parameter is a function that supplies the current iteration number of the loop, the fluent drawing interface and returns true to indicate that looping
should continue, or false to stop looping.
DrawEllipse(RectangleF, GorgonColor, float, float, GorgonTexture2DView, RectangleF?, int, GorgonSamplerState, float)
Function to draw an ellipse.
Declaration
IGorgon2DDrawingFluent DrawEllipse(RectangleF region, GorgonColor color, float smoothness = 1, float thickness = 1, GorgonTexture2DView texture = null, RectangleF? textureRegion = null, int textureArrayIndex = 0, GorgonSamplerState textureSampler = null, float depth = 0)
Parameters
Type | Name | Description |
---|---|---|
RectangleF | region | The region that will contain the ellipse. |
GorgonColor | color | The color of the ellipse. |
float | smoothness | [Optional] The smoothness of the ellipse. |
float | thickness | [Optional] The ellipse line thickness. |
GorgonTexture2DView | texture | [Optional] The texture to render on the ellipse. |
RectangleF? | textureRegion | [Optional] The texture coordinates to map to the rectangle. |
int | textureArrayIndex | [Optional] The array index for a texture array to use. |
GorgonSamplerState | textureSampler | [Optional] The texture sampler to apply to the texture. |
float | depth | [Optional] The depth value for the ellipse. |
Returns
Type | Description |
---|---|
IGorgon2DDrawingFluent | The fluent interface for drawing. |
DrawFilledArc(RectangleF, GorgonColor, float, float, float, GorgonTexture2DView, RectangleF?, int, GorgonSamplerState, float)
Function to draw an ellipse.
Declaration
IGorgon2DDrawingFluent DrawFilledArc(RectangleF region, GorgonColor color, float startAngle, float endAngle, float smoothness = 1, GorgonTexture2DView texture = null, RectangleF? textureRegion = null, int textureArrayIndex = 0, GorgonSamplerState textureSampler = null, float depth = 0)
Parameters
Type | Name | Description |
---|---|---|
RectangleF | region | The region that will contain the ellipse. |
GorgonColor | color | The color of the ellipse. |
float | startAngle | The starting angle of the arc, in degrees. |
float | endAngle | The ending angle of the arc, in degrees. |
float | smoothness | [Optional] The smoothness of the ellipse. |
GorgonTexture2DView | texture | [Optional] The texture to render on the ellipse. |
RectangleF? | textureRegion | [Optional] The texture coordinates to map to the rectangle. |
int | textureArrayIndex | [Optional] The array index for a texture array to use. |
GorgonSamplerState | textureSampler | [Optional] The texture sampler to apply to the texture. |
float | depth | [Optional] The depth value for the ellipse. |
Returns
Type | Description |
---|---|
IGorgon2DDrawingFluent | The fluent interface for drawing. |
DrawFilledEllipse(RectangleF, GorgonColor, float, GorgonTexture2DView, RectangleF?, int, GorgonSamplerState, float)
Function to draw an ellipse.
Declaration
IGorgon2DDrawingFluent DrawFilledEllipse(RectangleF region, GorgonColor color, float smoothness = 1, GorgonTexture2DView texture = null, RectangleF? textureRegion = null, int textureArrayIndex = 0, GorgonSamplerState textureSampler = null, float depth = 0)
Parameters
Type | Name | Description |
---|---|---|
RectangleF | region | The region that will contain the ellipse. |
GorgonColor | color | The color of the ellipse. |
float | smoothness | [Optional] The smoothness of the ellipse. |
GorgonTexture2DView | texture | [Optional] The texture to render on the ellipse. |
RectangleF? | textureRegion | [Optional] The texture coordinates to map to the rectangle. |
int | textureArrayIndex | [Optional] The array index for a texture array to use. |
GorgonSamplerState | textureSampler | [Optional] The texture sampler to apply to the texture. |
float | depth | [Optional] The depth value for the ellipse. |
Returns
Type | Description |
---|---|
IGorgon2DDrawingFluent | The fluent interface for drawing. |
DrawFilledRectangle(RectangleF, GorgonColor, GorgonTexture2DView, RectangleF?, int, GorgonSamplerState, float)
Function to draw a filled rectangle.
Declaration
IGorgon2DDrawingFluent DrawFilledRectangle(RectangleF region, GorgonColor color, GorgonTexture2DView texture = null, RectangleF? textureRegion = null, int textureArrayIndex = 0, GorgonSamplerState textureSampler = null, float depth = 0)
Parameters
Type | Name | Description |
---|---|---|
RectangleF | region | The region for the rectangle. |
GorgonColor | color | The color of the rectangle. |
GorgonTexture2DView | texture | [Optional] The texture for the rectangle. |
RectangleF? | textureRegion | [Optional] The texture coordinates to map to the rectangle. |
int | textureArrayIndex | [Optional] The array index for a texture array to use. |
GorgonSamplerState | textureSampler | [Optional] The texture sampler to apply to the texture. |
float | depth | [Optional] The depth value for the rectangle. |
Returns
Type | Description |
---|---|
IGorgon2DDrawingFluent | The fluent interface for drawing. |
DrawIf(Func<bool>, Action<IGorgon2DDrawingFluent>)
Function to evaluate an expression and if the expression is true, then execute a series of drawing commands contained within a callback method.
Declaration
IGorgon2DDrawingFluent DrawIf(Func<bool> expression, Action<IGorgon2DDrawingFluent> drawCommands)
Parameters
Type | Name | Description |
---|---|---|
Func<bool> | expression | The expression to evaluate. |
Action<IGorgon2DDrawingFluent> | drawCommands | The callback method containing the drawing commands. |
Returns
Type | Description |
---|---|
IGorgon2DDrawingFluent | The fluent interface for drawing. |
DrawLine(float, float, float, float, GorgonColor, float, GorgonTexture2DView, RectangleF?, int, GorgonSamplerState, float, float)
Function to draw a line.
Declaration
IGorgon2DDrawingFluent DrawLine(float x1, float y1, float x2, float y2, GorgonColor color, float thickness = 1, GorgonTexture2DView texture = null, RectangleF? textureRegion = null, int textureArrayIndex = 0, GorgonSamplerState textureSampler = null, float startDepth = 0, float endDepth = 0)
Parameters
Type | Name | Description |
---|---|---|
float | x1 | The starting horizontal position. |
float | y1 | The starting vertical position. |
float | x2 | The ending horizontal position. |
float | y2 | The ending vertical position. |
GorgonColor | color | The color of the line. |
float | thickness | [Optional] The line thickness. |
GorgonTexture2DView | texture | [Optional] The texture to render on the line. |
RectangleF? | textureRegion | [Optional] The texture coordinates to map to the rectangle. |
int | textureArrayIndex | [Optional] The array index for a texture array to use. |
GorgonSamplerState | textureSampler | [Optional] The texture sampler to apply to the texture. |
float | startDepth | [Optional] The depth value for the starting point of the line. |
float | endDepth | [Optional] The depth value for the ending point of the line. |
Returns
Type | Description |
---|---|
IGorgon2DDrawingFluent | The fluent interface for drawing. |
DrawLoop(int, Func<int, IGorgon2DDrawingFluent, bool>)
Function to execute a callback method containing drawing commands for the supplied amount of times.
Declaration
IGorgon2DDrawingFluent DrawLoop(int count, Func<int, IGorgon2DDrawingFluent, bool> drawCommands)
Parameters
Type | Name | Description |
---|---|---|
int | count | The number of times to loop. |
Func<int, IGorgon2DDrawingFluent, bool> | drawCommands | The callback method containing the drawing commands. |
Returns
Type | Description |
---|---|
IGorgon2DDrawingFluent | The fluent interface for drawing. |
DrawPolygonSprite(GorgonPolySprite)
Function to draw a polygonal sprite.
Declaration
IGorgon2DDrawingFluent DrawPolygonSprite(GorgonPolySprite sprite)
Parameters
Type | Name | Description |
---|---|---|
GorgonPolySprite | sprite | The polygon sprite to draw. |
Returns
Type | Description |
---|---|
IGorgon2DDrawingFluent | The fluent interface for drawing. |
Remarks
This method draws a sprite using a polygon as its surface. This is different from other sprite rendering in that:
- The surface is not rectangular.
- It is not batched with other drawing types, and is drawn immediately. This may be a performance hit.
The method takes a GorgonPolySprite object which contains GorgonPolySpriteVertex objects to define the outer shape (hull) of the polygon. Gorgon will triangulate the hull into a mesh that can be rendered.
GorgonPolySprite objects cannot be created directly, but can be built using the GorgonPolySpriteBuilder object. Please note that these objects implement
IDisposable, so users should call the Dispose
method when they are done with the objects.
caution
For performance reasons, any exceptions thrown from this method will only be thrown when Gorgon is compiled as DEBUG.
See Also
| Edit this page View SourceDrawRectangle(RectangleF, GorgonColor, float, GorgonTexture2DView, RectangleF?, int, GorgonSamplerState, float)
Function to draw a filled rectangle.
Declaration
IGorgon2DDrawingFluent DrawRectangle(RectangleF region, GorgonColor color, float thickness = 1, GorgonTexture2DView texture = null, RectangleF? textureRegion = null, int textureArrayIndex = 0, GorgonSamplerState textureSampler = null, float depth = 0)
Parameters
Type | Name | Description |
---|---|---|
RectangleF | region | The region for the rectangle. |
GorgonColor | color | The color of the rectangle. |
float | thickness | [Optional] The line thickness. |
GorgonTexture2DView | texture | [Optional] The texture for the rectangle. |
RectangleF? | textureRegion | [Optional] The texture coordinates to map to the rectangle. |
int | textureArrayIndex | [Optional] The array index for a texture array to use. |
GorgonSamplerState | textureSampler | [Optional] The texture sampler to apply to the texture. |
float | depth | [Optional] The depth value for the rectangle. |
Returns
Type | Description |
---|---|
IGorgon2DDrawingFluent | The fluent interface for drawing. |
DrawSprite(GorgonSprite)
Function to draw a sprite.
Declaration
IGorgon2DDrawingFluent DrawSprite(GorgonSprite sprite)
Parameters
Type | Name | Description |
---|---|---|
GorgonSprite | sprite | The sprite object to draw. |
Returns
Type | Description |
---|---|
IGorgon2DDrawingFluent | The fluent interface for drawing. |
Remarks
This method draws a regular rectangular GorgonSprite object.
A GorgonSprite is a data object that provides a means to rotate, scale and translate a texture region when rendering.
See Also
| Edit this page View SourceDrawString(string, Vector2, GorgonFont, GorgonColor?)
Function to draw text.
Declaration
IGorgon2DDrawingFluent DrawString(string text, Vector2 position, GorgonFont font = null, GorgonColor? color = null)
Parameters
Type | Name | Description |
---|---|---|
string | text | The text to render. |
Vector2 | position | The position of the text. |
GorgonFont | font | [Optional] The font to use. |
GorgonColor? | color | [Optional] The color of the text. |
Returns
Type | Description |
---|---|
IGorgon2DDrawingFluent | The fluent interface for drawing. |
Remarks
This is a convenience method that allows an application to draw text directly to the currently assigned render target.
If the font
parameter is not specified, then the DefaultFont is used to render the text.
If the color
parameter is not specified, then the White color is used.
DrawTextSprite(GorgonTextSprite)
Function to draw text.
Declaration
IGorgon2DDrawingFluent DrawTextSprite(GorgonTextSprite sprite)
Parameters
Type | Name | Description |
---|---|---|
GorgonTextSprite | sprite | The text sprite to render. |
Returns
Type | Description |
---|---|
IGorgon2DDrawingFluent | The fluent interface for drawing. |
Remarks
This method is used to draw a GorgonTextSprite to the current render target. A GorgonTextSprite is similar to a GorgonSprite in that it allows an application to take a block of text and translate, scale, and rotate the block of text.
Unlike the DrawString(string, Vector2, GorgonFont, GorgonColor?) method, which just renders whatever text is sent to it, a GorgonTextSprite can also be used to align text to a boundary (e.g. center, left align, etc...).
See Also
| Edit this page View SourceDrawTriangle(in GorgonTriangleVertex, in GorgonTriangleVertex, in GorgonTriangleVertex, GorgonTexture2DView, RectangleF?, int, GorgonSamplerState, float)
Function to draw a simple triangle.
Declaration
IGorgon2DDrawingFluent DrawTriangle(in GorgonTriangleVertex point1, in GorgonTriangleVertex point2, in GorgonTriangleVertex point3, GorgonTexture2DView texture = null, RectangleF? textureRegion = null, int textureArrayIndex = 0, GorgonSamplerState textureSampler = null, float depth = 0)
Parameters
Type | Name | Description |
---|---|---|
GorgonTriangleVertex | point1 | The vertex for the first point in the triangle. |
GorgonTriangleVertex | point2 | The vertex for the second point in the triangle. |
GorgonTriangleVertex | point3 | The vertex for the third point in the triangle. |
GorgonTexture2DView | texture | [Optional] The texture for the rectangle. |
RectangleF? | textureRegion | [Optional] The texture coordinates to map to the rectangle. |
int | textureArrayIndex | [Optional] The array index for a texture array to use. |
GorgonSamplerState | textureSampler | [Optional] The texture sampler to apply to the texture. |
float | depth | [Optional] The depth value for the rectangle. |
Returns
Type | Description |
---|---|
IGorgon2DDrawingFluent | The fluent interface for drawing. |
End()
Function to end rendering.
Declaration
IGorgon2DFluent End()
Returns
Type | Description |
---|---|
IGorgon2DFluent | The IGorgon2DFluent interface to allow continuation of rendering. |
Remarks
This finalizes rendering and flushes the current batch data to the GPU. Effectively, this is the method that performs the actual rendering for anything the user has drawn.
The 2D renderer uses batching to achieve its performance. Because of this, we define a batch with a call to Begin(Gorgon2DBatchState, GorgonCameraCommon) and End
. So, for optimal performance, it is best to draw
as much drawing as possible within the Begin/End batch body.
This method must be paired with a call to Begin(Gorgon2DBatchState, GorgonCameraCommon), if it is not, it will do nothing. If this method is not called after a call to Begin(Gorgon2DBatchState, GorgonCameraCommon), then nothing (in most cases) will be drawn. If a previous call to Begin(Gorgon2DBatchState, GorgonCameraCommon) is made, and this method is not called, and another call to Begin(Gorgon2DBatchState, GorgonCameraCommon) is made, an exception is thrown.
MeasureSprite(GorgonPolySprite, out RectangleF)
Property to return the bounds of the sprite, with transformation applied.
Declaration
IGorgon2DDrawingFluent MeasureSprite(GorgonPolySprite sprite, out RectangleF result)
Parameters
Type | Name | Description |
---|---|---|
GorgonPolySprite | sprite | The sprite to retrieve the boundaries from. |
RectangleF | result | The measurement result. |
Returns
Type | Description |
---|---|
IGorgon2DDrawingFluent | The fluent interface for drawing. |
Remarks
This is the equivalent of an axis aligned bounding box.
MeasureSprite(GorgonSprite, out RectangleF)
Property to return the bounds of the sprite, with transformation applied.
Declaration
IGorgon2DDrawingFluent MeasureSprite(GorgonSprite sprite, out RectangleF result)
Parameters
Type | Name | Description |
---|---|---|
GorgonSprite | sprite | The sprite to retrieve the boundaries from. |
RectangleF | result | The measurement result. |
Returns
Type | Description |
---|---|
IGorgon2DDrawingFluent | The fluent interface for drawing. |
Remarks
This is the equivalent of an axis aligned bounding box.
MeasureSprite(GorgonTextSprite, out RectangleF)
Property to return the bounds of the sprite, with transformation applied.
Declaration
IGorgon2DDrawingFluent MeasureSprite(GorgonTextSprite sprite, out RectangleF result)
Parameters
Type | Name | Description |
---|---|---|
GorgonTextSprite | sprite | The sprite to retrieve the boundaries from. |
RectangleF | result | The measurement result. |
Returns
Type | Description |
---|---|
IGorgon2DDrawingFluent | The fluent interface for drawing. |
Remarks
This is the equivalent of an axis aligned bounding box.
Update(Action<IGorgon2DDrawingFluent>)
Function to perform an arbitrary update of any required logic while rendering.
Declaration
IGorgon2DDrawingFluent Update(Action<IGorgon2DDrawingFluent> updateMethod)
Parameters
Type | Name | Description |
---|---|---|
Action<IGorgon2DDrawingFluent> | updateMethod | A method supplied by the user to perform some custom logic on objects that need to be rendered. |
Returns
Type | Description |
---|---|
IGorgon2DDrawingFluent | The fluent interface for drawing. |