mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
Closes #720.
Fix an issue where tweaks mode wont run if there are semi-transparent colors in the tab because of a regex issue.
This commit is contained in:
@@ -85,12 +85,26 @@ public class Handle {
|
||||
textFormat = "0x%x";
|
||||
|
||||
} else if ("webcolor".equals(type)) {
|
||||
Long val = Long.parseLong(strValue.substring(1, strValue.length()), 16);
|
||||
Long val;
|
||||
String prefix;
|
||||
if (strValue.length() == 7) {
|
||||
val = Long.parseLong(strValue.substring(1, strValue.length()), 16);
|
||||
prefix = "";
|
||||
} else {
|
||||
String valStr = strValue.substring(
|
||||
strValue.length() - 6,
|
||||
strValue.length()
|
||||
);
|
||||
val = Long.parseLong(valStr, 16);
|
||||
prefix = strValue.substring(
|
||||
1,
|
||||
strValue.length() - 6
|
||||
);
|
||||
}
|
||||
val = val | 0xff000000;
|
||||
value = newValue = val.intValue();
|
||||
strNewValue = strValue;
|
||||
textFormat = "#%06x";
|
||||
|
||||
textFormat = "#" + prefix + "%06x";
|
||||
} else if ("float".equals(type)) {
|
||||
value = newValue = Float.parseFloat(strValue);
|
||||
strNewValue = strValue;
|
||||
@@ -267,7 +281,19 @@ public class Handle {
|
||||
} else if ("hex".equals(type)) {
|
||||
tweakClient.sendInt(index, newValue.intValue());
|
||||
} else if ("webcolor".equals(type)) {
|
||||
tweakClient.sendInt(index, newValue.intValue());
|
||||
// If full opaque color, don't spend the cycles on string processing
|
||||
// which does appear to matter at high frame rates. Otherwise take the
|
||||
// hit and parse back from string value with transparency.
|
||||
if (strNewValue.length() == 7) {
|
||||
tweakClient.sendInt(index, newValue.intValue());
|
||||
} else {
|
||||
long target = Long.parseLong(
|
||||
strNewValue.substring(1, strNewValue.length()),
|
||||
16
|
||||
);
|
||||
tweakClient.sendInt(index, (int) target);
|
||||
}
|
||||
|
||||
} else if ("float".equals(type)) {
|
||||
tweakClient.sendFloat(index, newValue.floatValue());
|
||||
}
|
||||
|
||||
@@ -270,7 +270,7 @@ public class SketchParser {
|
||||
* list of all hexadecimal numbers in the sketch
|
||||
*/
|
||||
private void addAllWebColorNumbers() {
|
||||
Pattern p = Pattern.compile("#[A-Fa-f0-9]{6}");
|
||||
Pattern p = Pattern.compile("#([A-Fa-f0-9]{2})?[A-Fa-f0-9]{6}");
|
||||
for (int i=0; i<codeTabs.length; i++)
|
||||
{
|
||||
String c = codeTabs[i];
|
||||
|
||||
Reference in New Issue
Block a user