Search in sources :

Example 1 with PathIterator

use of com.codename1.ui.geom.PathIterator in project CodenameOne by codenameone.

the class IOSImplementation method renderShape.

private NativePathRenderer renderShape(Shape shape, Stroke stroke) {
    if (stroke != null) {
        float lineWidth = stroke.getLineWidth();
        int capStyle = stroke.getCapStyle();
        int miterStyle = stroke.getJoinStyle();
        float miterLimit = stroke.getMiterLimit();
        PathIterator path = shape.getPathIterator();
        Rectangle rb = shape.getBounds();
        // Notice that these will be cleaned up in the dealloc method of the DrawPath objective-c class
        int padding = (int) Math.ceil(lineWidth);
        int padding2 = padding * 2;
        NativePathRenderer renderer = new NativePathRenderer(rb.getX() - padding, rb.getY() - padding, rb.getWidth() + padding2, rb.getHeight() + padding2, path.getWindingRule());
        NativePathStroker stroker = new NativePathStroker(renderer, lineWidth, capStyle, miterStyle, miterLimit);
        NativePathConsumer c = stroker.consumer;
        fillPathConsumer(path, c);
        // We don't need the stroker anymore because it has passed the strokes to the renderer.
        stroker.destroy();
        return renderer;
    } else {
        Rectangle rb = shape.getBounds();
        PathIterator path = shape.getPathIterator();
        // Notice that this will be cleaned up in the dealloc method of the DrawPath objective-c class.
        NativePathRenderer renderer = new NativePathRenderer(rb.getX(), rb.getY(), rb.getWidth(), rb.getHeight(), path.getWindingRule());
        NativePathConsumer c = renderer.consumer;
        fillPathConsumer(path, c);
        return renderer;
    }
}
Also used : PathIterator(com.codename1.ui.geom.PathIterator) Rectangle(com.codename1.ui.geom.Rectangle)

Aggregations

PathIterator (com.codename1.ui.geom.PathIterator)1 Rectangle (com.codename1.ui.geom.Rectangle)1