1 module skia.SKVertices;
2 
3 import skia.Definitions;
4 import skia.Exceptions;
5 import skia.MathTypes;
6 import skia.SkiaApi;
7 import skia.SKColor;
8 import skia.SKObject;
9 
10 
11 class SKVertices : SKObject, ISKNonVirtualReferenceCounted, ISKSkipObjectRegistration
12 {
13 	this (void* x, bool owns)
14 	{
15     super (x, owns);
16 	}
17 
18 	protected override void Dispose (bool disposing)
19   {
20     return 	super.Dispose (disposing);
21   }
22 	
23 
24 	void ReferenceNative ()
25   {
26     return SkiaApi.sk_vertices_ref (cast(sk_vertices_t*)Handle);
27   } 
28 
29 	void UnreferenceNative ()
30   {
31     return SkiaApi.sk_vertices_unref (cast(sk_vertices_t*)Handle);
32   } 
33 
34 	static SKVertices CreateCopy (SKVertexMode vmode, SKPoint[] positions, SKColor[] colors)
35 	{
36 		return CreateCopy (vmode, positions, null, colors, null);
37 	}
38 
39 	static SKVertices CreateCopy (SKVertexMode vmode, SKPoint[] positions, SKPoint[] texs, SKColor[] colors)
40 	{
41 		return CreateCopy (vmode, positions, texs, colors, null);
42 	}
43 
44 	static SKVertices CreateCopy (SKVertexMode vmode, SKPoint[] positions, SKPoint[] texs, SKColor[] colors, ushort[] indices)
45 	{
46 		if (positions is null)
47 			throw new ArgumentNullException (positions.stringof);
48 
49 		if (texs !is null && positions.length != texs.length)
50 			throw new ArgumentException ("The number of texture coordinates must match the number of vertices.", texs.stringof);
51 		if (colors !is null && positions.length != colors.length)
52 			throw new ArgumentException ("The number of colors must match the number of vertices.", colors.stringof);
53 
54 		auto vertexCount = positions.length;
55 		auto indexCount = indices.length ? indices.length : 0;
56 
57 		SKPoint* p = positions.ptr;
58 		SKPoint* t = texs.ptr;
59 		SKColor* c = colors.ptr;
60 		ushort* i = indices.ptr;
61 		return GetObject (SkiaApi.sk_vertices_make_copy (vmode, cast(int)vertexCount, p, t, cast(uint*)c, cast(int)indexCount, i));
62 	}
63 
64 	static SKVertices GetObject (void* handle)
65   {
66     return handle is null ? null : new SKVertices (handle, true);
67   }
68 
69 }