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:
The4codeblocks
2025-04-19 10:03:22 -05:00
committed by GitHub
parent b07acb3ce1
commit 757188b270

View File

@@ -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);