make pixelDensity(displayDensity()) work properly, fixes #3436

This commit is contained in:
Ben Fry
2015-06-26 08:47:00 -04:00
parent f04b908812
commit a052600d48
2 changed files with 14 additions and 1 deletions

View File

@@ -329,6 +329,11 @@ public class PdePreprocessor {
String[] pixelDensityContents = matchMethod("pixelDensity", searchArea);
if (pixelDensityContents != null) {
extraStatements.append(pixelDensityContents[0]);
} else {
pixelDensityContents = matchDensityMess(searchArea);
if (pixelDensityContents != null) {
extraStatements.append(pixelDensityContents[0]);
}
}
String[] sizeContents = matchMethod("size", searchArea);
@@ -433,6 +438,13 @@ public class PdePreprocessor {
}
static protected String[] matchDensityMess(String searchArea) {
final String regexp =
"(?:^|\\s|;)pixelDensity\\s*\\(\\s*displayDensity\\s*\\([^\\)]*\\)\\s*\\)\\s*\\;";
return PApplet.match(searchArea, regexp);
}
/**
* Replace all commented portions of a given String as spaces.
* Utility function used here and in the preprocessor.