This project is read-only.

Getter/Setter

Getters and Setters allow for more complex animation while keeping it's usage very simple.

Example

Step 1 (Optional) - Create a name for your getter/setter and store in a static variable to access later.

public const string MyColorName = "mycolorname";

Step 2 - Create Getter/Setter

var MyColorGetterSetter = new GetterSetter
{
    Getter = (obj, data) => obj,
    Setter = (obj, data, per) =>
                 {
                     var c = GetterSetterData.EaseValue((Color) data.ValueStart, (Color) data.ValueEnd,
                                                        per);
                     var o = (Color) obj;
                     o.A = c.A;
                     o.B = c.B;
                     o.R = c.R;
                     o.G = c.G;
                 }
};

Step 3 - Register your GetterSetter

AnimationTypes.RegisterGetterSetter("mycolorname", MyColorGetterSetter);

Step 4 - Usage

var rnd = new Random();

var color = Color.FromArgb(1, 255, 255, 255);
var newColor = Color.FromArgb(1, (byte) (rnd.NextDouble()*255), (byte) (rnd.NextDouble()*255), (byte) (rnd.NextDouble()*255));

ArtefactAnimator.AddEase(color, "mycolorname"}, newColor, time, ease, delay);

Shortcuts

If you're only using a dependency property and you want to reference it by string, use the RegisterShorcut method.

AnimationTypes.RegisterShortcut("alpha", UIElement.OpacityProperty);

Last edited Mar 2, 2010 at 8:54 PM by jgraup, version 2

Comments

No comments yet.