public void line(float x1, float y1, float z1, float x2, float y2, float z2) { g.line(x1, y1, z1, x2, y2, z2); }
public void line(float x1, float y1, float x2, float y2) { g.line(x1, y1, x2, y2); }
/** * ( begin auto-generated from line.xml ) * * Draws a line (a direct path between two points) to the screen. The * version of <b>line()</b> with four parameters draws the line in 2D. To * color a line, use the <b>stroke()</b> function. A line cannot be filled, * therefore the <b>fill()</b> function will not affect the color of a * line. 2D lines are drawn with a width of one pixel by default, but this * can be changed with the <b>strokeWeight()</b> function. The version with * six parameters allows the line to be placed anywhere within XYZ space. * Drawing this shape in 3D with the <b>z</b> parameter requires the P3D * parameter in combination with <b>size()</b> as shown in the above example. * * ( end auto-generated ) * @webref shape:2d_primitives * @param x1 x-coordinate of the first point * @param y1 y-coordinate of the first point * @param x2 x-coordinate of the second point * @param y2 y-coordinate of the second point * @see PGraphics#strokeWeight(float) * @see PGraphics#strokeJoin(int) * @see PGraphics#strokeCap(int) * @see PGraphics#beginShape() */ public void line(float x1, float y1, float x2, float y2) { if (recorder != null) recorder.line(x1, y1, x2, y2); g.line(x1, y1, x2, y2); }
graph.stroke(0); graph.strokeWeight(2); graph.line(i,vals[i],i+1,vals[i+1]);
PGraphics pg; PGraphics pdf; boolean usePdf = false; void setup() { size(100, 100); pg = createGraphics(width, height); pdf = //whatever } void draw(){ if(usePdf){ display(pdf); } else{ display(pg); image(pg, 0, 0); } } void display(PGraphics g) { g.beginDraw(); g.background(100); g.stroke(255); g.line(20, 20, mouseX, mouseY); g.endDraw(); }
public PShape createGridShape() { int gridSize = 20; stroke(128); fill(64); strokeWeight(1); println("width=" + width + " height=" + height); PGraphics buffer = createGraphics(width / 2, height, P2D); buffer.beginDraw(); for (int y = 0; y < height; y += gridSize) { buffer.line(0, y, width/2, y); } for (int x = 0; x < width; x += gridSize) { buffer.line(x, 0, x, height); } buffer.endDraw(); PShape face = createShape(); face.beginShape(QUAD); face.noStroke(); face.textureMode(NORMAL); face.texture(buffer); face.vertex(-1, -1, 0, 0, 0); face.vertex(1, -1, 0, 1, 0); face.vertex(1, 1, 0, 1, 1); face.vertex(-1, 1, 0, 0, 1); face.endShape(); return face; }
PShape createReticle() { final int RADIUS = 64; PGraphics buffer = createGraphics(RADIUS, RADIUS); buffer.beginDraw(); buffer.background(0, 0); // transparent buffer.stroke(255); buffer.strokeWeight(4); buffer.ellipseMode(CENTER); buffer.ellipse(RADIUS / 2, RADIUS / 2, RADIUS / 3, RADIUS / 3); buffer.strokeWeight(8.0f); buffer.line(RADIUS/2, 0, RADIUS/2, RADIUS - 1); buffer.line(0, RADIUS/2, RADIUS-1, RADIUS/2); buffer.endDraw(); PShape face = createShape(); face.beginShape(QUAD); face.noStroke(); face.textureMode(NORMAL); face.texture(buffer); face.vertex(-1, -1, 0, 0, 0); face.vertex(1, -1, 0, 1, 0); face.vertex(1, 1, 0, 1, 1); face.vertex(-1, 1, 0, 0, 1); face.endShape(); return face; }
pg.stroke(pg.color(0, 0, 0), 35); float my = PApplet.map(1 - median, 0, 1, y0, y0 + h0); pg.line(x, my, x + w, my);
PShape createTextGraphics(String s) { PGraphics buffer = createGraphics(width/2, height); buffer.beginDraw(); buffer.strokeWeight(8.0f); buffer.background(color(0,128,0)); buffer.stroke(0xff, 0, 0); buffer.text(s, 0, height / 4); buffer.stroke(255); buffer.textSize(64f); buffer.text(s, 0, height / 3); buffer.stroke(0x0000FF); buffer.textSize(128); buffer.text(s, 0, height / 2 + height / 4); buffer.fill(color(128, 0, 128)); buffer.rect(400, 200, 400, 400); buffer.stroke(128); buffer.line(0, 0, width / 2, height); buffer.endDraw(); PShape face = createShape(); face.beginShape(QUAD); face.noStroke(); face.textureMode(NORMAL); face.texture(buffer); face.vertex(-1, -1, 0, 0, 0); face.vertex(1, -1, 0, 1, 0); face.vertex(1, 1, 0, 1, 1); face.vertex(-1, 1, 0, 0, 1); face.endShape(); return face; }