/** * Push a copy of the current transformation matrix onto the stack. */ public void pushMatrix() { g.pushMatrix(); }
/** * ( begin auto-generated from pushMatrix.xml ) * * Pushes the current transformation matrix onto the matrix stack. * Understanding <b>pushMatrix()</b> and <b>popMatrix()</b> requires * understanding the concept of a matrix stack. The <b>pushMatrix()</b> * function saves the current coordinate system to the stack and * <b>popMatrix()</b> restores the prior coordinate system. * <b>pushMatrix()</b> and <b>popMatrix()</b> are used in conjuction with * the other transformation functions and may be embedded to control the * scope of the transformations. * * ( end auto-generated ) * * @webref transform * @see PGraphics#popMatrix() * @see PGraphics#translate(float, float, float) * @see PGraphics#scale(float) * @see PGraphics#rotate(float) * @see PGraphics#rotateX(float) * @see PGraphics#rotateY(float) * @see PGraphics#rotateZ(float) */ public void pushMatrix() { if (recorder != null) recorder.pushMatrix(); g.pushMatrix(); }
public void drawChar(PGraphics g, char c, float x, float y, float size) { g.pushMatrix(); float s = size / (float) face.unitsPerEm; g.translate(x, y); g.scale(s, -s); FontGlyph fg = (FontGlyph) unicodeGlyphs.get(new Character(c)); if (fg != null) g.shape(fg); g.popMatrix(); }
public void drawChar(PGraphics g, char c, float x, float y, float size) { g.pushMatrix(); float s = size / face.unitsPerEm; g.translate(x, y); g.scale(s, -s); FontGlyph fg = unicodeGlyphs.get(Character.valueOf(c)); if (fg != null) g.shape(fg); g.popMatrix(); }
private void beginHUD() { sketch.g.pushMatrix(); sketch.g.hint(PConstants.DISABLE_DEPTH_TEST); // Load the identity matrix. sketch.g.resetMatrix(); // Apply the original Processing transformation matrix. sketch.g.applyMatrix(originalMatrix); }
public void drawString(PGraphics g, String str, float x, float y, float size) { // 1) scale by the 1.0/unitsPerEm // 2) scale up by a font size g.pushMatrix(); float s = size / face.unitsPerEm; //System.out.println("scale is " + s); // swap y coord at the same time, since fonts have y=0 at baseline g.translate(x, y); g.scale(s, -s); char[] c = str.toCharArray(); for (int i = 0; i < c.length; i++) { // call draw on each char (pulling it w/ the unicode table) FontGlyph fg = unicodeGlyphs.get(Character.valueOf(c[i])); if (fg != null) { fg.draw(g); // add horizAdvX/unitsPerEm to the x coordinate along the way g.translate(fg.horizAdvX, 0); } else { System.err.println("'" + c[i] + "' not available."); } } g.popMatrix(); }
public void drawString(PGraphics g, String str, float x, float y, float size) { // 1) scale by the 1.0/unitsPerEm // 2) scale up by a font size g.pushMatrix(); float s = size / (float) face.unitsPerEm; //System.out.println("scale is " + s); // swap y coord at the same time, since fonts have y=0 at baseline g.translate(x, y); g.scale(s, -s); char[] c = str.toCharArray(); for (int i = 0; i < c.length; i++) { // call draw on each char (pulling it w/ the unicode table) FontGlyph fg = (FontGlyph) unicodeGlyphs.get(new Character(c[i])); if (fg != null) { fg.draw(g); // add horizAdvX/unitsPerEm to the x coordinate along the way g.translate(fg.horizAdvX, 0); } else { System.err.println("'" + c[i] + "' not available."); } } g.popMatrix(); }
protected void pre(PGraphics g) { if (matrix != null) { g.pushMatrix(); g.applyMatrix(matrix); } /* strokeSaved = g.stroke; strokeColorSaved = g.strokeColor; strokeWeightSaved = g.strokeWeight; strokeCapSaved = g.strokeCap; strokeJoinSaved = g.strokeJoin; fillSaved = g.fill; fillColorSaved = g.fillColor; rectModeSaved = g.rectMode; ellipseModeSaved = g.ellipseMode; shapeModeSaved = g.shapeMode; */ if (style) { g.pushStyle(); styles(g); } }
protected void pre(PGraphics g) { if (matrix != null) { g.pushMatrix(); g.applyMatrix(matrix); } /* strokeSaved = g.stroke; strokeColorSaved = g.strokeColor; strokeWeightSaved = g.strokeWeight; strokeCapSaved = g.strokeCap; strokeJoinSaved = g.strokeJoin; fillSaved = g.fill; fillColorSaved = g.fillColor; rectModeSaved = g.rectMode; ellipseModeSaved = g.ellipseMode; shapeModeSaved = g.shapeMode; */ if (style) { g.pushStyle(); styles(g); } }
public void shape(PShape shape) { if (shape.isVisible()) { // don't do expensive matrix ops if invisible if (shapeMode == CENTER) { pushMatrix(); translate(-shape.getWidth()/2, -shape.getHeight()/2); } shape.draw(this); // needs to handle recorder too if (shapeMode == CENTER) { popMatrix(); } } }
/** * Actual implementation of clearing the background, now that the * internal variables for background color have been set. Called by the * backgroundFromCalc() method, which is what all the other background() * methods call once the work is done. */ protected void backgroundImpl() { pushStyle(); pushMatrix(); resetMatrix(); fill(backgroundColor); rect(0, 0, width, height); popMatrix(); popStyle(); }
/** * Actual implementation of clearing the background, now that the * internal variables for background color have been set. Called by the * backgroundFromCalc() method, which is what all the other background() * methods call once the work is done. */ protected void backgroundImpl() { pushStyle(); pushMatrix(); resetMatrix(); fill(backgroundColor); rect(0, 0, width, height); popMatrix(); popStyle(); }
/** * Convenience method to draw at a particular location. */ public void shape(PShape shape, float x, float y) { if (shape.isVisible()) { // don't do expensive matrix ops if invisible pushMatrix(); if (shapeMode == CENTER) { translate(x - shape.getWidth()/2, y - shape.getHeight()/2); } else if ((shapeMode == CORNER) || (shapeMode == CORNERS)) { translate(x, y); } shape.draw(this); popMatrix(); } }
public void shape(PShape shape) { if (shape.isVisible()) { // don't do expensive matrix ops if invisible // Flushing any remaining geometry generated in the immediate mode // to avoid depth-sorting issues. flush(); if (shapeMode == CENTER) { pushMatrix(); translate(-shape.getWidth()/2, -shape.getHeight()/2); } shape.draw(this); // needs to handle recorder too if (shapeMode == CENTER) { popMatrix(); } } }
flush(); pushMatrix();
public void shape(PShape shape, float x, float y, float c, float d) { if (shape.isVisible()) { // don't do expensive matrix ops if invisible pushMatrix(); if (shapeMode == CENTER) { // x and y are center, c and d refer to a diameter translate(x - c/2f, y - d/2f); scale(c / shape.getWidth(), d / shape.getHeight()); } else if (shapeMode == CORNER) { translate(x, y); scale(c / shape.getWidth(), d / shape.getHeight()); } else if (shapeMode == CORNERS) { // c and d are x2/y2, make them into width/height c -= x; d -= y; // then same as above translate(x, y); scale(c / shape.getWidth(), d / shape.getHeight()); } shape.draw(this); popMatrix(); } }
v.background(102); v.lights(); v.pushMatrix(); v.camera(x+eyeoff, y, 300, px, py, 0, 0.0, 1.0, 0.0); v.noStroke();
/** * @param a x-coordinate of the shape * @param b y-coordinate of the shape * @param c width to display the shape * @param d height to display the shape */ public void shape(PShape shape, float a, float b, float c, float d) { if (shape.isVisible()) { // don't do expensive matrix ops if invisible flush(); pushMatrix(); if (shapeMode == CENTER) { // x and y are center, c and d refer to a diameter translate(a - c/2f, b - d/2f); scale(c / shape.getWidth(), d / shape.getHeight()); } else if (shapeMode == CORNER) { translate(a, b); scale(c / shape.getWidth(), d / shape.getHeight()); } else if (shapeMode == CORNERS) { // c and d are x2/y2, make them into width/height c -= a; d -= b; // then same as above translate(a, b); scale(c / shape.getWidth(), d / shape.getHeight()); } shape.draw(this); popMatrix(); } }