public static SKVertices CreateCopy(SKVertexMode vmode, SKPoint[] positions, SKPoint[] texs, SKColor[] colors, UInt16[] indices)
        {
            if (positions == null)
            {
                throw new ArgumentNullException(nameof(positions));
            }

            if (texs != null && positions.Length != texs.Length)
            {
                throw new ArgumentException("The number of texture coordinates must match the number of vertices.", nameof(texs));
            }
            if (colors != null && positions.Length != colors.Length)
            {
                throw new ArgumentException("The number of colors must match the number of vertices.", nameof(colors));
            }

            var vertexCount = positions.Length;
            var indexCount  = indices?.Length ?? 0;

            fixed(SKPoint *p = positions)
            fixed(SKPoint * t = texs)
            fixed(SKColor * c = colors)
            fixed(UInt16 * i  = indices)
            {
                return(GetObject(SkiaApi.sk_vertices_make_copy(vmode, vertexCount, p, t, (uint *)c, indexCount, i)));
            }
        }
        private void DrawOrFillMesh([NotNull] IPaintProvider provider, [NotNull] Triangle[] mesh)
        {
            using (var paint = provider.Paint.Clone()) {
                const SKVertexMode geometryMode = SKVertexMode.Triangles;

                var vertices = new SKPoint[mesh.Length * 3];

                for (var i = 0; i < mesh.Length; ++i)
                {
                    var j = i * 3;

                    vertices[j]     = mesh[i].Point1.ToSKPoint();
                    vertices[j + 1] = mesh[i].Point2.ToSKPoint();
                    vertices[j + 2] = mesh[i].Point3.ToSKPoint();
                }

                var colors = new SKColor[vertices.Length];

                for (var i = 0; i < colors.Length; ++i)
                {
                    colors[i] = SKColors.White;
                }

                _canvas?.DrawVertices(geometryMode, vertices, colors, paint);
            }

            SetDirty();
        }
Exemple #3
0
        public void DrawVertices(SKVertexMode vmode, SKPoint[] vertices, SKPoint[] texs, SKColor[] colors, SKBlendMode mode, UInt16[] indices, SKPaint paint)
        {
            if (vertices == null)
            {
                throw new ArgumentNullException(nameof(vertices));
            }
            if (paint == null)
            {
                throw new ArgumentNullException(nameof(paint));
            }

            if (texs != null && vertices.Length != texs.Length)
                throw new ArgumentException("The number of texture coordinates must match the number of vertices.", nameof(texs)); }
Exemple #4
0
        public void DrawVertices(SKVertexMode vmode, SKPoint[] vertices, SKPoint[] texs, SKColor[] colors, SKBlendMode mode, UInt16[] indices, SKPaint paint)
        {
            var vert = SKVertices.CreateCopy(vmode, vertices, texs, colors, indices);

            DrawVertices(vert, mode, paint);
        }
Exemple #5
0
        public void DrawVertices(SKVertexMode vmode, SKPoint[] vertices, SKPoint[] texs, SKColor[] colors, SKPaint paint)
        {
            var vert = SKVertices.CreateCopy(vmode, vertices, texs, colors);

            DrawVertices(vert, SKBlendMode.Modulate, paint);
        }
 public static SKVertices CreateCopy(SKVertexMode vmode, SKPoint[] positions, SKPoint[] texs, SKColor[] colors)
 {
     return(CreateCopy(vmode, positions, texs, colors, null));
 }
Exemple #7
0
 public void DrawVertices(SKVertexMode vmode, SKPoint[] vertices, SKPoint[] texs, SKColor[] colors, UInt16[] indices, SKPaint paint)
 {
     DrawVertices(vmode, vertices, texs, colors, SKBlendMode.Modulate, indices, paint);
 }
Exemple #8
0
 public void DrawVertices(SKVertexMode vmode, SKPoint[] vertices, SKPoint[] texs, SKColor[] colors, SKPaint paint)
 {
     DrawVertices(vmode, vertices, texs, colors, null, paint);
 }