Gorilla.Arena.Utils Unit Reference
Overview
The Gorilla.Arena.Utils unit converts the two value types an
entity cannot store directly — a colour and a 3D
point — to and from the strings that go into its JSON document.
All four functions use an invariant (en-US) format, so a value written on a
machine with German locale reads back correctly on one with English locale.
That is the whole reason they exist: FloatToStr would produce 1,25 on one
device and fail to parse it on the other.
Functions
| Function | Description |
|---|---|
StringToAlphaColorF(const AValue : String) : TAlphaColorF |
Reads four floats. Accepts commas or spaces as separators. Missing alpha defaults to 1. Swaps red and blue |
AlphaColorFToString(const AValue : TAlphaColorF; const ADelimiter : Char = ' ') : String |
Writes R G B A with seven decimals |
StringToPoint3D(const AValue : String) : TPoint3D |
Reads three floats. Accepts commas or spaces |
Point3DToString(const AValue : TPoint3D; const ADelimiter : Char = ' ') : String |
Writes X Y Z with seven decimals |
Notes
StringToAlphaColorF exchanges the red and blue components as it reads. It is
the counterpart of the channel swap TGorillaArenaUser applies on Windows —
use the two together, as TGorillaArenaUser.GetColor and SetColor do, rather
than one on its own.
An unparsable component becomes 0 rather than raising, so a malformed value
arriving from another device cannot take the application down.