more pixel density fixes

This commit is contained in:
Ben Fry
2015-06-13 17:50:54 -04:00
parent f7d542b2a6
commit 13d019696c
5 changed files with 59 additions and 26 deletions

View File

@@ -293,6 +293,18 @@ public class PApplet implements PConstants {
*/
public int height = DEFAULT_HEIGHT;
/**
* Width of the pixels in this drawing surface
* (takes pixelDensity into account).
*/
public int pixelWidth;
/**
* Height of the pixels in this drawing surface
* (takes pixelDensity into account).
*/
public int pixelHeight;
/**
* ( begin auto-generated from mouseX.xml )
*
@@ -811,7 +823,7 @@ public class PApplet implements PConstants {
boolean fullScreen;
int display = -1; // use default
GraphicsDevice[] displayDevices;
int pixelDensity = 1;
public int pixelDensity = 1;
String outputPath;
OutputStream outputStream;
@@ -897,19 +909,16 @@ public class PApplet implements PConstants {
final public int sketchWidth() {
//return DEFAULT_WIDTH;
return width;
}
final public int sketchHeight() {
//return DEFAULT_HEIGHT;
return height;
}
final public String sketchRenderer() {
//return JAVA2D;
return renderer;
}
@@ -1061,6 +1070,18 @@ public class PApplet implements PConstants {
}
/**
* Called by PSurface objects to set the width and height variables,
* and update the pixelWidth and pixelHeight variables.
*/
public void setSize(int width, int height) {
this.width = width;
this.height = height;
pixelWidth = width * pixelDensity;
pixelHeight = height * pixelDensity;
}
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

View File

@@ -168,12 +168,14 @@ public class PSurfaceAWT extends PSurfaceNone {
super.validate();
newSize.width = getWidth();
newSize.height = getHeight();
if (oldSize.equals(newSize)) {
// System.out.println("validate() return " + oldSize);
return;
} else {
// if (oldSize.equals(newSize)) {
//// System.out.println("validate() return " + oldSize);
// return;
// } else {
if (!oldSize.equals(newSize)) {
// System.out.println("validate() render old=" + oldSize + " -> new=" + newSize);
oldSize = newSize;
sketch.setSize(newSize.width, newSize.height);
render();
}
}
@@ -783,8 +785,9 @@ public class PSurfaceAWT extends PSurfaceNone {
//initImage(graphics, wide, high);
//throw new RuntimeException("implement me, see readme.md");
sketch.width = wide;
sketch.height = high;
sketch.setSize(wide, high);
// sketch.width = wide;
// sketch.height = high;
// set PGraphics variables for width/height/pixelWidth/pixelHeight
graphics.setSize(wide, high);

View File

@@ -75,7 +75,8 @@ public class PSurfaceFX implements PSurface {
@Override
public void changed(ObservableValue<? extends Number> value,
Number oldWidth, Number newWidth) {
sketch.width = newWidth.intValue();
// sketch.width = newWidth.intValue();
sketch.setSize(newWidth.intValue(), sketch.height);
// draw();
fx.setSize(sketch.width, sketch.height);
}
@@ -84,7 +85,8 @@ public class PSurfaceFX implements PSurface {
@Override
public void changed(ObservableValue<? extends Number> value,
Number oldHeight, Number newHeight) {
sketch.height = newHeight.intValue();
// sketch.height = newHeight.intValue();
sketch.setSize(sketch.width, newHeight.intValue());
// draw();
fx.setSize(sketch.width, sketch.height);
}

View File

@@ -522,8 +522,9 @@ public class PSurfaceJOGL implements PSurface {
// System.err.println("3. set size");
if (!presentMode) {
sketch.width = width;
sketch.height = height;
// sketch.width = width;
// sketch.height = height;
sketch.setSize(width, height);
sketchWidth = width;
sketchHeight = height;
graphics.setSize(width, height);

View File

@@ -1,10 +1,20 @@
0238 (3.0b1)
retina fixes
X make g.pixelDensity public inside PApplet (so accessible by sketches)
o or is it akin to g.fill and the rest?
X it's in PApplet, but not public.. will be the same as g.pixelDensity
X add pixelWidth/Height to PApplet
X add setSize() method for surfaces
X tricky cuz we'll need a getter/setter when surface messes w/ things
text/fonts
X Text looks blurry in GL Retina
X https://github.com/processing/processing/issues/2739
X text not getting the correct font in Retina2D
X https://github.com/processing/processing/issues/2617
X Text is half size in PGraphicsRetina2D
X https://github.com/processing/processing/issues/2738
andres
X ortho function is broken
@@ -14,6 +24,14 @@ X https://github.com/processing/processing/issues/3379
beta
_ need to be able to call pixelDensity(2) before beginDraw()
_ add pixelDensity() method to PImage/PGraphics
_ pixelDensity(2) does: pixelWidth = width; width /= 2; pixelDensity = 2;
_ this works for both PGraphics and images (though they're a little backwards)
_ for PGraphics it comes early enough
_ pixelDensity(BEST)? (messes with pixels, but for most sketches, helpful)
_ NPE when using image() created with createGraphics(PGraphicsRetina2D)
_ https://github.com/processing/processing/issues/2510
_ replace sketchXxxx() methods with another mechanism?
_ and an internal dictionary that stores them all?
_ intParam(), stringParam() and setParam()?
@@ -22,13 +40,6 @@ _ surface.size(), surface.noSmooth()... just like PGraphics methods?
_ make final to move folks away from these?
_ or is this a bad move until we've sorted out Android?
_ update wiki/docs to say "don't override sketchXxxx() methods"
_ pixelDensity(BEST)? (messes with pixels, but for most sketches, helpful)
_ add pixelDensity() method to PImage/PGraphics
_ pixelDensity(2) does: pixelWidth = width; width /= 2; pixelDensity = 2;
_ this works for both PGraphics and images (though they're a little backwards)
_ for PGraphics it comes early enough
_ g.pixelDensity should prolly move to PApplet?
_ or is it akin to g.fill and the rest?
high priority
@@ -194,11 +205,6 @@ _ retina sketches slow to start
_ https://github.com/processing/processing/issues/2357
_ zero alpha values still a problem with retina renderer
_ https://github.com/processing/processing/issues/2030
_ NPE when using image() created with createGraphics(PGraphicsRetina2D)
_ https://github.com/processing/processing/issues/2510
_ check retina with PGraphicsRetina2D
_ Text is half size in PGraphicsRetina2D
_ https://github.com/processing/processing/issues/2738
decisions/misc