Skip to content

Commit 417abd5

Browse files
committed
pull the pixelDensity() calls out
1 parent f5c55ee commit 417abd5

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

java/src/processing/mode/java/preproc/PdePreprocessor.java

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -309,20 +309,25 @@ make sure that it uses numbers (or displayWidth/Height), copy into settings
309309
searchArea = sb.toString();
310310
}
311311

312+
StringList extraStatements = new StringList();
313+
312314
// First look for noSmooth() or smooth(N) so we can hoist it into settings.
313-
String smoothStatement = null;
314315
String[] smoothContents = matchMethod("smooth", searchArea);
315316
if (smoothContents != null) {
316-
smoothStatement = smoothContents[0];
317+
extraStatements.append(smoothContents[0]);
317318
}
318319
String[] noContents = matchMethod("noSmooth", searchArea);
319320
if (noContents != null) {
320-
if (smoothStatement != null) {
321+
if (extraStatements != null) {
321322
throw new SketchException("smooth() and noSmooth() cannot be used in the same sketch");
322323
} else {
323-
smoothStatement = noContents[0];
324+
extraStatements.append(noContents[0]);
324325
}
325326
}
327+
String[] pixelDensityContents = matchMethod("pixelDensity", searchArea);
328+
if (pixelDensityContents != null) {
329+
extraStatements.append(pixelDensityContents[0]);
330+
}
326331

327332
String[] sizeContents = matchMethod("size", searchArea);
328333
String[] fullContents = matchMethod("fullScreen", searchArea);
@@ -364,8 +369,8 @@ make sure that it uses numbers (or displayWidth/Height), copy into settings
364369
throw new SketchException("Please fix the size() line to continue.", false);
365370
}
366371

367-
if (smoothStatement != null) {
368-
info.statement += smoothStatement;
372+
if (extraStatements != null) {
373+
info.statement += extraStatements;
369374
}
370375
info.checkEmpty();
371376
return info;
@@ -396,18 +401,18 @@ make sure that it uses numbers (or displayWidth/Height), copy into settings
396401
}
397402
info.width = "displayWidth";
398403
info.height = "displayHeight";
399-
if (smoothStatement != null) {
400-
info.statement += smoothStatement;
404+
if (extraStatements != null) {
405+
info.statement += extraStatements.join(" ");
401406
}
402407
info.checkEmpty();
403408
return info;
404409
}
405410

406411
// Made it this far, but no size() or fullScreen(), and still
407412
// need to pull out the noSmooth() and smooth(N) methods.
408-
if (smoothStatement != null) {
413+
if (extraStatements != null) {
409414
SurfaceInfo info = new SurfaceInfo();
410-
info.statement = smoothStatement;
415+
info.statement = extraStatements.join(" ");
411416
return info;
412417
}
413418

0 commit comments

Comments
 (0)