Class TextElement
Implements
Inherited Members
Namespace: GTA.UI
Assembly: ScriptHookVDotNet3.dll
Syntax
public class TextElement : IElement
Constructors
| Improve this Doc View SourceTextElement(String, PointF, Single)
Initializes a new instance of the TextElement class used for drawing text on the screen.
Declaration
public TextElement(string caption, PointF position, float scale)
Parameters
Type | Name | Description |
---|---|---|
String | caption | The TextElement to draw. |
PointF | position | Set the Position on screen where to draw the TextElement. |
Single | scale | Sets a Scale used to increase of decrease the size of the TextElement, for no scaling use 1.0f. |
TextElement(String, PointF, Single, Color)
Initializes a new instance of the TextElement class used for drawing text on the screen.
Declaration
public TextElement(string caption, PointF position, float scale, Color color)
Parameters
Type | Name | Description |
---|---|---|
String | caption | The TextElement to draw. |
PointF | position | Set the Position on screen where to draw the TextElement. |
Single | scale | Sets a Scale used to increase of decrease the size of the TextElement, for no scaling use 1.0f. |
Color | color | Set the Color used to draw the TextElement. |
TextElement(String, PointF, Single, Color, Font)
Initializes a new instance of the TextElement class used for drawing text on the screen.
Declaration
public TextElement(string caption, PointF position, float scale, Color color, Font font)
Parameters
Type | Name | Description |
---|---|---|
String | caption | The TextElement to draw. |
PointF | position | Set the Position on screen where to draw the TextElement. |
Single | scale | Sets a Scale used to increase of decrease the size of the TextElement, for no scaling use 1.0f. |
Color | color | Set the Color used to draw the TextElement. |
Font | font | Sets the Font used when drawing the text. |
TextElement(String, PointF, Single, Color, Font, Alignment)
Initializes a new instance of the TextElement class used for drawing text on the screen.
Declaration
public TextElement(string caption, PointF position, float scale, Color color, Font font, Alignment alignment)
Parameters
Type | Name | Description |
---|---|---|
String | caption | The TextElement to draw. |
PointF | position | Set the Position on screen where to draw the TextElement. |
Single | scale | Sets a Scale used to increase of decrease the size of the TextElement, for no scaling use 1.0f. |
Color | color | Set the Color used to draw the TextElement. |
Font | font | Sets the Font used when drawing the text. |
Alignment | alignment | Sets the Alignment used when drawing the text, Left,Center or Right. |
TextElement(String, PointF, Single, Color, Font, Alignment, Boolean, Boolean)
Initializes a new instance of the TextElement class used for drawing text on the screen.
Declaration
public TextElement(string caption, PointF position, float scale, Color color, Font font, Alignment alignment, bool shadow, bool outline)
Parameters
Type | Name | Description |
---|---|---|
String | caption | The TextElement to draw. |
PointF | position | Set the Position on screen where to draw the TextElement. |
Single | scale | Sets a Scale used to increase of decrease the size of the TextElement, for no scaling use 1.0f. |
Color | color | Set the Color used to draw the TextElement. |
Font | font | Sets the Font used when drawing the text. |
Alignment | alignment | Sets the Alignment used when drawing the text, Left,Center or Right. |
Boolean | shadow | Sets whether or not to draw the TextElement with a Shadow effect. |
Boolean | outline | Sets whether or not to draw the TextElement with an Outline around the letters. |
TextElement(String, PointF, Single, Color, Font, Alignment, Boolean, Boolean, Single)
Initializes a new instance of the TextElement class used for drawing text on the screen.
Declaration
public TextElement(string caption, PointF position, float scale, Color color, Font font, Alignment alignment, bool shadow, bool outline, float wrapWidth)
Parameters
Type | Name | Description |
---|---|---|
String | caption | The TextElement to draw. |
PointF | position | Set the Position on screen where to draw the TextElement. |
Single | scale | Sets a Scale used to increase of decrease the size of the TextElement, for no scaling use 1.0f. |
Color | color | Set the Color used to draw the TextElement. |
Font | font | Sets the Font used when drawing the text. |
Alignment | alignment | Sets the Alignment used when drawing the text, Left,Center or Right. |
Boolean | shadow | Sets whether or not to draw the TextElement with a Shadow effect. |
Boolean | outline | Sets whether or not to draw the TextElement with an Outline around the letters. |
Single | wrapWidth | Sets how many horizontal pixel to draw before wrapping the TextElement on the next line down. |
Properties
| Improve this Doc View SourceAlignment
Gets or sets the alignment of this TextElement.
Declaration
public Alignment Alignment { get; set; }
Property Value
Type | Description |
---|---|
Alignment | The alignment: |
Caption
Gets or sets the text to draw in this TextElement.
Declaration
public string Caption { get; set; }
Property Value
Type | Description |
---|---|
String | The caption. |
Centered
Gets or sets a value indicating whether the alignment of this TextElement is centered. See Alignment
Declaration
public bool Centered { get; set; }
Property Value
Type | Description |
---|---|
Boolean | true if centered; otherwise, false. |
Color
Gets or sets the color of this TextElement.
Declaration
public Color Color { get; set; }
Property Value
Type | Description |
---|---|
Color | The color. |
Enabled
Gets or sets a value indicating whether this TextElement will be drawn.
Declaration
public bool Enabled { get; set; }
Property Value
Type | Description |
---|---|
Boolean | true if enabled; otherwise, false. |
Font
Gets or sets the font of this TextElement.
Declaration
public Font Font { get; set; }
Property Value
Type | Description |
---|---|
Font | The GTA Font use when drawing. |
Outline
Gets or sets a value indicating whether this TextElement is drawn with an outline.
Declaration
public bool Outline { get; set; }
Property Value
Type | Description |
---|---|
Boolean | true if outline; otherwise, false. |
Position
Gets or sets the position of this TextElement.
Declaration
public PointF Position { get; set; }
Property Value
Type | Description |
---|---|
PointF | The position scaled on a 1280*720 pixel base. |
Remarks
If ScaledDraw is called, the position will be scaled by the width returned in ScaledWidth.
Scale
Gets or sets the scale of this TextElement.
Declaration
public float Scale { get; set; }
Property Value
Type | Description |
---|---|
Single | The scale usually a value between ~0.5 and 3.0, Default = 1.0 |
ScaledWidth
Measures how many pixels in the horizontal axis this TextElement will use when drawn against a ScaledWidth pixel base
Declaration
public float ScaledWidth { get; }
Property Value
Type | Description |
---|---|
Single |
Shadow
Gets or sets a value indicating whether this TextElement is drawn with a shadow effect.
Declaration
public bool Shadow { get; set; }
Property Value
Type | Description |
---|---|
Boolean | true if shadow; otherwise, false. |
Width
Measures how many pixels in the horizontal axis this TextElement will use when drawn against a 1280 pixel base
Declaration
public float Width { get; }
Property Value
Type | Description |
---|---|
Single |
WrapWidth
Gets or sets the maximum size of the TextElement before it wraps to a new line.
Declaration
public float WrapWidth { get; set; }
Property Value
Type | Description |
---|---|
Single | The width of the TextElement. |
Methods
| Improve this Doc View SourceDraw()
Draws the TextElement this frame.
Declaration
public virtual void Draw()
Draw(SizeF)
Draws the TextElement this frame at the specified offset.
Declaration
public virtual void Draw(SizeF offset)
Parameters
Type | Name | Description |
---|---|---|
SizeF | offset | The offset to shift the draw position of this TextElement using a 1280*720 pixel base. |
Finalize()
Declaration
protected void Finalize()
GetScaledStringWidth(String, Font, Single)
Measures how many pixels in the horizontal axis the string will use when drawn
Declaration
public static float GetScaledStringWidth(string text, Font font = Font.ChaletLondon, float scale = 1F)
Parameters
Type | Name | Description |
---|---|---|
String | text | The string of text to measure. |
Font | font | The Font of the textu to measure. |
Single | scale | Sets a sclae value for increasing or decreasing the size of the text, default value 1.0f - no scaling. |
Returns
Type | Description |
---|---|
Single | The amount of pixels scaled by the pixel width base return in ScaledWidth |
GetStringWidth(String, Font, Single)
Measures how many pixels in the horizontal axis the string will use when drawn
Declaration
public static float GetStringWidth(string text, Font font = Font.ChaletLondon, float scale = 1F)
Parameters
Type | Name | Description |
---|---|---|
String | text | The string of text to measure. |
Font | font | The Font of the textu to measure. |
Single | scale | Sets a sclae value for increasing or decreasing the size of the text, default value 1.0f - no scaling. |
Returns
Type | Description |
---|---|
Single | The amount of pixels scaled on a 1280 pixel width base |
ScaledDraw()
Draws the TextElement this frame using the width returned in ScaledWidth.
Declaration
public virtual void ScaledDraw()
ScaledDraw(SizeF)
Draws the TextElement this frame at the specified offset using the width returned in ScaledWidth.
Declaration
public virtual void ScaledDraw(SizeF offset)
Parameters
Type | Name | Description |
---|---|---|
SizeF | offset | The offset to shift the draw position of this TextElement using a ScaledWidth*720 pixel base. |