while(!i.isDone()) { switch(i.currentSegment(coord)) { case FlatteningPathIterator.SEG_MOVETO:
public static Polygon getPolygonOutline(BufferedImage image) { Area a = getOutline(image, new Color(0, 0, 0, 0), false, 10); // 10 or whatever color tolerance you want Polygon p = new Polygon(); FlatteningPathIterator fpi = new FlatteningPathIterator(a.getPathIterator(null), 0.1); // 0.1 or how sloppy you want it double[] pts = new double[6]; while (!fpi.isDone()) { switch (fpi.currentSegment(pts)) { case FlatteningPathIterator.SEG_MOVETO: case FlatteningPathIterator.SEG_LINETO: p.addPoint((int) pts[0], (int) pts[1]); break; } fpi.next(); } return p; }
float last_x = floats[0]; float last_y = floats[1]; while (! fpi.isDone())
points=new ArrayList<Point>(); float[] coords=new float[6]; while (!iter.isDone()) { iter.currentSegment(coords); int x=(int)coords[0];
FlatteningPathIterator fpi = new FlatteningPathIterator(sspi, 0.01f); while (!fpi.isDone()) { segType = fpi.currentSegment(seg); if (segType == PathIterator.SEG_LINETO) {
FlatteningPathIterator fpi = new FlatteningPathIterator(sspi, 0.01f); while (!fpi.isDone()) { segType = fpi.currentSegment(seg); if (segType == PathIterator.SEG_LINETO) {
FlatteningPathIterator fpi = new FlatteningPathIterator(sspi, 0.01f); while (!fpi.isDone()) { segType = fpi.currentSegment(seg); if (segType == PathIterator.SEG_LINETO) {
float[] oldPts = null; Collection curveSegments = new Vector(); while ( !f.isDone() ) { float[] pts = new float[6]; int segType = f.currentSegment(pts);
public void drawCircle(int x, int y, int w, int h) { int index = preview.getCurrentSlice(); Ellipse2D e = new Ellipse2D.Float(x, y, w, h); float[] v = new float[6]; boolean finished = false; ImageProcessor ip = stack.getProcessor(index); for(int z = 0; !finished; z++) { ip = ip.convertToRGB(); ip.setValue(color); ip.setLineWidth(linewidth); FlatteningPathIterator it = new FlatteningPathIterator( e.getPathIterator(null), 1); it.currentSegment(v); ip.moveTo((int)v[0], (int)v[1]); it.next(); for(int i = 0; i < z; i++) { it.currentSegment(v); ip.lineTo((int)v[0], (int)v[1]); it.next(); finished = it.isDone(); } if(!stack.addSlice(index + z, ip)) break; } }