UiValue
- Namespace: Turian.Engine.UI
- Source File: UiValue.cs
Parsers for the scalar value forms used in .ui inline styles and attributes.
Public Methods
TryLength
public static bool TryLength(string? text, float value, bool isPercent)
Parses a length: bare number or Npx → pixels; N% → the fraction (0..1) via isPercent.
Parameters:
text(string?): The length text.value(float): The parsed magnitude (pixels, or the 0..1 fraction for a percentage).isPercent(bool): True when the text ended with%.
Returns: bool
TryFloat
public static bool TryFloat(string? text, float value)
Parses a bare float (invariant culture).
Parameters:
text(string?): The number text.value(float): The parsed value.
Returns: bool
TryBool
public static bool TryBool(string? text, bool value)
Parses a bool: true/false/1/0/yes/no.
Parameters:
text(string?): The text.value(bool): The parsed bool.
Returns: bool
TryColor
public static bool TryColor(string? text, GuiColor color)
Parses a color: #rgb, #rrggbb, #rrggbbaa, rgb(r,g,b), rgba(r,g,b,a) (a in 0..1 or 0..255), or a named color Guinevere knows.
Parameters:
text(string?): The color text.color(GuiColor): The parsed color.
Returns: bool