PColorActivity interpolates between two colors for its target over the duration of the animation.
The source color is retrieved from the target just before the activity is scheduled to start.
Inheritance: UMD.HCIL.Piccolo.Activities.PInterpolatingActivity
		public override void Initialize() {
			PRoot root = Canvas.Root;
			PLayer layer = Canvas.Layer;
			PActivityScheduler scheduler = root.ActivityScheduler;
		
			PNode singlePulse = PPath.CreateRectangle(0, 0, 100, 80);;
			PPath repeatPulse = PPath.CreateRectangle(100, 80, 100, 80);;
			PNode repeatReversePulse = PPath.CreateRectangle(200, 160, 100, 80);;

			layer.AddChild(singlePulse);
			layer.AddChild(repeatPulse);
			layer.AddChild(repeatReversePulse);

			PColorActivity singlePulseActivity = new PColorActivity(1000, 0, 1, ActivityMode.SourceToDestination, new PulseTarget(singlePulse), Color.Orange);
			PColorActivity repeatPulseActivity = new PColorActivity(1000, 0, 5, ActivityMode.SourceToDestination, new PulseTarget(repeatPulse), Color.Blue);
			PColorActivity repeatReversePulseActivity = new PColorActivity(500, 0, 10, ActivityMode.SourceToDestination, new PulseTarget(repeatReversePulse), Color.Green);

			scheduler.AddActivity(singlePulseActivity);
			scheduler.AddActivity(repeatPulseActivity);
			scheduler.AddActivity(repeatReversePulseActivity);
		}
Esempio n. 2
0
		/// <summary>
		/// Animate this node's color from its current value to the new value
		/// specified.
		/// </summary>
		/// <param name="destColor">The final color value.</param>
		/// <param name="duration">The amount of time that the animation should take.</param>
		/// <returns>The newly scheduled activity.</returns>
		/// <remarks>
		/// This method assumes that this nodes Brush property is of type SolidBrush.
		/// If this node descends from the root then the activity will be scheduled,
		/// else the returned activity should be scheduled manually. If two different
		/// color activities are scheduled for the same node at the same time, they will
		/// both be applied to the node, but the last one scheduled will be applied last
		/// on each frame, so it will appear to have replaced the original. Generally
		/// you will not want to do that.
		/// </remarks>
		public virtual PColorActivity AnimateToColor(Color destColor, long duration) {
			PColorActivity.Target t = new PNodeColorTarget(this);

			if (duration == 0) {
				t.Color  = destColor;
				return null;
			}

			PColorActivity ca = new PColorActivity(duration, PUtil.DEFAULT_ACTIVITY_STEP_RATE, t, destColor);
			AddActivity(ca);
			return ca;
		}