small medium large xlarge

Tosocnet_pragsmall
06 Feb 2009, 17:31
Andrei Freeman (3 posts)

Taking the pointalize code and the torus code, I tried to make the animation of the pointalize filter smoother.

Using the code from torus; I track the from and to values and set up an animation on the keyPath rather than directly applying it.

The result has two effects depending on a change in pointalize. If I initialize the key value initially to 0.0; the controls all blank out as white when I choose a light or heavy. If I initialize the key value to 1.0; selecting either light or heavy merely does an instant display of the 1.0 setting.

I omitted the torus key for repeatCount because I only want a one-shot.

This is the example change I’ve tried on 6.1’s View Filters (code/FilteredViews/FilterView/FilterView.m)

What am I missing?

-Andrei

- (IBAction)heavyPointalize:(id)sender { // int newPointalize = 5.0f; if(nil == [controls contentFilters] || 0 == [[controls contentFilters] count]) { [self pointalze]; }

NSString *path = [NSString stringWithFormat:
				  @"contentFilters.pointalize.%@", kCIInputRadiusKey];

if (currPointalise != newPointalize) {
	
	CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:path];
	animation.fromValue = NSNumber numberWithInt:currPointalize];
	animation.toValue = NSNumber numberWithInt:newPointalize];
	animation.duration = 1.0;
	animation.timingFunction = [CAMediaTimingFunction functionWithName:
								kCAMediaTimingFunctionEaseInEaseOut];
	
	[[controls layer] addAnimation:animation forKey:@"pointalizeAnimation"];
	currPointalizeFloat = newPointalizeFloat;

// [controls setValue:[NSNumber numberWithInt:5.0f] forKeyPath:path]; } }

@

Tosocnet_pragsmall
06 Feb 2009, 18:59
Andrei Freeman (3 posts)

other than formatting…

Let’s try the pre tag.

- (IBAction)heavyPointalize:(id)sender { // 
<label id="code.FilteredView.morePointalize:" />
	int newPointalize = 5.0f;
	if(nil == [controls contentFilters] || 0 == [[controls contentFilters] count]) { 
		[self pointalze];
	} NSString *path = [NSString stringWithFormat: @"contentFilters.pointalize.%@", kCIInputRadiusKey];

 	if (currPointalise != newPointalize) {
 		CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:path];

		animation.fromValue = NSNumber numberWithInt:currPointalize];
		animation.toValue = NSNumber numberWithInt:newPointalize];
		animation.duration = 1.0;
		animation.timingFunction = [CAMediaTimingFunction functionWithName: kCAMediaTimingFunctionEaseInEaseOut];

		[[controls layer] addAnimation:animation forKey:@"pointalizeAnimation"];
		currPointalizeFloat = newPointalizeFloat;

	// [controls setValue:[NSNumber numberWithInt:5.0f] forKeyPath:path];
	}
}
Biopic_100x100_pragsmall
07 Feb 2009, 13:48
Bill Dudney (917 posts)

Hi Andrei,

Your code looks fine so I copied it here and tried it out. I could not get it to animate either. I’ll continue looking at it today.

Please let us know if you get it working.

Tosocnet_pragsmall
11 Feb 2009, 07:15
Andrei Freeman (3 posts)

Thanks Bill,

If you like I can send you all the code changes I made to this file to see the whole thing. But I think the changes in this one method stand fairly well on their own.

It seems to reason from everything I’ve read that the CI Filters should be able to animate over time on a layer-backed view just like anything else. Theoretically you should be able to walk through a transform as easily as you should be able to walk through a gradual pointalise

So far… I’ve got nothing and am on the verge of assuming that I’m going to have to just copy the image of the view to a CGImage and treat it like a picture. (Not the preferred route)

Biopic_100x100_pragsmall
11 Feb 2009, 12:12
Bill Dudney (917 posts)

Hi Andrei,

My guess is that we are doing something simple incorrectly. I was able to get pointallize and many other filters to animate as backgroundFilters but none of them would as contentsFilters. It really should work.

I’ll have some more time to look at this later in the week. I’ll post if I find anything.

Johnjoyce_halo_pragsmall
27 Jan 2014, 05:48
John Joyce (9 posts)

I had the same experience recently. What I found was that animating filters need to be added to the view’s filters array, not the layer’s content or background filters arrays. Content filters in particular were non starters, and backgroundFilters were very fussy.

  You must be logged in to comment