コード例 #1
0
        public void FillEllipse(Ellipse ellipse, int slices = 64)
        {
            float[]            offsets;
            EllipseColorShader shader = ChooseEllipseShader(Color, out offsets);

            Color4[]  colors = shader(ellipse, Color, (offsets.Length - 1) * (slices) + 1, slices);
            int[]     indices;
            Vector3[] vertices = EllipseMesh.CreateMesh(ellipse, offsets, slices, Transform, out indices);

            var vertexArray = new VertexPositionColor[vertices.Length];

            for (int i = 0; i < vertices.Length; i++)
            {
                vertexArray[i] = new VertexPositionColor()
                {
                    Position = vertices[i], Color = colors[i]
                }
            }
            ;

            shapes.Add(new ShapeMeshDescription()
            {
                Vertices = vertexArray, Indices = indices
            });
        }
コード例 #2
0
        public void DrawEllipse(Ellipse ellipse, float ringWidth, int slices = 64)
        {
            float innerRadiusRatio = 1 - (ringWidth / ellipse.RadiusX);

            float[] offsets;

            var solidColor = Color as SolidColor;

            if (solidColor != null)
            {
                Color = RadialGradient.New(Color.Name,
                                           new[]
                {
                    new GradientStop(SharpDX.Mathematics.Color.Transparent, 0),
                    new GradientStop(solidColor.Color, innerRadiusRatio), new GradientStop(solidColor.Color, 1)
                });
            }

            EllipseColorShader shader = ChooseEllipseOutlineShader(innerRadiusRatio, Color, out offsets);

            Color4[]  colors = shader(ellipse, Color, offsets.Length * slices, slices);
            int[]     indices;
            Vector3[] vertices = EllipseMesh.CreateRingMesh(ellipse, offsets, slices, Transform, out indices);

            var vertexArray = new VertexPositionColor[vertices.Length];

            for (int i = 0; i < vertices.Length; i++)
            {
                vertexArray[i] = new VertexPositionColor()
                {
                    Position = vertices[i], Color = colors[i]
                }
            }
            ;

            shapes.Add(new ShapeMeshDescription()
            {
                Vertices = vertexArray, Indices = indices
            });
        }