added skewX/Y (bug #1448) and fixed bugs in its implementation

This commit is contained in:
benfry
2010-03-23 18:23:39 +00:00
parent ebd93a30b3
commit 992bbaffa6
12 changed files with 134 additions and 10 deletions
@@ -6884,6 +6884,16 @@ public class PApplet extends Activity implements PConstants, Runnable {
public void scale(float x, float y, float z) {
g.scale(x, y, z);
}
public void skewX(float angle) {
g.skewX(angle);
}
public void skewY(float angle) {
g.skewY(angle);
}
public void resetMatrix() {
@@ -3277,6 +3277,22 @@ public class PGraphics extends PImage implements PConstants {
public void scale(float x, float y, float z) {
showMissingWarning("scale");
}
/**
* Skew along X axis
*/
public void skewX(float angle) {
showMissingWarning("skewX");
}
/**
* Skew along Y axis
*/
public void skewY(float angle) {
showMissingWarning("skewY");
}
//////////////////////////////////////////////////////////////
@@ -1247,6 +1247,16 @@ public class PGraphicsAndroid2D extends PGraphics {
public void scale(float sx, float sy, float sz) {
showDepthWarningXYZ("scale");
}
public void skewX(float angle) {
canvas.skew((float) Math.tan(angle), 0);
}
public void skewY(float angle) {
canvas.skew(0, (float) Math.tan(angle));
}
@@ -2156,9 +2156,29 @@ public class PGraphicsAndroid3D extends PGraphics {
gl.glScalef(x, y, z);
modelviewUpdated = false;
}
}
}
public void skewX(float angle) {
float t = (float) Math.tan(angle);
applyMatrix(1, t, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0,
0, 0, 0, 1);
}
//////////////////////////////////////////////////////////////
public void skewY(float angle) {
float t = (float) Math.tan(angle);
applyMatrix(1, 0, 0, 0,
t, 1, 0, 0,
0, 0, 1, 0,
0, 0, 0, 1);
}
//////////////////////////////////////////////////////////////
// MATRIX MORE!
@@ -190,12 +190,12 @@ public class PMatrix2D implements PMatrix {
public void skewX(float angle) {
apply(1, 0, 1, angle, 0, 0);
apply(1, 0, 1, tan(angle), 0, 0);
}
public void skewY(float angle) {
apply(1, 0, 1, 0, angle, 0);
apply(1, 0, 1, 0, tan(angle), 0);
}
@@ -423,7 +423,8 @@ public class PMatrix2D implements PMatrix {
// TODO make this more efficient, or move into PMatrix2D
protected boolean isWarped() {
return ((m00 != 1) || (m01 != 0) &&
// was &&, but changed so skewX and skewY will work
return ((m00 != 1) || (m01 != 0) ||
(m10 != 0) || (m11 != 1));
}
@@ -446,4 +447,8 @@ public class PMatrix2D implements PMatrix {
private final float cos(float angle) {
return (float)Math.cos(angle);
}
private final float tan(float angle) {
return (float)Math.tan(angle);
}
}
+3
View File
@@ -1,4 +1,7 @@
0182 android
X added skewX/Y implementation
X http://dev.processing.org/bugs/show_bug.cgi?id=1448
_ for libraries that don't work with android, don't let them export
_ e.g. people adding the opengl library when it's not needed