private void AddShape(ShapeDetails shape, StringBuilder sb)
        {
            if (shape.ShapeOperation == ShapeOperation.None)
            {
                return;
            }
            ShapePoint lastEnd = null;

            sb.Append(@"
        <path d=""");
            foreach (var line in shape.Lines)
            {
                if (!line.Start.Equals(lastEnd))
                {
                    sb.Append("M");
                    AddPoint(line.Start, sb);
                }

                if (line.CurveControlPoint1 == null)
                {
                    sb.Append(" L");
                }
                else
                {
                    if (line.CurveControlPoint2 != null)
                    {
                        sb.Append(" C");
                        AddPoint(line.CurveControlPoint1, sb);
                        sb.Append(",");
                        AddPoint(line.CurveControlPoint2, sb);
                        sb.Append(",");
                    }
                    else
                    {
                        sb.Append(" Q");
                        AddPoint(line.CurveControlPoint1, sb);
                        sb.Append(",");
                    }
                }

                AddPoint(line.End, sb);
                lastEnd = line.End;
            }

            sb.Append("\" stroke-width=\"").Append(shape.LineWidth)
            .Append("\" fill=\"");
            AppendColor(shape.ShapeOperation == ShapeOperation.Stroke?null:shape.FillColor, sb);
            if (shape.EvenOddRule)
            {
                sb.Append("\" fill-rule=\"evenodd");
            }
            sb.Append("\" stroke=\"");
            AppendColor(shape.ShapeOperation == ShapeOperation.Fill?null:shape.StrokeColor, sb);
            sb.Append("\"/>");
        }
 private void AddPoint(ShapePoint p, StringBuilder sb)
 {
     sb.Append(" ").Append(Math.Round(p.X, 2)).Append(" ").Append(Math.Round(p.Y, 2));
 }
Exemplo n.º 3
0
 public bool Equals(ShapePoint other) =>
 other != null && Math.Abs(X - other.X) < 0.01 && Math.Abs(Y - other.Y) < 0.01;