public void EachShape(Action <Body, Shape> action) { ShapeIterator iterator = (body, shape, data) => { action(Body.FromIntPtr(body), Shape.FromIntPtr(shape)); }; cpBodyEachShape(Handle.Handle, iterator, IntPtr.Zero); }
/// <summary> Processes a <code>Shape</code> by converting its general path to a series of /// <code>ShapeRecord</code>s. The records are not terminated with an <code>EndShapeRecord</code> /// so that subsequent calls can be made to this method to concatenate more shape paths. /// <p/> /// For closed shapes (including character glyphs) there exists a high possibility of rounding /// errors caused by the conversion of double-precision pixel co-ordinates to integer twips /// (1 twip = 1/20th pixel at 72 dpi). As such, at each move command this error is checked and /// corrected. /// <p/> /// /// </summary> /// <param name="si">A ShapeIterator who's path will be converted to records and added to the collection /// </param> public void processShape(ShapeIterator si) { while (!si.Done) { double[] coords = new double[6]; short code = si.currentSegment(coords); switch (code) { case flash.swf.builder.types.ShapeIterator_Fields.MOVE_TO: correctRoundingErrors(); move(coords[0], coords[1]); closed = false; //reset closed flag after move break; case flash.swf.builder.types.ShapeIterator_Fields.LINE_TO: straight(coords[0], coords[1]); break; case flash.swf.builder.types.ShapeIterator_Fields.QUAD_TO: curved(coords[0], coords[1], coords[2], coords[3]); break; case flash.swf.builder.types.ShapeIterator_Fields.CUBIC_TO: approximateCubicBezier(new Point(pen.x, pen.y), new Point(coords[0], coords[1]), new Point(coords[2], coords[3]), new Point(coords[4], coords[5])); break; case flash.swf.builder.types.ShapeIterator_Fields.CLOSE: closed = true; close(); break; } si.next(); } correctRoundingErrors(); }
extern static void cpBodyEachShape(IntPtr body, ShapeIterator iterator, IntPtr data);
static extern void cpBodyEachShape(IntPtr body, ShapeIterator iterator, IntPtr data);