using SFML.Graphics;
using SFML.System;
using SFML.Window;
using System;
namespace Otter {
///
/// Class that represents a Vertex. Just a wrapper for an SFML Vertex.
///
public class Vert {
#region Private Fields
Vertex vertex;
#endregion
#region Public Properties
///
/// The Color of the Vert.
///
public Color Color {
get { return new Color(vertex.Color); }
set { vertex.Color = value.SFMLColor; }
}
///
/// The X position.
///
public float X {
get { return vertex.Position.X; }
set { vertex.Position = new Vector2f(value, vertex.Position.Y); }
}
///
/// The Y position.
///
public float Y {
get { return vertex.Position.Y; }
set { vertex.Position = new Vector2f(vertex.Position.X, value); }
}
///
/// The X, Y position as a Vector2.
///
public Vector2 Position {
get { return new Vector2(vertex.Position.X, vertex.Position.Y); }
set { vertex.Position = new Vector2f((float)value.X, (float)value.Y); }
}
///
/// The X, Y position of the Texture as a Vector2.
///
public Vector2 TexCoords {
get { return new Vector2(vertex.TexCoords.X, vertex.TexCoords.Y); }
set { vertex.TexCoords = new Vector2f((float)value.X, (float)value.Y); }
}
///
/// The X position of the Texture.
///
public float U {
get { return vertex.TexCoords.X; }
set { vertex.TexCoords = new Vector2f(value, vertex.TexCoords.Y); }
}
///
/// The Y position of the Texture.
///
public float V {
get { return vertex.TexCoords.Y; }
set { vertex.TexCoords = new Vector2f(vertex.TexCoords.X, value); }
}
#endregion
#region Public Methods
public override string ToString() {
return String.Format("X: {0} Y: {1} Color: {2} U: {3} V: {4}", X, Y, Color, U, V);
}
#endregion
#region Constructors
///
/// Create a new Vert.
///
/// The X position.
/// The Y position.
/// The Color.
/// The X position on the Texture.
/// The Y position on the Texture.
public Vert(float x, float y, Color color, float u, float v) {
vertex = new SFML.Graphics.Vertex(new Vector2f(x, y), color.SFMLColor, new Vector2f(u, v));
}
///
/// Create a new Vert.
///
/// A source Vert to copy.
public Vert(Vert copy) : this(copy.X, copy.Y, copy.Color, copy.U, copy.V) { }
///
/// Create a new white Vert at 0, 0.
///
public Vert() : this(0, 0, Color.White, 0, 0) { }
///
/// Create a new Vert.
///
/// The X position.
/// The Y position.
public Vert(float x, float y) : this(x, y, Color.White, 0, 0) { }
///
/// Create a new Vert.
///
/// The X position.
/// The Y position.
/// The X position on the Texture.
/// The Y position on the Texture.
public Vert(float x, float y, float u, float v) : this(x, y, Color.White, u, v) { }
///
/// Create a new Vert.
///
/// The X position.
/// The Y position.
/// The Color.
public Vert(float x, float y, Color color) : this(x, y, color, 0, 0) { }
#endregion
#region Internal
internal Vertex SFMLVertex {
get { return vertex; }
}
#endregion
}
}