protected override void UpdateDrawable() { base.UpdateDrawable(); SFMLVertices = new VertexArray((PrimitiveType)PrimitiveType); foreach (var v in Verts) { // Adjust texture for potential atlas offset. v.U += TextureLeft; v.V += TextureTop; v.U = Util.Clamp(v.U, TextureLeft, TextureRight); v.V = Util.Clamp(v.V, TextureTop, TextureBottom); //copy to new vert and apply color and alpha var vCopy = new Vert(v); vCopy.Color *= Color; vCopy.Color.A *= Alpha; SFMLVertices.Append(vCopy); } }
public static void Append(this VertexArray vertices, Vert vert) { vertices.Append(vert.X, vert.Y, vert.Color, vert.U, vert.V); }
/// <summary> /// Create a new Vert. /// </summary> /// <param name="copy">A source Vert to copy.</param> public Vert(Vert copy) : this(copy.X, copy.Y, copy.Color, copy.U, copy.V) { }
/// <summary> /// Add a Vert. /// </summary> /// <param name="x">The X position.</param> /// <param name="y">The Y position.</param> public void Add(float x, float y) { var vert = new Vert(x, y); Add(vert); }
/// <summary> /// Add a Vert. /// </summary> /// <param name="x">The X position.</param> /// <param name="y">The Y position.</param> /// <param name="color">The Color.</param> public void Add(float x, float y, Color color) { var vert = new Vert(x, y, color); Add(vert); }
/// <summary> /// Add a Vert. /// </summary> /// <param name="x">The X position.</param> /// <param name="y">The Y position.</param> /// <param name="u">The X position on the Texture.</param> /// <param name="v">The Y position on the Texture.</param> public void Add(float x, float y, float u, float v) { var vert = new Vert(x, y, u, v); Add(vert); }
/// <summary> /// Add a Vert. /// </summary> /// <param name="x">The X position.</param> /// <param name="y">The Y position.</param> /// <param name="color">The Color.</param> /// <param name="u">The X position on the Texture.</param> /// <param name="v">The Y position on the Texture.</param> public void Add(float x, float y, Color color, float u, float v) { var vert = new Vert(x, y, color, u, v); Add(vert); }