/** * @param z forward/back translation */ public void translate(float x, float y, float z) { checkMatrix(3); matrix.translate(x, y, z); }
/** * @param tz forward/back translation */ public void translate(float x, float y, float z) { checkMatrix(3); matrix.translate(x, y, z); }
/** * ( begin auto-generated from PShape_translate.xml ) * * Specifies an amount to displace the shape. The <b>x</b> parameter * specifies left/right translation, the <b>y</b> parameter specifies * up/down translation, and the <b>z</b> parameter specifies translations * toward/away from the screen. Subsequent calls to the method accumulates * the effect. For example, calling <b>translate(50, 0)</b> and then * <b>translate(20, 0)</b> is the same as <b>translate(70, 0)</b>. This * transformation is applied directly to the shape, it's not refreshed each * time <b>draw()</b> is run. * <br /><br /> * Using this method with the <b>z</b> parameter requires using the P3D * parameter in combination with size. * * ( end auto-generated ) * @webref pshape:method * @usage web_application * @brief Displaces the shape * @param tx left/right translation * @param ty up/down translation * @see PShape#rotate(float) * @see PShape#scale(float) * @see PShape#resetMatrix() */ public void translate(float x, float y) { checkMatrix(2); matrix.translate(x, y); }
/** * ( begin auto-generated from PShape_translate.xml ) * * Specifies an amount to displace the shape. The <b>x</b> parameter * specifies left/right translation, the <b>y</b> parameter specifies * up/down translation, and the <b>z</b> parameter specifies translations * toward/away from the screen. Subsequent calls to the method accumulates * the effect. For example, calling <b>translate(50, 0)</b> and then * <b>translate(20, 0)</b> is the same as <b>translate(70, 0)</b>. This * transformation is applied directly to the shape, it's not refreshed each * time <b>draw()</b> is run. * <br /><br /> * Using this method with the <b>z</b> parameter requires using the P3D * parameter in combination with size. * * ( end auto-generated ) * @webref pshape:method * @usage web_application * @brief Displaces the shape * @param x left/right translation * @param y up/down translation * @see PShape#rotate(float) * @see PShape#scale(float) * @see PShape#resetMatrix() */ public void translate(float x, float y) { checkMatrix(2); matrix.translate(x, y); }
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; }
matrix.translate(-viewBox[0], -viewBox[1]);