/// <summary> /// Equals override /// </summary> /// <param name="obj"></param> /// <returns></returns> public override bool Equals(object obj) { SpriteLayout layout = (SpriteLayout)obj; return(base.Equals(obj) && layout.Color.Equals(this.Color)); }
/// <summary> /// Clones the layout /// </summary> /// <returns></returns> public override object Clone() { SpriteLayout layout = new SpriteLayout(); layout.SetFrom(this); layout.Color = this.Color; layout.Skew = this.Skew; return(layout); }
/// <summary> /// Applies the provided keyframe to the control, /// overriding all needed properties /// </summary> /// <param name="frame"></param> public override void ApplyKeyFrame(KeyFrame startFrame, KeyFrame endFrame, float factor) { base.ApplyKeyFrame(startFrame, endFrame, factor); SpriteLayout startLayout = startFrame != null ? startFrame.Layout as SpriteLayout : null; SpriteLayout endLayout = endFrame != null ? endFrame.Layout as SpriteLayout : null; if (startLayout == null && endLayout == null) { return; } int r, g, b, a; float skew; if (endLayout == null) { r = startLayout.Color.R; g = startLayout.Color.G; b = startLayout.Color.B; a = startLayout.Color.A; skew = startLayout.Skew; } else { r = (int)((float)startLayout.Color.R * (1.0f - factor) + (float)endLayout.Color.R * factor); g = (int)((float)startLayout.Color.G * (1.0f - factor) + (float)endLayout.Color.G * factor); b = (int)((float)startLayout.Color.B * (1.0f - factor) + (float)endLayout.Color.B * factor); a = (int)((float)startLayout.Color.A * (1.0f - factor) + (float)endLayout.Color.A * factor); skew = startLayout.Skew * (1.0f - factor) + endLayout.Skew * factor; } this.Color = Color.FromArgb(a, r, g, b); this.Skew = skew; }
/// <summary> /// Constructor /// </summary> public GUISprite() { Layout = new SpriteLayout(); Name = "Sprite"; }
/// <summary> /// Clones the layout /// </summary> /// <returns></returns> public override object Clone() { SpriteLayout layout = new SpriteLayout(); layout.SetFrom(this); layout.Color = this.Color; layout.Skew = this.Skew; return layout; }