class
GUICanvas
A GUI element that allows the user to draw custom graphics.
All drawn elements relative to the canvas, to its origin in the top left corner.
Public
Methods
staticGetGuiTypeName
Returns type name of the GUI element used for finding GUI element styles.
DrawLine
Draws a line going from to .
- a
- Starting point of the line, relative to the canvas origin (top-left).
- b
- Ending point of the line, relative to the canvas origin (top-left).
- color
- Color of the line.
- depth
- Depth at which to draw the element. Elements with higher depth will be drawn before others. Additionally elements of the same type (triangle or line) will be drawn in order they are submitted if they share the same depth.
DrawPolyLine
Draws multiple lines following the path by the provided vertices.
First vertex connects to the second vertex, and every following vertex connects to the previous vertex.
- vertices
- Points to use for drawing the line. Must have at least two elements. All points are relative to the canvas origin (top-left).
- color
- Color of the line.
- depth
- Depth at which to draw the element. Elements with higher depth will be drawn before others. Additionally elements of the same type (triangle or line) will be drawn in order they are submitted if they share the same depth.
DrawImage
Draws a quad with a the provided image displayed.
- image
- Image to draw.
- area
- Position and size of the texture to draw. Position is relative to the canvas origin (top-left). If size is zero, the default texture size will be used.
- color
- Color to tint the drawn texture with.
- scaleMode
- Scale mode to use when sizing the texture. Only relevant if the provided quad size doesn't match the texture size.
- depth
- Depth at which to draw the element. Elements with higher depth will be drawn before others. Additionally elements of the same type (triangle or line) will be drawn in order they are submitted if they share the same depth.
DrawTriangleStrip
Draws a triangle strip.
First three vertices are used to form the initial triangle, and every next vertex will form a triangle with the previous two.
- vertices
- A set of points defining the triangles. Must have at least three elements. All points are relative to the canvas origin (top-left).
- color
- Color of the triangles.
- depth
- Depth at which to draw the element. Elements with higher depth will be drawn before others. Additionally elements of the same type (triangle or line) will be drawn in order they are submitted if they share the same depth.
DrawTriangleList
Draws a triangle list.
Every three vertices in the list represent a unique triangle.
- vertices
- A set of points defining the triangles. Must have at least three elements, and its size must be a multiple of three.
- color
- Color of the triangles.
- depth
- Depth at which to draw the element. Elements with higher depth will be drawn before others. Additionally elements of the same type (triangle or line) will be drawn in order they are submitted if they share the same depth.
DrawText
Draws a piece of text with the wanted font.
The text will be aligned to the top-left corner of the provided position, and will not be word wrapped.
- text
- Text to draw.
- position
- Position of the text to draw. This represents the top-left corner of the text. It is relative to the canvas origin (top-left).
- font
- Font to draw the text with.
- size
- Size of the font.
- color
- Color of the text.
- depth
- Depth at which to draw the element. Elements with higher depth will be drawn before others. Additionally elements of the same type (triangle or line) will be drawn in order they are submitted if they share the same depth.
Clear
Clears the canvas, removing any previously drawn elements.
staticCreate
Creates a new GUI element.
- styleClass
- Style class that will be used for determining GUI element visuals from the current style sheet. If no class is provided, default style is determined based on GUI element type.
- options
- Additional options that control GUI element size and position. This will override options set in the style sheet.
Internal
Constructors
GUICanvas
Methods
CalculateUnconstrainedOptimalSize
Calculates the optimal size for the GUI element, ignoring size constraints.
GetRenderElementDepthRange
Returns the range of depths that the child elements can be rendered it.
GetStyleSheetElement
Returns the name of the GUI element type to be used for style lookup in the style sheet.
Protected
Methods
~GUICanvas
FillBuffer
Fill the pre-allocated vertex, uv and index buffers with the mesh data for the specified render element.
- vertices
- Previously allocated buffer where to store the vertices. Output is expected to match the GUIMeshType as returned by getRenderElements() for the specified element.
- indices
- Previously allocated buffer where to store the indices.
- vertexOffset
- At which vertex should the method start filling the buffer.
- offset
- Offset that should be applied to all output vertex positions.
- indexOffset
- At which index should the method start filling the buffer.
- maxVertexCount
- Total number of vertices the buffers were allocated for. Used only for memory safety.
- maxIndexCount
- Total number of indices the buffers were allocated for. Used only for memory safety.
- renderElementIdx
- Zero-based index of the render element.
UpdateRenderElements
Recreates the internal render elements.
Must be called before GetRenderElementVertexAndIndexData/FillBuffer if element is dirty. Marks the element as non dirty.
BuildImageElement
Build an image sprite from the provided canvas element.
BuildTextElement
Build a text sprite from the provided canvas element.
BuildTriangleElement
Build a set of clipped triangles from the source triangles provided by the canvas element.
BuildAllTriangleElementsIfDirty
Rebuilds all triangle elements on the canvas, by constructing a set of clipped and offset triangles from the triangles provided by the canvas elements.
FindElement
Finds the canvas element that contains the render element with the specified index.