Java Code Examples for processing.core.PGraphics#textAlign()
The following examples show how to use
processing.core.PGraphics#textAlign() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MoireProposal.java From haxademic with MIT License | 5 votes |
public void drawNumberToTexture(String str, PGraphics tex) { tex.beginDraw(); tex.fill(0); tex.textFont(font); tex.textAlign(P.CENTER, P.TOP); tex.text(str, 0, p.height * 0.2f, p.width, p.height * 0.8f); tex.endDraw(); }
Example 2
Source File: SlideCaption.java From haxademic with MIT License | 5 votes |
public void update(PGraphics pg) { showProgress.update(); if(captionQueued != null && showProgress.value() == 0) { caption = captionQueued; captionQueued = null; showProgress.setTarget(1); } if(caption != null) { PG.setDrawCorner(pg); pg.noStroke(); // get eased y float easedProgress = Penner.easeInOutCubic(showProgress.value()); float curY = pg.height - height * easedProgress; pg.pushMatrix(); // draw bg pg.fill(0, 127); pg.rect(0, curY, pg.width, height); // curY // draw text // buffer.textLeading(font.getSize() * 0.75f); pg.fill(255); pg.textAlign(P.CENTER, P.CENTER); pg.textFont(font); pg.text(caption, textOffsetY * 5f, curY - textOffsetY, pg.width - 50, height); pg.popMatrix(); PG.setDrawCenter(pg); } }
Example 3
Source File: SlideTitle.java From haxademic with MIT License | 5 votes |
public void update(PGraphics pg) { showProgress.update(); if(titleQueued != null && showProgress.value() == 0) { title = titleQueued; titleQueued = null; showProgress.setTarget(1); } if(title != null) { PG.setDrawCorner(pg); pg.noStroke(); // get eased y float easedProgress = Penner.easeInOutCubic(showProgress.value()); pg.pushMatrix(); // draw bg pg.fill(0, opacity * easedProgress); pg.rect(0, 0, pg.width, pg.height); // draw text // buffer.textLeading(font.getSize() * 0.75f); pg.fill(255, 255 * easedProgress); pg.textAlign(P.CENTER, P.CENTER); pg.textFont(font); pg.text(title, 0, 0, pg.width, pg.height); pg.popMatrix(); PG.setDrawCenter(pg); } }
Example 4
Source File: FontCacher.java From haxademic with MIT License | 5 votes |
public static void setFontOnContext(PGraphics pg, PFont font, int color, float leadingMult, int alignX, int alignY) { pg.fill(color); pg.textFont(font); pg.textSize(font.getSize()); pg.textLeading(font.getSize() * leadingMult); pg.textAlign(alignX, alignY); }
Example 5
Source File: BezierSurface.java From sketch-mapper with MIT License | 4 votes |
/** * Renders the grid in the surface. (useful in calibration mode) * * @param g */ private void renderGrid(PGraphics g) { g.beginDraw(); g.fill(ccolor); g.noStroke(); for (int i = 0; i < GRID_RESOLUTION; i++) { for (int j = 0; j < GRID_RESOLUTION; j++) { g.beginShape(); g.vertex(vertexPoints[i][j].x, vertexPoints[i][j].y); g.vertex(vertexPoints[i + 1][j].x, vertexPoints[i + 1][j].y); g.vertex(vertexPoints[i + 1][j + 1].x, vertexPoints[i + 1][j + 1].y); g.vertex(vertexPoints[i][j + 1].x, vertexPoints[i][j + 1].y); g.endShape(); } } g.textFont(sm.getIdFont()); g.fill(255); g.textAlign(PApplet.CENTER, PApplet.CENTER); g.textSize(20); g.text("" + this.getSurfaceName(), (float) (this.getCenter().x), (float) this.getCenter().y); if (isLocked) { g.textSize(12); g.text("Surface locked", (float) this.getCenter().x, (float) this.getCenter().y + 26); } if (sketch != null) { g.textSize(10); g.text(sketch.getName(), (float) this.getCenter().x, (float) this.getCenter().y + 40); } g.noFill(); g.stroke(BezierSurface.GRID_LINE_COLOR); g.strokeWeight(2); if (isSelected) g.stroke(BezierSurface.GRID_LINE_SELECTED_COLOR); if (!isLocked) { for (int i = 0; i <= GRID_RESOLUTION; i++) { for (int j = 0; j <= GRID_RESOLUTION; j++) { g.point(vertexPoints[i][j].x, vertexPoints[i][j].y, vertexPoints[i][j].z); } } } if (isSelected) { g.strokeWeight(4); g.stroke(BezierSurface.GRID_LINE_SELECTED_COLOR); //draw the outline here for (int i = 0; i < poly.npoints - 1; i++) { g.line(poly.xpoints[i], poly.ypoints[i], poly.xpoints[i + 1], poly.ypoints[i + 1]); if (i == poly.npoints - 2) g.line(poly.xpoints[i + 1], poly.ypoints[i + 1], poly.xpoints[0], poly.ypoints[0]); } } g.strokeWeight(1); g.stroke(SELECTED_OUTLINE_INNER_COLOR); //draw the outline here for (int i = 0; i < poly.npoints - 1; i++) { g.line(poly.xpoints[i], poly.ypoints[i], poly.xpoints[i + 1], poly.ypoints[i + 1]); if (i == poly.npoints - 2) g.line(poly.xpoints[i + 1], poly.ypoints[i + 1], poly.xpoints[0], poly.ypoints[0]); } if (!isLocked) { // Draw the control points. for (int i = 0; i < this.cornerPoints.length; i++) { this.renderCornerPoint(g, this.cornerPoints[i].x, this.cornerPoints[i].y, (this.activePoint == i), i); } for (int i = 0; i < this.bezierPoints.length; i++) { this.renderBezierPoint(g, this.bezierPoints[i].x, this.bezierPoints[i].y, (this.selectedBezierControl == i), i); g.strokeWeight(1); g.stroke(255); g.line(this.bezierPoints[i].x, this.bezierPoints[i].y, this.cornerPoints[(int) (i / 2)].x, this.cornerPoints[(int) (i / 2)].y); } } g.endDraw(); }