/** * Replace the current transformation matrix with the top of the stack. */ public void popMatrix() { g.popMatrix(); }
/** * ( begin auto-generated from popMatrix.xml ) * * Pops the current transformation matrix off the matrix stack. * Understanding pushing and popping 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#pushMatrix() */ public void popMatrix() { if (recorder != null) recorder.popMatrix(); g.popMatrix(); }
private void endHUD() { sketch.g.hint(PConstants.ENABLE_DEPTH_TEST); sketch.g.popMatrix(); } }
protected void post(PGraphics g) { // for (int i = 0; i < childCount; i++) { // children[i].draw(g); // } /* // TODO this is not sufficient, since not saving fillR et al. g.stroke = strokeSaved; g.strokeColor = strokeColorSaved; g.strokeWeight = strokeWeightSaved; g.strokeCap = strokeCapSaved; g.strokeJoin = strokeJoinSaved; g.fill = fillSaved; g.fillColor = fillColorSaved; g.ellipseMode = ellipseModeSaved; */ if (matrix != null) { g.popMatrix(); } if (style) { g.popStyle(); } }
protected void post(PGraphics g) { // for (int i = 0; i < childCount; i++) { // children[i].draw(g); // } /* // TODO this is not sufficient, since not saving fillR et al. g.stroke = strokeSaved; g.strokeColor = strokeColorSaved; g.strokeWeight = strokeWeightSaved; g.strokeCap = strokeCapSaved; g.strokeJoin = strokeJoinSaved; g.fill = fillSaved; g.fillColor = fillColorSaved; g.ellipseMode = ellipseModeSaved; */ if (matrix != null) { g.popMatrix(); } if (style) { g.popStyle(); } }
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(); }
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(); }
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(); }
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(); } } }
/** * 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, 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.popMatrix(); v.endDraw();
/** * @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(); } }
canvas.sphere(60); canvas.popMatrix(); canvas.endDraw();