/** * Returns a copy of this PMatrix. */ public PMatrix2D get() { PMatrix2D outgoing = new PMatrix2D(); outgoing.set(this); return outgoing; }
/** * Returns a copy of this PMatrix. */ public PMatrix2D get() { PMatrix2D outgoing = new PMatrix2D(); outgoing.set(this); return outgoing; }
protected void pushTransform() { if (transformStack == null) transformStack = new Stack<PMatrix>(); PMatrix mat; if (transform instanceof PMatrix2D) { mat = new PMatrix2D(); } else { mat = new PMatrix3D(); } mat.set(transform); transformStack.push(mat); }
protected void pushTransform() { if (transformStack == null) transformStack = new Stack<PMatrix>(); PMatrix mat; if (transform instanceof PMatrix2D) { mat = new PMatrix2D(); } else { mat = new PMatrix3D(); } mat.set(transform); transformStack.push(mat); }
@Override public PMatrix2D getMatrix(PMatrix2D target) { if (target == null) { target = new PMatrix2D(); } g2.getTransform().getMatrix(transform); target.set((float) transform[0], (float) transform[2], (float) transform[4], (float) transform[1], (float) transform[3], (float) transform[5]); return target; }
return new PMatrix2D(m[0], m[2], m[4], m[1], m[3], m[5]); return new PMatrix2D(1, 0, tx, 0, 1, ty); return new PMatrix2D(sx, 0, 0, 0, sy, 0); float s = PApplet.sin(angle); return new PMatrix2D(c, -s, 0, s, c, 0); PMatrix2D mat = new PMatrix2D(0, 1, m[1], 1, 0, m[2]); mat.rotate(m[0]); mat.translate(-m[1], -m[2]); return new PMatrix2D(1, 0, 1, PApplet.tan(m[0]), 0, 0); return new PMatrix2D(1, 0, 1, 0, PApplet.tan(m[0]), 0);
/** * Make sure that the shape's matrix is 1) not null, and 2) has a matrix * that can handle <em>at least</em> the specified number of dimensions. */ protected void checkMatrix(int dimensions) { if (matrix == null) { if (dimensions == 2) { matrix = new PMatrix2D(); } else { matrix = new PMatrix3D(); } } else if (dimensions == 3 && (matrix instanceof PMatrix2D)) { // time for an upgrayedd for a double dose of my pimpin' matrix = new PMatrix3D(matrix); } }
/** * Make sure that the shape's matrix is 1) not null, and 2) has a matrix * that can handle <em>at least</em> the specified number of dimensions. */ protected void checkMatrix(int dimensions) { if (matrix == null) { if (dimensions == 2) { matrix = new PMatrix2D(); } else { matrix = new PMatrix3D(); } } else if (dimensions == 3 && (matrix instanceof PMatrix2D)) { // time for an upgrayedd for a double dose of my pimpin' matrix = new PMatrix3D(matrix); } }
return new PMatrix2D(m[0], m[2], m[4], m[1], m[3], m[5]); float ty = (m.length == 2) ? m[1] : m[0]; return new PMatrix2D(1, 0, tx, 0, 1, ty); float sy = (m.length == 2) ? m[1] : m[0]; return new PMatrix2D(sx, 0, 0, 0, sy, 0); float s = PApplet.sin(angle); return new PMatrix2D(c, -s, 0, s, c, 0); PMatrix2D mat = new PMatrix2D(0, 1, m[1], 1, 0, m[2]); mat.rotate(m[0]); mat.translate(-m[1], -m[2]); return new PMatrix2D(1, 0, 1, PApplet.tan(m[0]), 0, 0); return new PMatrix2D(1, 0, 1, 0, PApplet.tan(m[0]), 0);
@Override public PMatrix2D getMatrix(PMatrix2D target) { if (target == null) { target = new PMatrix2D(); } // canvas.getTransform().getMatrix(transform); Matrix m = new Matrix(); canvas.getMatrix(m); m.getValues(transform); // target.set((float) transform[0], (float) transform[2], (float) transform[4], // (float) transform[1], (float) transform[3], (float) transform[5]); target.set((float) transform[0], (float) transform[1], (float) transform[2], (float) transform[3], (float) transform[4], (float) transform[5]); return target; }
@Override public PMatrix2D getMatrix(PMatrix2D target) { if (target == null) { target = new PMatrix2D(); } //double[] transform = new double[6]; // TODO This is not tested; apparently Affine is a full 3x4 Affine t = context.getTransform(); //.getMatrix(transform); // target.set((float) transform[0], (float) transform[2], (float) transform[4], // (float) transform[1], (float) transform[3], (float) transform[5]); target.set((float) t.getMxx(), (float) t.getMxy(), (float) t.getTx(), (float) t.getMyx(), (float) t.getMyy(), (float) t.getTy()); return target; }
private PMatrix getMatrix(PShape shape) { boolean useParams = true; float[] params = null; try { params = shape.getParams(); } catch (NullPointerException npe) { useParams = false; } PMatrix matrix = ((PShapeSVGExtended) shape).getMatrix(); if (matrix == null) { matrix = new PMatrix2D(); } else { // use a copy matrix = matrix.get(); } if (useParams) { matrix.translate(params[0], params[1]); } // is root. if (shape.getParent() == null) { return matrix; } PMatrix2D parentMat = (PMatrix2D) getMatrix(shape.getParent()); matrix.preApply(parentMat); return matrix; }
if (matrix == null) matrix = new PMatrix2D(); matrix.scale(width/viewBox[2], height/viewBox[3]); matrix.translate(-viewBox[0], -viewBox[1]);
ohio = (PShape)usa.getChild("OH"); PMatrix2D transform = new PMatrix2D(); //apply transforms(position,rotation,scale) to this matrix transform.scale(2); //be aware that the order of operation matters! transform.translate(-800,-300); //this matrix can be used to convert from screen coordinats to SVG coordinates
if (transform == null) { if (dimensions == 2) { transform = new PMatrix2D(); } else { transform = new PMatrix3D();
if (transform == null) { if (dimensions == 2) { transform = new PMatrix2D(); } else { transform = new PMatrix3D();