public void setStroke(int stroke) { if (openShape) { PGraphics.showWarning(INSIDE_BEGIN_END_ERROR, "setStroke()"); return; } strokeColor = stroke; if (vertices != null) { for (int i = 0; i < vertices.length; i++) { setStroke(i, stroke); } } }
Table data; PShape dataPlot; size(1620, 1080, P2D); //create a group to store the lines from each row dataPlot = createShape(GROUP); //load the data, specifying it has a header and it's tab separated data = loadTable("data.tsv", "header, tsv"); //traverse each row for (TableRow row : data.rows ()) { //extract each value int x1 = row.getInt("x1"); int y1 = row.getInt("y1"); int x2 = row.getInt("x2"); int y2 = row.getInt("y2"); //add the coordinates as lines to the group PShape line = createShape(LINE, x1, y1, x2, y2); float dist = dist(x1, y1, x2, y2); line.setStroke(color(map(dist, 0, height, 160, 0))); line.setStrokeWeight(map(dist, 0, height, 10.0, 1.0)); dataPlot.addChild(line); } //render the plot shape(dataPlot);
/** * ( begin auto-generated from PShape_setStroke.xml ) * * The <b>setStroke()</b> method defines the outline color of a <b>PShape</b>. * This method is used after shapes are created or when a shape is defined * explicitly (e.g. <b>createShape(RECT, 20, 20, 80, 80)</b>) as shown in * the above example. When a shape is created with <b>beginShape()</b> and * <b>endShape()</b>, its attributes may be changed with <b>fill()</b> and * <b>stroke()</b> within <b>beginShape()</b> and <b>endShape()</b>. * However, after the shape is created, only the <b>setStroke()</b> method * can define a new stroke value for the <b>PShape</b>. * * ( end auto-generated ) * * @webref * @param stroke * @brief Set the stroke value */ public void setStroke(int stroke) { if (openShape) { PGraphics.showWarning(INSIDE_BEGIN_END_ERROR, "setStroke()"); return; } strokeColor = stroke; if (vertices != null && perVertexStyles) { for (int i = 0; i < vertices.length; i++) { setStroke(i, stroke); } } }
/** * Detect faces using {@link HaarCascadeDetector}, return an {@link ArrayList} of * {@link PShape} instances. Note the {@link PShape} instances have no fill and * a colour: 255,0,0 * @return detected faces */ public ArrayList<PShape> faces(){ ArrayList<PShape> faces = new ArrayList<PShape>(); List<DetectedFace> detected = faceDetector.detectFaces(oiImage.flatten()); for (DetectedFace detectedFace : detected) { Rectangle bounds = detectedFace.getBounds(); PShape detectedPShape = this.parent.createShape(RECT,bounds.x,bounds.y,bounds.width,bounds.height); detectedPShape.setFill(false); detectedPShape.setStroke(this.parent.color(255f, 0, 0)); faces.add(detectedPShape); } return faces; } }