// * // * Applies a "thickness" to a shape, ie a bit like the extruder, but in 2D // * <table border="0" width="100%"><tr><td>\image html shape_thick1.png "Start shape (before thicken)"</td><td>\image html shape_thick2.png "Result (after thicken)"</td></tr></table> // //----------------------------------------------------------------------- public MultiShape thicken(float amount) { if (!mClosed) { Shape s = new Shape(); s.setOutSide(mOutSide); for (int i = 0; i < mPoints.Count; i++) s.addPoint(mPoints[i] + amount * getAvgNormal((uint)i)); for (int i = mPoints.Count - 1; i >= 0; i--) s.addPoint(mPoints[i] - amount * getAvgNormal((uint)i)); s.close(); return new MultiShape().addShape(s); } else { MultiShape ms = new MultiShape(); Shape s1 = new Shape(); for (int i = 0; i < mPoints.Count; i++) s1.addPoint(mPoints[i] + amount * getAvgNormal((uint)i)); s1.close(); s1.setOutSide(mOutSide); ms.addShape(s1); Shape s2 = new Shape(); for (int i = 0; i < mPoints.Count; i++) s2.addPoint(mPoints[i] - amount * getAvgNormal((uint)i)); s2.close(); s2.setOutSide(mOutSide == Side.SIDE_LEFT ? Side.SIDE_RIGHT : Side.SIDE_LEFT); ms.addShape(s2); return ms; } }
/// Extracts a part of the shape as a new shape /// @param first first index to be in the new shape /// @param last last index to be in the new shape public Shape extractSubShape(uint first, uint last) { Shape s = new Shape(); for (int i = (int)first; i <= last; i++) s.addPoint(mPoints[i]); s.setOutSide(mOutSide); if (mClosed) s.close(); return s; }