/** * @param v1 red or hue value (depending on current color mode) * @param v2 green or saturation value (depending on current color mode) * @param v3 blue or brightness value (depending on current color mode) * @webref color:setting */ public void stroke(float v1, float v2, float v3) { if (recorder != null) recorder.stroke(v1, v2, v3); g.stroke(v1, v2, v3); }
protected void drawCross(PGraphics pg) { float x0 = 0.4f * pg.width; float y0 = 0.4f * pg.height; float x1 = 0.6f * pg.width; float y1 = 0.6f * pg.height; pg.stroke(160, 30); pg.strokeWeight(pg.width * 0.05f); pg.line(x0, y0, x1, y1); pg.line(x1, y0, x0, y1); }
protected void styles(PGraphics g) { // should not be necessary because using only the int version of color //parent.colorMode(PConstants.RGB, 255); if (stroke) { g.stroke(strokeColor); g.strokeWeight(strokeWeight); g.strokeCap(strokeCap); g.strokeJoin(strokeJoin); } else { g.noStroke(); } if (fill) { //System.out.println("filling " + PApplet.hex(fillColor)); g.fill(fillColor); } else { g.noFill(); } }
protected void styles(PGraphics g) { // should not be necessary because using only the int version of color //parent.colorMode(PConstants.RGB, 255); if (stroke) { g.stroke(strokeColor); g.strokeWeight(strokeWeight); g.strokeCap(strokeCap); g.strokeJoin(strokeJoin); } else { g.noStroke(); } if (fill) { //System.out.println("filling " + PApplet.hex(fillColor)); g.fill(fillColor); } else { g.noFill(); } }
pg.translate (width/2+100, height/2); pg.rotate (PI/6); pg.stroke(255); pg.noFill(); pg.strokeWeight(0.5);
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; }
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; }
/** * Set the tint to either a grayscale or ARGB value. * See notes attached to the fill() function. */ public void stroke(int rgb) { g.stroke(rgb); }
public void stroke(float x, float y, float z) { g.stroke(x, y, z); }
public void stroke(int rgb, float alpha) { g.stroke(rgb, alpha); }
public void stroke(float gray) { g.stroke(gray); }
public void stroke(float gray, float alpha) { g.stroke(gray, alpha); }
public void stroke(float x, float y, float z, float a) { g.stroke(x, y, z, a); }
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(); }
PGraphics p; void setup(){ size(400,400,P3D); p = createGraphics(400,400,P3D); smooth(); stroke(180,90,210); } void draw(){ background(180,90,210); p.beginDraw(); p.background(220, 180, 40,0); p.noFill(); p.stroke(220, 180, 40); p.translate(width/2 - (width/2 - mouseX), height/2, 400-mouseY*5); p.sphere(100); p.endDraw(); pushMatrix(); translate(width/2, height/2, -200); rotateY(radians(frameCount)); rotateX(radians(frameCount/2)); box(100); popMatrix(); image(p,0,0); }