Exemplo n.º 1
0
        public PathShape ToFillPathShape(IToolContext context, IBaseShape shape)
        {
            using (var geometry = ToPath(context, shape))
            {
                if (geometry != null)
                {
                    var style = context.DocumentContainer?.StyleLibrary?.Get(shape.StyleId);
                    if (style == null)
                    {
                        style = context.DocumentContainer?.StyleLibrary?.CurrentItem;
                    }

                    using (var disposable = new CompositeDisposable())
                    {
                        var path = SkiaUtil.ToFillPath(context, style.FillPaint, shape.Effects, geometry, disposable.Disposables);
                        if (path != null)
                        {
                            disposable.Disposables.Add(path);
                            var union = SkiaUtil.Op(SKPathOp.Union, new[] { path, path });
                            if (union != null && !union.IsEmpty)
                            {
                                disposable.Disposables.Add(union);
                                return(SkiaUtil.ToPathShape(context, union, context.DocumentContainer?.StyleLibrary?.CurrentItem, context?.DocumentContainer?.PointTemplate));
                            }
                        }
                    }
                }
            }
            return(null);
        }
Exemplo n.º 2
0
        public PathShape Op(IToolContext context, PathOp op, ICollection <IBaseShape> selected)
        {
            var path   = default(PathShape);
            var shapes = GetShapes(selected);

            if (shapes != null && shapes.Count > 0)
            {
                var paths = ToPaths(context, shapes);
                if (paths != null && paths.Count > 0)
                {
                    var result = SkiaUtil.Op(SkiaUtil.ToSKPathOp(op), paths);
                    if (result != null)
                    {
                        if (!result.IsEmpty)
                        {
                            var style = context.DocumentContainer?.StyleLibrary?.Get(shapes[0].StyleId);
                            if (style == null)
                            {
                                style = context.DocumentContainer?.StyleLibrary?.CurrentItem;
                            }
                            path = SkiaUtil.ToPathShape(context, result, style, context?.DocumentContainer?.PointTemplate);
                        }
                        result.Dispose();
                    }

                    for (int i = 0; i < paths.Count; i++)
                    {
                        paths[i].Dispose();
                    }
                }
            }
            return(path);
        }
Exemplo n.º 3
0
 public PathShape ToPathShape(IToolContext context, string svgPathData)
 {
     if (!string.IsNullOrWhiteSpace(svgPathData))
     {
         using var path = SkiaUtil.ToPath(svgPathData);
         return(SkiaUtil.ToPathShape(context, path, context.DocumentContainer?.StyleLibrary?.CurrentItem, context?.DocumentContainer?.PointTemplate));
     }
     return(null);
 }
Exemplo n.º 4
0
 public PathShape ToPathShape(IToolContext context, IBaseShape shape)
 {
     using (var geometry = ToPath(context, shape))
     {
         if (geometry != null)
         {
             var style = context.DocumentContainer?.StyleLibrary?.Get(shape.StyleId);
             if (style == null)
             {
                 style = context.DocumentContainer?.StyleLibrary?.CurrentItem;
             }
             return(SkiaUtil.ToPathShape(context, geometry, style, context?.DocumentContainer?.PointTemplate));
         }
     }
     return(null);
 }