public void AnimateColor(Texture.Texture texture, Color4 to, int frame, Func<double, double> easing = null) { if (frame == 0) return; frame /= 2; easing = easing ?? EasingFunctions.Linear; this.targetObject = texture; this.targetPropery = "color"; Color4 from = new Color4(); bool noCompile = false; float dr = 0f, dg = 0f, db = 0f, da = 0f; Process.Invoke(() => { texture.NoCompile = true; from = texture.Color; noCompile = texture.NoCompile; dr = (to.R - from.R); dg = (to.G - from.G); db = (to.B - from.B); da = (to.A - from.A); }); for (int i = 0, j = 1; i < frame; i++) { Process.WaitFrame(1); Process.Invoke(() => { float f = (float)easing(j++ / (double)frame); texture.Color = new Color4((from.R + dr * f).Clamp(1f, 0f), (from.G + dg * f).Clamp(1f, 0f), (from.B + db * f).Clamp(1f, 0f), (from.A + da * f).Clamp(1f, 0f)); }); } Process.Invoke(() => { if (!noCompile) texture.NoCompile = false; }); }
public void AnimatePosition(Texture.Texture texture, PointF to, int frame, Func<double, double> easing = null) { if (frame == 0) return; frame /= 2; easing = easing ?? EasingFunctions.Linear; this.targetObject = texture; this.targetPropery = "position"; PointF from = new PointF(); bool noCompile = false; float dx = 0f, dy = 0f; Process.Invoke(() => { texture.NoCompile = true; from = texture.Position; noCompile = texture.NoCompile; dx = (to.X - from.X); dy = (to.Y - from.Y); }); for (int i = 0, j = 1; i < frame; i++) { Process.WaitFrame(1); Process.Invoke(() => { float f = (float)easing(j++ / (double)frame); texture.Position = new PointF(from.X + dx * f, from.Y + dy * f); }); } Process.Invoke(() => { if (!noCompile) texture.NoCompile = false; }); }
private void AsignmentTexture(int id, Texture.Texture texture) { int key; if (this.asignment.ContainsKey(id)) { key = this.asignment[id]; this.Window.Textures.Remove(key, true); this.Window.Textures.Add(key, texture); } else { key = this.Window.Textures.AddLast(texture); this.asignment.Add(id, key); } }