1 /*
2 DSFML - The Simple and Fast Multimedia Library for D
3 
4 Copyright (c) <2013 - 2015> <Jeremy DeHaan>
5 
6 This software is provided 'as-is', without any express or implied warranty.
7 In no event will the authors be held liable for any damages arising from the use of this software.
8 
9 Permission is granted to anyone to use this software for any purpose, including commercial applications,
10 and to alter it and redistribute it freely, subject to the following restrictions:
11 
12 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software.
13 If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
14 
15 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
16 
17 3. This notice may not be removed or altered from any source distribution
18 */
19 
20 module dsfml.graphics.vertex;
21 
22 import dsfml.graphics.color;
23 import dsfml.system.vector2;
24 
25 /++
26  + Define a point with color and texture coordinates.
27  + 
28  + A vertex is an improved point.
29  + 
30  + It has a position and other extra attributes that will be used for drawing: in SFML, vertices also have a color and a pair of texture coordinates.
31  + 
32  + The vertex is the building block of drawing. Everything which is visible on screen is made of vertices. They are grouped as 2D primitives (triangles, quads, ...), and these primitives are grouped to create even more complex 2D entities such as sprites, texts, etc.
33  + 
34  + If you use the graphical entities of SFML (sprite, text, shape) you won't have to deal with vertices directly. But if you want to define your own 2D entities, such as tiled maps or particle systems, using vertices will allow you to get maximum performances.
35  + 
36  + Authors: Laurent Gomila, Jeremy DeHaan
37  + See_Also: http://www.sfml-dev.org/documentation/2.0/classsf_1_1Vertex.php#details
38  +/
39 struct Vertex
40 {
41 	/// 2D position of the vertex
42 	Vector2f position = Vector2f(0,0);
43 	/// Color of the vertex. Default is White.
44 	Color color = Color.White;
45 	/// 2D coordinates of the texture's pixel map to the vertex.
46 	Vector2f texCoords = Vector2f(0,0);
47 	
48 	
49 	this(Vector2f thePosition)
50 	{
51 		position = thePosition;
52 	}
53 	this(Vector2f thePosition, Color theColor)
54 	{
55 		position = thePosition;
56 		color = theColor;
57 	}
58 	this(Vector2f thePosition, Vector2f theTexCoords)
59 	{
60 		position = thePosition;
61 		texCoords = theTexCoords;
62 	}
63 	
64 	this(Vector2f thePosition, Color theColor, Vector2f theTexCoords)
65 	{
66 		position = thePosition;
67 		color = theColor;
68 		texCoords = theTexCoords;
69 	}
70 	
71 	
72 }
73 
74 unittest
75 {
76 	version(DSFML_Unittest_Graphics)
77 	{
78 		//not really needed, but implemented for code coverage later.
79 		import std.stdio;
80 		
81 		writeln("Unit test for Vertex");
82 
83 
84 		auto vertex = Vertex();
85 
86 		vertex.position = Vector2f(1,1);
87 
88 		vertex.color = Color.Blue;
89 
90 		vertex.texCoords = Vector2f(20,10);
91 
92 		writeln();
93 	}
94 }