Gorgon
Show / Hide Table of Contents

Class GorgonTextSprite

A class that defines a sprite that is used to display text.

Inheritance
object
GorgonTextSprite
Inherited Members
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
Namespace: Gorgon.Renderers
Assembly: Gorgon.Renderers.Gorgon2D.dll
Syntax
public class GorgonTextSprite

Constructors

| Edit this page View Source

GorgonTextSprite(GorgonFont, string)

Initializes a new instance of the GorgonTextSprite class.

Declaration
public GorgonTextSprite(GorgonFont font, string text = null)
Parameters
Type Name Description
GorgonFont font

The font used to render the text.

string text

[Optional] The text to render.

Exceptions
Type Condition
ArgumentNullException

Thrown when the font parameter is null.

Properties

| Edit this page View Source

Alignment

Property to set or return the alignment for the text.

Declaration
public Alignment Alignment { get; set; }
Property Value
Type Description
Alignment
Remarks

If the LayoutArea is defined, then it will be used to determine the layout of the text when aligning. Otherwise, the Size is used.

| Edit this page View Source

AllowColorCodes

Property to set or return whether color codes are allowed or not.

Declaration
public bool AllowColorCodes { get; set; }
Property Value
Type Description
bool
Remarks

The text sprite allows a developer to insert a special code into the Text string to enable coloring of individual letters or words. This code, which is similar to a bbcode is in the format of [c #AARRGGBB] and is closed with a tag of [/c]. For example, to change a block of text to red, pass [c #FFFF0000]Red[/c] text to the Text property.

Because enabling this value incurs more overhead for text rendering, it is defaulted to false.

| Edit this page View Source

AlphaTest

Property to set or return the alpha testing values.

Declaration
public GorgonRangeF? AlphaTest { get; set; }
Property Value
Type Description
GorgonRangeF?
Remarks

Alpha testing will skip rendering pixels based on the current alpha value for the pixel if it falls into the range specified by this property.

To disable alpha testing outright, set this property to null.

| Edit this page View Source

Anchor

Property to set or return the point around which the sprite will pivot when rotated.

Declaration
public Vector2 Anchor { get; set; }
Property Value
Type Description
Vector2
Remarks

This value is a relative value where 0, 0 means the upper left of the sprite, and 1, 1 means the lower right.

| Edit this page View Source

Angle

Property to set or return the angle of rotation, in degrees.

Declaration
public float Angle { get; set; }
Property Value
Type Description
float
| Edit this page View Source

Bounds

Property to return the boundaries of the sprite.

Declaration
public RectangleF Bounds { get; }
Property Value
Type Description
RectangleF
| Edit this page View Source

Color

Property to set or return the color of the sprite.

Declaration
public GorgonColor Color { get; set; }
Property Value
Type Description
GorgonColor
Remarks

This sets the color for the entire sprite. To assign colors to each corner of the sprite, use the GlyphCornerColors property.

| Edit this page View Source

Depth

Property to set or return the depth value for this sprite.

Declaration
public float Depth { get; set; }
Property Value
Type Description
float
| Edit this page View Source

DrawMode

Property to set or return how to draw the text when rendering.

Declaration
public TextDrawMode DrawMode { get; set; }
Property Value
Type Description
TextDrawMode
Remarks

This parameter will not have any effect if the Font was not generated with an OutlineSize greater than 0, and non transparent colors in OutlineColor1 and OutlineColor1.

See Also
IGorgonFontInfo
| Edit this page View Source

Font

Property to set or return the font to used for rendering text.

Declaration
public GorgonFont Font { get; set; }
Property Value
Type Description
GorgonFont
| Edit this page View Source

GlyphCornerColors

Property to return the interface that allows colors to be assigned to each corner of an individual font glyph.

Declaration
public GorgonGlyphColors GlyphCornerColors { get; }
Property Value
Type Description
GorgonGlyphColors
| Edit this page View Source

IsUpdated

Property to return whether or not the sprite has had its position, size, texture information, or object space vertices updated since it was last drawn.

Declaration
public bool IsUpdated { get; }
Property Value
Type Description
bool
| Edit this page View Source

LayoutArea

Property to set or return the layout area for the Alignment property.

Declaration
public Size2F? LayoutArea { get; set; }
Property Value
Type Description
Size2F?
Remarks

This defines a custom area to layout the text when changing its Alignment. By default, Gorgon will use the Bounds to determine the layout region for aligning text, but, when this property is defined, the layout region can be larger or smaller than the sprite Bounds.

| Edit this page View Source

LineSpace

Property to set or return a mulitplier used to indicate how much space to put between each vertical line.

Declaration
public float LineSpace { get; set; }
Property Value
Type Description
float
| Edit this page View Source

Lines

Property to return the individual lines of text within the Text property.

Declaration
public IReadOnlyList<string> Lines { get; }
Property Value
Type Description
IReadOnlyList<string>
| Edit this page View Source

OutlineTint

Property to set or return the tint color for an outline.

Declaration
public GorgonColor OutlineTint { get; set; }
Property Value
Type Description
GorgonColor
Remarks

This sets a tint color value for a text sprite with an outline. This parameter requires that the DrawMode property be set to true, and the Font has a OutlineSize that is greater than 0, and a non transparent OutlineColor1, and/or OutlineColor2.

See Also
IGorgonFontInfo
| Edit this page View Source

Position

Property to set or return the position of the sprite.

Declaration
public Vector2 Position { get; set; }
Property Value
Type Description
Vector2
| Edit this page View Source

Scale

Property to set or return the scale factor to apply to the sprite.

Declaration
public Vector2 Scale { get; set; }
Property Value
Type Description
Vector2
| Edit this page View Source

ScaledSize

Property to set or return the size of the renderable after scaling has been applied.

Declaration
public Size2F ScaledSize { get; set; }
Property Value
Type Description
Size2F
Remarks

This property will set or return the actual size of the renderable. This means that if a Scale has been set, then this property will return the size of the renderable with multiplied by the scale. When assigning a value, the scale be set on value derived from the current size of the renderable.

| Edit this page View Source

Size

Property to return the size of the sprite.

Declaration
public Size2F Size { get; }
Property Value
Type Description
Size2F
| Edit this page View Source

TabSpaceCount

Property to set or return the number of spaces to substitute when rendering a tab (\t) control character.

Declaration
public int TabSpaceCount { get; set; }
Property Value
Type Description
int
Remarks

The default value is 4.

| Edit this page View Source

Text

Property to set or return the text to render.

Declaration
public string Text { get; set; }
Property Value
Type Description
string
Remarks

This sets or returns the text to render.

This property will also allow the use of a color code (if the AllowColorCodes property is true). This code, which is similar to a bbcode is in the format of [c #AARRGGBB] and is closed with a tag of [/c]. For example, to change a block of text to red, pass [c #FFFF0000]Red[/c] text to the this property.

Because the color codes add more overhead when rendering text, it is best to only use it sparingly for performance intensive scenarios.

| Edit this page View Source

TextureSampler

Property to set or return the texture sampler to use when rendering.

Declaration
public GorgonSamplerState TextureSampler { get; set; }
Property Value
Type Description
GorgonSamplerState

Extension Methods

GorgonDebugExtensions.ValidateObject<T>(T, string)
GorgonNullExtensions.AsNullable<T>(object)
GorgonNullExtensions.IfNull<T>(object, T)
GorgonNullExtensions.IsNull(object)
  • Edit this page
  • View Source
In this article
Back to top Copyright 2023 - Licensed under the MIT license by Michael Winsor (Tape_Worm).
Send comments on this topic to the author