Install Steam
login
|
language
简体中文 (Simplified Chinese)
繁體中文 (Traditional Chinese)
日本語 (Japanese)
한국어 (Korean)
ไทย (Thai)
Български (Bulgarian)
Čeština (Czech)
Dansk (Danish)
Deutsch (German)
Español - España (Spanish - Spain)
Español - Latinoamérica (Spanish - Latin America)
Ελληνικά (Greek)
Français (French)
Italiano (Italian)
Bahasa Indonesia (Indonesian)
Magyar (Hungarian)
Nederlands (Dutch)
Norsk (Norwegian)
Polski (Polish)
Português (Portuguese - Portugal)
Português - Brasil (Portuguese - Brazil)
Română (Romanian)
Русский (Russian)
Suomi (Finnish)
Svenska (Swedish)
Türkçe (Turkish)
Tiếng Việt (Vietnamese)
Українська (Ukrainian)
Report a translation problem
} //Trick: close the Program class so we can define Extensions classes
public static class EasyEXTHelpersColors // Helpers for KeenAPI/EasyAPI. Should be included in some of EasyEXT(ensions)
{
// Returns a Color object builded from a string. Warning: in the SE format so "{R:<d> G:<d> B:<d> A:<d>}"
public static Color ToColor(this String colorstring)
{
var matches = System.Text.RegularExpressions.Regex.Matches(colorstring, @"\d+");
Color color = new Color();
color.R = Byte.Parse(matches[0].Value);
color.G = Byte.Parse(matches[1].Value);
color.B = Byte.Parse(matches[2].Value);
color.A = Byte.Parse(matches[3].Value);
return color;
}
//Trick: no closing brace here, SE will close it automaticaly
public void Main(string argument) {
Color color = "{R:10 G:20 B:30 A:255}".ToColor();
Echo(Convert.ToString(color));
}
It will create a color from a string, the retransform it into a string and display it. As you can see the values are well preserved.
This is a stupid example but we will see how to use if with more EasyAPY extensions (EasyEXT...) in a next discussion ...
LKS