Пример #1
0
        public bool Op(SKPath other, SKPathOp op, SKPath result)
        {
            if (other == null)
            {
                throw new ArgumentNullException(nameof(other));
            }
            if (result == null)
            {
                throw new ArgumentNullException(nameof(result));
            }

            return(SkiaApi.sk_pathop_op(Handle, other.Handle, op, result.Handle));
        }
Пример #2
0
        public SKPath Op(SKPath other, SKPathOp op)
        {
            var result = new SKPath();

            if (Op(other, op, result))
            {
                return(result);
            }
            else
            {
                result.Dispose();
                return(null);
            }
        }
Пример #3
0
        private void OpFirstPathWithRest(SKPathOp op)
        {
            _remainderPath.Reset();
            _firstPath.Reset();

            for (var i = _pathContents.Count - 1; i >= 1; i--)
            {
                var content = _pathContents[i];

                if (content is ContentGroup contentGroup)
                {
                    var pathList = contentGroup.PathList;
                    for (var j = pathList.Count - 1; j >= 0; j--)
                    {
                        var path = pathList[j].Path;
                        path.Transform(contentGroup.TransformationMatrix.ToSKMatrix());
                        _remainderPath.AddPath(path);
                    }
                }
                else
                {
                    _remainderPath.AddPath(content.Path);
                }
            }

            var lastContent = _pathContents[0];

            if (lastContent is ContentGroup group)
            {
                var pathList = group.PathList;
                for (var j = 0; j < pathList.Count; j++)
                {
                    var path = pathList[j].Path;
                    path.Transform(group.TransformationMatrix.ToSKMatrix());
                    _firstPath.AddPath(path);
                }
            }
            else
            {
                _firstPath = lastContent.Path;
            }

            _firstPath.Op(_remainderPath, op, _firstPath);
        }
Пример #4
0
        internal static SKPath Op(SKPathOp op, IList <SKPath> paths)
        {
            if (paths == null || paths.Count <= 0)
            {
                return(null);
            }

            if (paths.Count == 1)
            {
                using (var empty = new SKPath()
                {
                    FillType = paths[0].FillType
                })
                {
                    return(empty.Op(paths[0], op));
                }
            }
            else
            {
                var haveResult = false;
                var result     = new SKPath(paths[0])
                {
                    FillType = paths[0].FillType
                };

                for (int i = 1; i < paths.Count; i++)
                {
                    var next = result.Op(paths[i], op);
                    if (next != null)
                    {
                        result.Dispose();
                        result     = next;
                        haveResult = true;
                    }
                }

                return(haveResult ? result : null);
            }
        }
Пример #5
0
 public void Add(SKPath path, SKPathOp op)
 {
     SkiaApi.sk_opbuilder_add(Handle, path.Handle, op);
 }
Пример #6
0
 /*
  * Set this path to the result of applying the Op to the two specified paths. The resulting path will be constructed from non-overlapping contours. The curve order is reduced where possible so that cubics may be turned into quadratics, and quadratics maybe turned into lines.
  * Path1: The first operand (for difference, the minuend)
  * Path2: The second operand (for difference, the subtrahend)
  */
 public void Op(Path path1, Path path2, SKPathOp op)
 {
     Contours.Add(new OpContour(path1, path2, op));
 }
Пример #7
0
 public OpContour(Path path1, Path path2, SKPathOp opType)
 {
     this.path1 = path1;
     this.path2 = path2;
     OpType     = opType;
 }
Пример #8
0
		public extern static void sk_opbuilder_add(sk_opbuilder_t builder, sk_path_t path, SKPathOp op);
Пример #9
0
		public extern static bool sk_pathop_op(sk_path_t one, sk_path_t two, SKPathOp op, sk_path_t result);
Пример #10
0
			public void Add (SKPath path, SKPathOp op)
			{
				SkiaApi.sk_opbuilder_add (Handle, path.Handle, op);
			}
Пример #11
0
		public SKPath Op (SKPath other, SKPathOp op)
		{
			var result = new SKPath ();
			if (Op (other, op, result)) {
				return result;
			} else {
				result.Dispose ();
				return null;
			}
		}
Пример #12
0
		public bool Op (SKPath other, SKPathOp op, SKPath result)
		{
			if (other == null)
				throw new ArgumentNullException (nameof (other));
			if (result == null)
				throw new ArgumentNullException (nameof (result));

			return SkiaApi.sk_pathop_op (Handle, other.Handle, op, result.Handle);
		}