SkiaSharp.SKPaint.Clone C# (CSharp) Method

Clone() public method

public Clone ( ) : SKPaint
return SKPaint
		public SKPaint Clone()
		{
			return GetObject<SKPaint>(SkiaApi.sk_paint_clone(Handle));
		}
	}

Usage Example

Ejemplo n.º 1
0
        private void ReadTextSpans(XElement e, SKCanvas canvas, SKPoint location, SKPaint stroke, SKPaint fill)
        {
            var nodes = e.Nodes().ToArray();

            for (int i = 0; i < nodes.Length; i++)
            {
                var  c       = nodes[i];
                bool isFirst = i == 0;
                bool isLast  = i == nodes.Length - 1;

                if (c.NodeType == XmlNodeType.Text)
                {
                    // TODO: check for preserve whitespace

                    var textSegments = ((XText)c).Value.Split(new[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries);
                    var count        = textSegments.Length;
                    if (count > 0)
                    {
                        if (isFirst)
                        {
                            textSegments[0] = textSegments[0].TrimStart();
                        }
                        if (isLast)
                        {
                            textSegments[count - 1] = textSegments[count - 1].TrimEnd();
                        }
                        var text = WSRe.Replace(string.Concat(textSegments), " ");

                        canvas.DrawText(text, location.X, location.Y, fill);

                        location.X += fill.MeasureText(text);
                    }
                }
                else if (c.NodeType == XmlNodeType.Element)
                {
                    var ce = (XElement)c;
                    if (ce.Name.LocalName == "tspan")
                    {
                        var spanFill = fill.Clone();

                        // the current span may want to change the cursor position
                        location.X = ReadOptionalNumber(ce.Attribute("x")) ?? location.X;
                        location.Y = ReadOptionalNumber(ce.Attribute("y")) ?? location.Y;

                        ReadFontAttributes(ce, spanFill);

                        var text = ce.Value.Trim();

                        canvas.DrawText(text, location.X, location.Y, spanFill);

                        location.X += spanFill.MeasureText(text);
                    }
                }
            }
        }
All Usage Examples Of SkiaSharp.SKPaint::Clone