示例#1
0
        public static void DrawPath(ICanvas2D dc, Matrix3x2 xform, string path, OutlineFillStyle style)
        {
            var shapes = ParseShapes(path);

            foreach (var shape in shapes)
            {
                var points = shape.AsSpan();

                if (points[0].Equals(points[points.Length - 1]))
                {
                    points = points.Slice(0, points.Length - 1);
                    dc.DrawPolygon(points, style);
                    continue;
                }

                if (style.HasFill)
                {
                    dc.DrawPolygon(points, style.FillColor);
                }
                if (style.HasOutline)
                {
                    dc.DrawLines(points, style.OutlineWidth, style.OutlineColor);
                }
            }
        }
示例#2
0
        void IScene3D.DrawSurface(ReadOnlySpan <Point3> vertices, SurfaceStyle brush)
        {
            Span <XYZ> clippedVertices = stackalloc XYZ[vertices.Length * 2];

            var cvertices = _FrustumNearPlane.ClipPolygonToPlane(clippedVertices, Point3.AsNumerics(vertices));

            if (cvertices < 3)
            {
                return;
            }

            clippedVertices = clippedVertices.Slice(0, cvertices);

            Span <Point2> points = stackalloc Point2[clippedVertices.Length];

            var center = XYZ.Zero;

            for (int i = 0; i < points.Length; ++i)
            {
                var v = clippedVertices[i];

                center   += v;
                points[i] = _ProjectPoint(v).SelectXY();
            }

            center /= points.Length;

            brush = brush.WithOutline(_ProjectRadius(center, brush.Style.OutlineWidth));

            _RenderTarget.DrawPolygon(points, brush.Style);
        }