named colors in %<color> (#10682)
* named colors in %<color> * bad copying + needs closing bracket * fix formatt * some other (now fixed) bug gave me trouble, now I can remove this * shouldn't need access to Pal now
This commit is contained in:
@@ -93,6 +93,12 @@ public class LAssembler{
|
||||
if(symbol.startsWith("0x")) return Strings.parseLong(symbol, 16, 2, symbol.length(), invalidNum);
|
||||
if(symbol.startsWith("+0x")) return Strings.parseLong(symbol, 16, 3, symbol.length(), invalidNum);
|
||||
if(symbol.startsWith("-0x")) return -Strings.parseLong(symbol, 16, 3, symbol.length(), invalidNum);//FIXME: breaks with Long.MIN_VALUE
|
||||
if(symbol.startsWith("%[") && symbol.endsWith("]") && symbol.length() > 3){
|
||||
double color = parseNamedColor(symbol);
|
||||
if(color != -1d){
|
||||
return color;
|
||||
}
|
||||
}
|
||||
if(symbol.startsWith("%") && (symbol.length() == 7 || symbol.length() == 9)) return parseColor(symbol);
|
||||
|
||||
return Strings.parseDouble(symbol, invalidNum);
|
||||
@@ -108,6 +114,12 @@ public class LAssembler{
|
||||
return Color.toDoubleBits(r, g, b, a);
|
||||
}
|
||||
|
||||
double parseNamedColor(String symbol){
|
||||
Color color = Colors.get(symbol.substring(2, symbol.length() - 1));
|
||||
|
||||
return color == null ? -1d : color.toDoubleBits();
|
||||
}
|
||||
|
||||
/** Adds a constant value by name. */
|
||||
public LVar putConst(String name, Object value){
|
||||
LVar var = putVar(name);
|
||||
|
||||
Reference in New Issue
Block a user