public void TestRemoveFramesBefore() { var actor = new Actor(new Scene(), 1, 0); var value = new VFloat(actor, 1); value.AddStepFrame(actor.StartTime, 0); Assert.Throws <ArgumentException>(() => value.RemoveFramesBefore(1)); value.AddStepFrame(10, 5.1f); value.Interpolate(5); value.RemoveFramesBefore(4); Assert.AreEqual(0, value.GetValue(4)); Assert.AreEqual(0, value.GetValue(5)); Assert.AreEqual(0, value.GetValue(9)); Assert.AreEqual(5.1f, value.GetValue(10)); Assert.AreEqual(5.1f, value.GetValue(11)); value.AddLinearFrame(20, 15.1f); value.Interpolate(12); value.RemoveFramesBefore(11); Assert.AreEqual(7.1f, value.GetValue(11)); Assert.AreEqual(7.1f, value.GetValue(12)); Assert.AreEqual(8.1f, value.GetValue(13)); Assert.AreEqual(14.1f, value.GetValue(19)); Assert.AreEqual(15.1f, value.GetValue(20)); }
protected Variable <float> AddFloat(Actor actor, int id) { var variable = new VFloat(actor, id); actor.AddVariable(variable); return(variable); }
public void TestAddFrames() { var actor = new Actor(new Scene(), 1, 0); var value = new VFloat(actor, 1); value.AddStepFrame(actor.StartTime, -10.5f); Assert.Throws <ArgumentException>(() => value.GetValue(-1)); Assert.AreEqual(-10.5f, value.GetValue(0)); Assert.AreEqual(-10.5f, value.GetValue(1)); value.AddStepFrame(10, 5.6f); Assert.AreEqual(-10.5f, value.GetValue(0)); Assert.AreEqual(-10.5f, value.GetValue(9)); Assert.AreEqual(5.6f, value.GetValue(10)); Assert.AreEqual(5.6f, value.GetValue(11)); value.AddLinearFrame(20, 15.6f); Assert.AreEqual(5.6f, value.GetValue(10)); Assert.AreEqual(6.6f, value.GetValue(11)); Assert.AreEqual(14.6f, value.GetValue(19)); Assert.AreEqual(15.6f, value.GetValue(20)); Assert.AreEqual(15.6f, value.GetValue(21)); }
public Variable<float> AddFloat(int id, float value) { if (this.actor == null) throw new InvalidOperationException("Cannot add variable after this.actor initialized"); var state = new RecordState(); var variable = new VFloat(this.actor, id, state); variable.AddStepFrame(this.actor.StartTime, value); state.OnChange(this.actor.StartTime); this.actor.AddVariable(variable); return variable; }
public Variable <float> AddFloat(int id, float value) { if (this.actor == null) { throw new InvalidOperationException("Cannot add variable after this.actor initialized"); } var state = new RecordState(); var variable = new VFloat(this.actor, id, state); variable.AddStepFrame(this.actor.StartTime, value); state.OnChange(this.actor.StartTime); this.actor.AddVariable(variable); return(variable); }
public void TestRemoveFramesAfter() { var actor = new Actor(new Scene(), 1, 0); var value = new VFloat(actor, 1); value.AddStepFrame(actor.StartTime, 0); Assert.Throws<ArgumentException>(() => value.RemoveFramesAfter(-1)); value.AddStepFrame(10, 5); value.Interpolate(9); value.RemoveFramesAfter(10); Assert.AreEqual(0, value.GetValue(8), 0); Assert.AreEqual(0, value.GetValue(9), 0); Assert.AreEqual(0, value.GetValue(10), 0); value.AddLinearFrame(19, 10); value.Interpolate(17); value.RemoveFramesAfter(18); Assert.AreEqual(7, value.GetValue(16)); Assert.AreEqual(8, value.GetValue(17)); Assert.AreEqual(8, value.GetValue(18)); }
public void TestRemoveFramesAfter() { var actor = new Actor(new Scene(), 1, 0); var value = new VFloat(actor, 1); value.AddStepFrame(actor.StartTime, 0); Assert.Throws <ArgumentException>(() => value.RemoveFramesAfter(-1)); value.AddStepFrame(10, 5); value.Interpolate(9); value.RemoveFramesAfter(10); Assert.AreEqual(0, value.GetValue(8), 0); Assert.AreEqual(0, value.GetValue(9), 0); Assert.AreEqual(0, value.GetValue(10), 0); value.AddLinearFrame(19, 10); value.Interpolate(17); value.RemoveFramesAfter(18); Assert.AreEqual(7, value.GetValue(16)); Assert.AreEqual(8, value.GetValue(17)); Assert.AreEqual(8, value.GetValue(18)); }
public void TestAddFrames() { var actor = new Actor(new Scene(), 1, 0); var value = new VFloat(actor, 1); value.AddStepFrame(actor.StartTime, -10.5f); Assert.Throws<ArgumentException>(() => value.GetValue(-1)); Assert.AreEqual(-10.5f, value.GetValue(0)); Assert.AreEqual(-10.5f, value.GetValue(1)); value.AddStepFrame(10, 5.6f); Assert.AreEqual(-10.5f, value.GetValue(0)); Assert.AreEqual(-10.5f, value.GetValue(9)); Assert.AreEqual(5.6f, value.GetValue(10)); Assert.AreEqual(5.6f, value.GetValue(11)); value.AddLinearFrame(20, 15.6f); Assert.AreEqual(5.6f, value.GetValue(10)); Assert.AreEqual(6.6f, value.GetValue(11)); Assert.AreEqual(14.6f, value.GetValue(19)); Assert.AreEqual(15.6f, value.GetValue(20)); Assert.AreEqual(15.6f, value.GetValue(21)); }
public void TestRemoveFramesBefore() { var actor = new Actor(new Scene(), 1, 0); var value = new VFloat(actor, 1); value.AddStepFrame(actor.StartTime, 0); Assert.Throws<ArgumentException>(() => value.RemoveFramesBefore(1)); value.AddStepFrame(10, 5.1f); value.Interpolate(5); value.RemoveFramesBefore(4); Assert.AreEqual(0, value.GetValue(4)); Assert.AreEqual(0, value.GetValue(5)); Assert.AreEqual(0, value.GetValue(9)); Assert.AreEqual(5.1f, value.GetValue(10)); Assert.AreEqual(5.1f, value.GetValue(11)); value.AddLinearFrame(20, 15.1f); value.Interpolate(12); value.RemoveFramesBefore(11); Assert.AreEqual(7.1f, value.GetValue(11)); Assert.AreEqual(7.1f, value.GetValue(12)); Assert.AreEqual(8.1f, value.GetValue(13)); Assert.AreEqual(14.1f, value.GetValue(19)); Assert.AreEqual(15.1f, value.GetValue(20)); }