Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated in /var/www/html/extensions/Variables/includes/ExtVariables.php on line 198
CAFilter: Difference between revisions - iPhone Development Wiki

CAFilter: Difference between revisions

From iPhone Development Wiki
(Created page with 'CAFilter is an Objective-C wrapper for creating static or transition image filters. == Applying filters to layers == Although the SDK says that the <tt>filters</tt> propert…')
 
m (→‎Builtin static filters: Added 5 more known filters. Detail to be filled.)
Line 11: Line 11:
== Builtin static filters ==
== Builtin static filters ==
[[Image:CAFilterDemo.png|right|thumb|Layers with filters applied, in order: (1) no filter; (2) gaussianBlur; (3) multiplyColor; (4) pageCurl]]
[[Image:CAFilterDemo.png|right|thumb|Layers with filters applied, in order: (1) no filter; (2) gaussianBlur; (3) multiplyColor; (4) pageCurl]]
=== multiplyColor ===
This will multiply an <tt>inputColor</tt> to the layer.
=== multiplyGradient ===
=== colorAdd ===
=== colorSubtract ===
=== colorMonochrome ===
=== gaussianBlur ===
=== gaussianBlur ===
The <tt>gaussianBlur</tt> filter can apply a Gaussian blur effect to the layer. It accepts a float parameter, <tt>inputRadius</tt>, which specifies the strength of blurring.
The <tt>gaussianBlur</tt> filter can apply a Gaussian blur effect to the layer. It accepts a float parameter, <tt>inputRadius</tt>, which specifies the strength of blurring.


=== multiplyColor ===
=== lanczosResize ===
This will multiply an <tt>inputColor</tt> to the layer.


=== pageCurl ===
=== pageCurl ===

Revision as of 22:24, 21 January 2011

CAFilter is an Objective-C wrapper for creating static or transition image filters.

Applying filters to layers

Although the SDK says that the filters property is unused, you can actually apply filter effects with it, for example, to apply a Gaussian blur filter for a window:

CAFilter* filter = [CAFilter filterWithName:@"gaussianBlur"];
[filter setValue:[NSNumber numberWithFloat:5] forKey:@"inputRadius"];
window.layer.filters = [NSArray arrayWithObject:filter];

Builtin static filters

Error creating thumbnail: File missing
Layers with filters applied, in order: (1) no filter; (2) gaussianBlur; (3) multiplyColor; (4) pageCurl

multiplyColor

This will multiply an inputColor to the layer.

multiplyGradient

colorAdd

colorSubtract

colorMonochrome

gaussianBlur

The gaussianBlur filter can apply a Gaussian blur effect to the layer. It accepts a float parameter, inputRadius, which specifies the strength of blurring.

lanczosResize

pageCurl

The pageCurl filter gives the layer a page curl effect. It accepts 3 float parameters:

  • inputTime (from 0 to 1).
  • inputAngle (in radian, must not be a multiple of π/2).
  • inputRadius (in pixel, the radius of the curled part).

Transition filters

Transition filters also uses CAFilter as the interface, as CATransition also has a filter property. But the transition filters cannot be treated as static filters and applied to layers directly.

References