take care of ellipse/rect/image modes in PShape (fixes #3685)

This commit is contained in:
Ben Fry
2015-08-21 10:24:45 -04:00
parent 7f62a019f2
commit 0a62e9fc9c
5 changed files with 47 additions and 15 deletions
+17
View File
@@ -1544,6 +1544,9 @@ public class PShape implements PConstants {
// TODO unapproved
static protected void copyStyles(PShape src, PShape dest) {
dest.ellipseMode = src.ellipseMode;
dest.rectMode = src.rectMode;
if (src.stroke) {
dest.stroke = true;
dest.strokeColor = src.strokeColor;
@@ -1640,8 +1643,13 @@ public class PShape implements PConstants {
} else if (kind == RECT) {
if (image != null) {
int oldMode = g.imageMode;
g.imageMode(CORNER);
g.image(image, params[0], params[1], params[2], params[3]);
g.imageMode(oldMode);
} else {
int oldMode = g.rectMode;
g.rectMode(rectMode);
if (params.length == 4) {
g.rect(params[0], params[1],
params[2], params[3]);
@@ -1655,11 +1663,18 @@ public class PShape implements PConstants {
params[4], params[5],
params[6], params[7]);
}
g.rectMode(oldMode);
}
} else if (kind == ELLIPSE) {
int oldMode = g.ellipseMode;
g.ellipseMode(ellipseMode);
g.ellipse(params[0], params[1],
params[2], params[3]);
g.ellipseMode(oldMode);
} else if (kind == ARC) {
int oldMode = g.ellipseMode;
g.ellipseMode(ellipseMode);
if (params.length == 6) {
g.arc(params[0], params[1],
params[2], params[3],
@@ -1670,6 +1685,8 @@ public class PShape implements PConstants {
params[4], params[5],
(int) params[6]);
}
g.ellipseMode(oldMode);
} else if (kind == BOX) {
if (params.length == 1) {
g.box(params[0]);
+6 -7
View File
@@ -100,7 +100,7 @@ public class PShapeSVG extends PShape {
protected float svgHeight;
/** √((w² + h²)/2) of containing SVG (used for percentages). */
protected float svgXYSize;
protected float svgSizeXY;
protected Gradient strokeGradient;
String strokeName; // id of another object, gradients only?
@@ -177,7 +177,7 @@ public class PShapeSVG extends PShape {
svgWidth = width;
svgHeight = height;
svgXYSize = PApplet.sqrt((svgWidth*svgWidth + svgHeight*svgHeight)/2.0f);
svgSizeXY = PApplet.sqrt((svgWidth*svgWidth + svgHeight*svgHeight)/2.0f);
}
element = properties;
@@ -262,7 +262,7 @@ public class PShapeSVG extends PShape {
svgWidth = parent.svgWidth;
svgHeight = parent.svgHeight;
svgXYSize = parent.svgXYSize;
svgSizeXY = parent.svgSizeXY;
opacity = parent.opacity;
}
@@ -416,7 +416,7 @@ public class PShapeSVG extends PShape {
float rx, ry;
if (circle) {
rx = ry = getFloatWithUnit(element, "r", svgXYSize);
rx = ry = getFloatWithUnit(element, "r", svgSizeXY);
} else {
rx = getFloatWithUnit(element, "rx", svgWidth);
ry = getFloatWithUnit(element, "ry", svgHeight);
@@ -426,7 +426,6 @@ public class PShapeSVG extends PShape {
params[2] = rx*2;
params[3] = ry*2;
}
@@ -1181,7 +1180,7 @@ public class PShapeSVG extends PShape {
void setStrokeWeight(String lineweight) {
strokeWeight = parseUnitSize(lineweight, svgXYSize);
strokeWeight = parseUnitSize(lineweight, svgSizeXY);
}
@@ -1537,7 +1536,7 @@ public class PShapeSVG extends PShape {
this.cx = getFloatWithUnit(properties, "cx", svgWidth);
this.cy = getFloatWithUnit(properties, "cy", svgHeight);
this.r = getFloatWithUnit(properties, "r", svgXYSize);
this.r = getFloatWithUnit(properties, "r", svgSizeXY);
String transformStr =
properties.getString("gradientTransform");
+6 -7
View File
@@ -3,6 +3,7 @@
/*
Part of the Processing project - http://processing.org
Copyright (c) 2012-15 The Processing Foundation
Copyright (c) 2011-12 Ben Fry and Casey Reas
This library is free software; you can redistribute it and/or
@@ -4802,7 +4803,6 @@ public class PShapeOpenGL extends PShape {
}
// Applies the styles of g.
@Override
protected void styles(PGraphics g) {
if (g instanceof PGraphicsOpenGL) {
@@ -4849,9 +4849,11 @@ public class PShapeOpenGL extends PShape {
// Rendering methods
/*
public void draw() {
draw(pg);
}
*/
@Override
@@ -4876,18 +4878,15 @@ public class PShapeOpenGL extends PShape {
}
render(gl, tex);
}
} else {
render(gl, image);
}
post(gl);
}
} else {
// The renderer is not PGraphicsOpenGL, which probably
// means that the draw() method is being called by the
// recorder. We just use the default drawing from the
// parent class.
// The renderer is not PGraphicsOpenGL, which probably means that
// the draw() method is being called by the recorder. We just use
// the default draw implementation from the parent class.
super.draw(g);
}
}
+6
View File
@@ -1,6 +1,8 @@
0243 core (3.0b5)
X NullPointerException in selectFolder() on OS X
X https://github.com/processing/processing/issues/3661
X Wrong positioning of circles in SVG shapes (regression from 2)
X https://github.com/processing/processing/issues/3685
cleaning
X How do images behave when pixelDensity(2) is set?
@@ -22,6 +24,10 @@ X implement frameRate()
X FX - Fix key typed
X https://github.com/processing/processing/pull/3672
java.lang.StringIndexOutOfBoundsException: String index out of range: 0
at java.lang.String.charAt(String.java:658)
at processing.javafx.PSurfaceFX.fxKeyEvent(PSurfaceFX.java:713)
known issues
_ P2D and P3D windows behave strangely when larger than the screen size
+12 -1
View File
@@ -6,6 +6,7 @@ X line selected for errors is off by one or two
X https://github.com/processing/processing/issues/3654
X PDE window leaks undisposed Timer objects even when closed
X https://github.com/processing/processing/issues/3655
_ items still show up in "Recent" if they no longer exist (on startup)
contribs
X Undo does not move to the correct location in the editor window
@@ -32,6 +33,13 @@ X https://github.com/processing/processing/pull/3675
X remove category dropdown from CM except when viewing libraries
X https://github.com/processing/processing/issues/3668
X https://github.com/processing/processing/pull/3676
X Fix info panel text color and alignment in CM
_ https://github.com/processing/processing/issues/3642
X https://github.com/processing/processing/pull/3684
X Right-clicking popup menu closes instead of shifting its location
X https://github.com/processing/processing/issues/3649
X Use 1x or 2x icons in the CM
X https://github.com/processing/processing/pull/3681
cleaning
X modify build to insert these after antlr run:
@@ -81,6 +89,9 @@ _ http://www.oracle.com/us/technologies/java/locale-140624.html
3.0 final
_ CM: Clicking item in Libraries list throws exception
_ https://github.com/processing/processing/issues/3667
_ Casey reports that exported app still asks to download Java
_ prompt to install Xcode coming up on Export to Application
_ http://stackoverflow.com/questions/15371925/how-to-check-if-command-line-tools-is-installed
_ "xcode-select -p" returns 0 if they exist (and the dir) or 2 if they don't
@@ -180,7 +191,7 @@ crashing
_ fix appbundler problems due to rollback
_ appbundler is no longer being developed by Oracle, switch to "packager"
_ this re-introduces two bugs (serial export and scrolling)
_ and any other changes later than 16 November 2015:
_ and any other changes later than 16 November 2014:
_ https://github.com/processing/processing/commits/master/build/macosx/appbundler.jar
_ https://github.com/processing/processing/commits/master/build/macosx/appbundler/native/main.m
_ another possible culprit