2021-12-20 00:55:30 +00:00
|
|
|
package util;
|
|
|
|
|
|
|
|
import haxe.Exception;
|
|
|
|
import cc.Colors;
|
|
|
|
|
|
|
|
enum Color {
|
|
|
|
White;
|
|
|
|
Orange;
|
|
|
|
Magenta;
|
|
|
|
LightBlue;
|
|
|
|
Yellow;
|
|
|
|
Lime;
|
|
|
|
Pink;
|
|
|
|
Gray;
|
|
|
|
Grey;
|
|
|
|
LightGray;
|
|
|
|
LightGrey;
|
|
|
|
Cyan;
|
|
|
|
Purple;
|
|
|
|
Blue;
|
|
|
|
Brown;
|
|
|
|
Green;
|
|
|
|
Red;
|
|
|
|
Black;
|
|
|
|
}
|
|
|
|
|
|
|
|
class ColorConvert {
|
2022-02-21 14:35:37 +00:00
|
|
|
public static function colorToCC(color:Color):cc.Colors.Color {
|
2021-12-20 00:55:30 +00:00
|
|
|
switch color {
|
|
|
|
case White:
|
|
|
|
return Colors.white;
|
|
|
|
case Orange:
|
|
|
|
return Colors.orange;
|
|
|
|
case Magenta:
|
|
|
|
return Colors.magenta;
|
|
|
|
case LightBlue:
|
|
|
|
return Colors.lightBlue;
|
|
|
|
case Yellow:
|
|
|
|
return Colors.yellow;
|
|
|
|
case Lime:
|
|
|
|
return Colors.lime;
|
|
|
|
case Pink:
|
|
|
|
return Colors.pink;
|
|
|
|
case Gray:
|
|
|
|
return Colors.gray;
|
|
|
|
case Grey:
|
|
|
|
return Colors.grey;
|
|
|
|
case LightGray:
|
|
|
|
return Colors.lightGray;
|
|
|
|
case LightGrey:
|
|
|
|
return Colors.lightGrey;
|
|
|
|
case Cyan:
|
|
|
|
return Colors.cyan;
|
|
|
|
case Purple:
|
|
|
|
return Colors.purple;
|
|
|
|
case Blue:
|
|
|
|
return Colors.blue;
|
|
|
|
case Brown:
|
|
|
|
return Colors.brown;
|
|
|
|
case Green:
|
|
|
|
return Colors.green;
|
|
|
|
case Red:
|
|
|
|
return Colors.red;
|
|
|
|
case Black:
|
|
|
|
return Colors.black;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-02-21 14:35:37 +00:00
|
|
|
public static function ccToColor(color:cc.Colors.Color):Color {
|
2021-12-20 00:55:30 +00:00
|
|
|
switch color {
|
|
|
|
case 0:
|
|
|
|
return White;
|
|
|
|
case 1:
|
|
|
|
return Orange;
|
|
|
|
case 2:
|
|
|
|
return Magenta;
|
|
|
|
case 3:
|
|
|
|
return LightBlue;
|
|
|
|
case 4:
|
|
|
|
return Yellow;
|
|
|
|
case 5:
|
|
|
|
return Lime;
|
|
|
|
case 6:
|
|
|
|
return Pink;
|
|
|
|
case 7:
|
|
|
|
return Gray;
|
|
|
|
case 8:
|
|
|
|
return Grey;
|
|
|
|
case 9:
|
|
|
|
return LightGray;
|
|
|
|
case 10:
|
|
|
|
return LightGrey;
|
|
|
|
case 11:
|
|
|
|
return Cyan;
|
|
|
|
case 12:
|
|
|
|
return Purple;
|
|
|
|
case 13:
|
|
|
|
return Blue;
|
|
|
|
case 14:
|
|
|
|
return Brown;
|
|
|
|
case 15:
|
|
|
|
return Green;
|
|
|
|
case 16:
|
|
|
|
return Red;
|
|
|
|
case 17:
|
|
|
|
return Black;
|
|
|
|
case _:
|
|
|
|
throw new Exception("Invalid input");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|