From 9ff5c973b2fb60b11a61035e623557be2aa277b3 Mon Sep 17 00:00:00 2001 From: Jakub Valtar Date: Thu, 16 Feb 2017 13:07:30 +0100 Subject: [PATCH] Add --density sketch arg --- core/src/processing/core/PApplet.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/core/src/processing/core/PApplet.java b/core/src/processing/core/PApplet.java index 473e032e8..46137db94 100644 --- a/core/src/processing/core/PApplet.java +++ b/core/src/processing/core/PApplet.java @@ -787,6 +787,8 @@ public class PApplet implements PConstants { */ static public final String ARGS_SKETCH_FOLDER = "--sketch-path"; + static public final String ARGS_DENSITY = "--density"; + /** * When run externally to a PdeEditor, * this is sent by the sketch when it quits. @@ -906,6 +908,7 @@ public class PApplet implements PConstants { // Unlike the others above, needs to be public to support // the pixelWidth and pixelHeight fields. public int pixelDensity = 1; + int suggestedDensity = -1; String outputPath; OutputStream outputStream; @@ -10367,6 +10370,7 @@ public class PApplet implements PConstants { // boolean fullScreen = false; boolean present = false; // boolean spanDisplays = false; + int density = -1; String param = null, value = null; String folder = calcSketchPath(); @@ -10409,6 +10413,15 @@ public class PApplet implements PConstants { } else if (param.equals(ARGS_LOCATION)) { location = parseInt(split(value, ',')); + + } else if (param.equals(ARGS_DENSITY)) { + density = parseInt(value, -1); + if (density == -1) { + System.err.println("Could not parse " + value + " for " + ARGS_DENSITY); + } else if (density != 1 && density != 2) { + density = -1; + System.err.println(ARGS_DENSITY + " should be 1 or 2"); + } } } else { @@ -10477,6 +10490,10 @@ public class PApplet implements PConstants { // (and most likely, from the PDE's preference setting). sketch.display = displayNum; + // Set the suggested density that is coming from command line + // (most likely set from the PDE based on a system DPI scaling) + sketch.suggestedDensity = density; + // For 3.0.1, moved this above handleSettings() so that loadImage() can be // used inside settings(). Sets a terrible precedent, but the alternative // of not being able to size a sketch to an image is driving people loopy.