1 <!DOCTYPE html PUBLIC
"-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
4 <meta http-equiv=
"Content-Type" content=
"text/html; charset=UTF-8">
5 <meta http-equiv=
"Content-Style-Type" content=
"text/css">
7 <meta name=
"Generator" content=
"Cocoa HTML Writer">
8 <meta name=
"CocoaVersion" content=
"949.43">
9 <style type=
"text/css">
10 p
.p1
{margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Helvetica
}
11 p
.p2
{margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Helvetica
; min-height: 22.0px}
12 p
.p3
{margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica
}
13 p
.p4
{margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica
; min-height: 14.0px}
14 p
.p5
{margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Helvetica
}
15 p
.p6
{margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica
; color: #003dd8; min-height: 14.0px}
16 p
.p7
{margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco
; color: #416a20}
17 p
.p8
{margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco
}
18 p
.p9
{margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco
; min-height: 14.0px}
19 p
.p10
{margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco
; color: #9e2212}
20 p
.p11
{margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco
; color: #0033b4}
21 p
.p12
{margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Helvetica
; min-height: 17.0px}
22 p
.p13
{margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco
; color: #606060}
23 p
.p14
{margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Monaco
; color: #9e2212; min-height: 14.0px}
24 span
.s1
{color: #003dd8}
25 span
.s2
{text-decoration: underline
}
26 span
.s3
{color: #000000}
27 span
.s4
{color: #0033b4}
28 span
.s5
{color: #416a20}
29 span
.s6
{color: #9e2212}
30 span
.s7
{font: 12.0px Helvetica
; color: #000000}
31 span
.s8
{color: #606060}
32 span
.s9
{font: 14.0px Helvetica
}
33 span
.s10
{font: 12.0px Helvetica
}
34 span
.s11
{color: #0000ff}
35 span
.s12
{font: 10.0px Monaco
}
36 span
.Apple-tab-span
{white-space:pre
}
40 <p class=
"p1"><b>SCImageFilter
</b></p>
41 <p class=
"p2"><br></p>
42 <p class=
"p3">filter class to use with
<a href=
"SCImage.html"><span class=
"s1">SCImage
</span></a></p>
43 <p class=
"p3">currently this class represents the CoreImage Filters you can apply to a SCImage.
</p>
44 <p class=
"p4"><br></p>
45 <p class=
"p3">all the built-in filters and docs:
</p>
46 <p class=
"p4"><br></p>
47 <p class=
"p3"><span class=
"s2">http://developer.apple.com/documentation/GraphicsImaging/Reference/CoreImageFilterReference/Reference/reference.html
</span></p>
48 <p class=
"p4"><br></p>
49 <p class=
"p4"><br></p>
50 <p class=
"p5"><b>Class Methods
</b></p>
51 <p class=
"p6"><span class=
"Apple-tab-span"> </span></p>
52 <p class=
"p3"><span class=
"s1"><span class=
"Apple-tab-span"> </span></span><b>*new (filterName, args)
</b></p>
53 <p class=
"p3"><b><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>filterName -
</b>The filter name
<a href=
"../../../Core/Symbol.html"><span class=
"s1">Symbol
</span></a> or
<a href=
"../../../Collections/String.html"><span class=
"s1">String
</span></a></p>
54 <p class=
"p3"><span class=
"s1"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span><b>args -
</b>The filter name
<a href=
"../../../Core/Symbol.html"><span class=
"s1">Symbol
</span></a> or
<a href=
"../../../Collections/String.html"><span class=
"s1">String
</span></a></p>
55 <p class=
"p6"><span class=
"Apple-tab-span"> </span></p>
56 <p class=
"p7"><span class=
"s3"><span class=
"Apple-tab-span"> </span>f =
</span><span class=
"s4">SCImageFilter
</span><span class=
"s3">.new(
</span>\CIStarShineGenerator
<span class=
"s3">);
</span></p>
57 <p class=
"p8"><span class=
"Apple-tab-span"> </span>f.attributes;
</p>
58 <p class=
"p9"><span class=
"Apple-tab-span"> </span></p>
59 <p class=
"p10"><span class=
"s3"><span class=
"Apple-tab-span"> </span></span>// or you can do also Synth like style if you already know the attributes of this synth
</p>
60 <p class=
"p8"><span class=
"Apple-tab-span"> </span>f =
<span class=
"s4">SCImageFilter
</span>.new(
<span class=
"s5">\CIStarShineGenerator
</span>, [
<span class=
"s5">\center
</span>, [
200,
200],
<span class=
"s5">\radius
</span>,
200*
0.05]);
</p>
61 <p class=
"p8"><span class=
"Apple-tab-span"> </span>f.values;
<span class=
"s6">//
</span></p>
62 <p class=
"p4"><span class=
"Apple-tab-span"> </span></p>
63 <p class=
"p3"><span class=
"s1"><span class=
"Apple-tab-span"> </span></span><b>*filterCategories
</b></p>
64 <p class=
"p3"><b><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></b>Returns a Dictionary containing all the filters associated by categories.
</p>
65 <p class=
"p10"><span class=
"s7"><b><span class=
"Apple-tab-span"> </span></b></span>// getting filter categories (dictionary)
</p>
66 <p class=
"p8"><span class=
"Apple-tab-span"> </span>(
</p>
67 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s4">SCImageFilter
</span>.filterCategories.keysDo({
<span class=
"s4">|cat|
</span></p>
68 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>cat.postln;
</p>
69 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>});
</p>
70 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s8">"ok"</span>.postln;
</p>
71 <p class=
"p8"><span class=
"Apple-tab-span"> </span>)
</p>
72 <p class=
"p9"><span class=
"Apple-tab-span"> </span></p>
73 <p class=
"p10"><span class=
"s3"><span class=
"Apple-tab-span"> </span></span>// getting Filters for a category - returns a SymbolArray
</p>
74 <p class=
"p7"><span class=
"s3"><span class=
"Apple-tab-span"> </span></span><span class=
"s4">SCImageFilter
</span><span class=
"s3">.filterCategories.at(
</span>\CICategoryGeometryAdjustment
<span class=
"s3">);
</span></p>
75 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"s4">SCImageFilter
</span>.filterCategories.at(
<span class=
"s5">\CICategoryGenerator
</span>);
</p>
76 <p class=
"p4"><b><span class=
"Apple-tab-span"> </span></b></p>
77 <p class=
"p10"><span class=
"s7"><b><span class=
"Apple-tab-span"> </span></b></span>// finding Non Built In Plugins usually plugins loaded in (/Library/Graphics/Image Units/)
</p>
78 <p class=
"p10"><span class=
"s3"><span class=
"Apple-tab-span"> </span></span>// all plugins are loaded at startup
</p>
79 <p class=
"p10"><span class=
"s3"><span class=
"Apple-tab-span"> </span></span>// you can find free plugins at http://www.noiseindustries.com/products/
</p>
80 <p class=
"p8"><span class=
"Apple-tab-span"> </span>(
</p>
81 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"s4">var
</span> n =
0;
</p>
82 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"s4">SCImageFilter
</span>.filterCategories.do ({
</p>
83 <p class=
"p11"><span class=
"s3"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span>|symbolArray|
</p>
84 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>symbolArray.do ({
<span class=
"s4">|pluginName|
</span></p>
85 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>if(pluginName.asString.beginsWith(
<span class=
"s8">"CI"</span>).not, {
</p>
86 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>(
<span class=
"s8">"External Filter Found: "</span> ++ pluginName).postln;
</p>
87 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>n = n+
1;
</p>
88 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>});
</p>
89 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>});
</p>
90 <p class=
"p8"><span class=
"Apple-tab-span"> </span>});
</p>
91 <p class=
"p8"><span class=
"Apple-tab-span"> </span>(n +
<span class=
"s8">"plugins found"</span>).postln;
</p>
92 <p class=
"p8"><span class=
"Apple-tab-span"> </span>n;
</p>
93 <p class=
"p8"><span class=
"Apple-tab-span"> </span>)
</p>
94 <p class=
"p4"><br></p>
95 <p class=
"p4"><br></p>
96 <p class=
"p5"><b>Instance Methods
</b></p>
97 <p class=
"p12"><br></p>
98 <p class=
"p3"><span class=
"s9"><b><span class=
"Apple-tab-span"> </span></b></span><b>attributes
<span class=
"Apple-tab-span"> </span></b></p>
99 <p class=
"p3"><b><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></b>returns an
<a href=
"../../../Collections/IdentityDictionary.html"><span class=
"s1">IdentityDictionary
</span></a> containing for each association:
</p>
100 <p class=
"p3"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>the attribute/property name as the key.
</p>
101 <p class=
"p3"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>the supercollider
<a href=
"../../../Core/Kernel/Class.html"><span class=
"s1">Class
</span></a> you should use as an argument to set the attribute.
</p>
102 <p class=
"p3"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>Once you know the attributes you can set them like using normal instance setters, use the name and append '_'.
</p>
103 <p class=
"p4"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
104 <p class=
"p8"><span class=
"s10"><span class=
"Apple-tab-span"> </span></span>(
</p>
105 <p class=
"p7"><span class=
"s3"><span class=
"Apple-tab-span"> </span>f =
</span><span class=
"s4">SCImageFilter
</span><span class=
"s3">.new(
</span>\CIStarShineGenerator
<span class=
"s3">);
</span></p>
106 <p class=
"p8"><span class=
"Apple-tab-span"> </span>f.attributes.keysValuesDo({
<span class=
"s4">|k, v|
</span></p>
107 <p class=
"p13"><span class=
"s3"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>(
</span>"CIStarShineGenerator responds to "<span class=
"s3">++k.asString++
</span>"_("<span class=
"s3">++v.asString++
</span>")"<span class=
"s3">).postln;
</span></p>
108 <p class=
"p8"><span class=
"Apple-tab-span"> </span>});
</p>
109 <p class=
"p8"><span class=
"Apple-tab-span"> </span>)
</p>
110 <p class=
"p9"><span class=
"Apple-tab-span"> </span></p>
111 <p class=
"p8"><span class=
"Apple-tab-span"> </span>f.center_([
200,
200]);
</p>
112 <p class=
"p8"><span class=
"Apple-tab-span"> </span>f.radius_(
200*
0.05);
</p>
113 <p class=
"p9"><span class=
"Apple-tab-span"> </span></p>
114 <p class=
"p3"><span class=
"Apple-tab-span"> </span><b>attributeRange
</b></p>
115 <p class=
"p3"><b><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></b>get the numerical range and the default Value for an attribute.
</p>
116 <p class=
"p3"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>returns an Array as [ min, max, default ]
</p>
117 <p class=
"p3"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>min, max, or default may be a
<a href=
"../../../Math/Float.html"><span class=
"s11">Float
</span></a>, a
<a href=
"../../GUI-Tools/Color.html"><span class=
"s11">Color
</span></a>, an
<a href=
"../../../Collections/Array.html"><span class=
"s11">Array
</span></a> or
<a href=
"../../../Core/Nil.html"><span class=
"s11">Nil
</span></a>.
</p>
118 <p class=
"p4"><span class=
"Apple-tab-span"> </span></p>
119 <p class=
"p10"><span class=
"s3"><span class=
"Apple-tab-span"> </span></span>// a SCImageFilter
</p>
120 <p class=
"p7"><span class=
"s3"><span class=
"Apple-tab-span"> </span>f =
</span><span class=
"s4">SCImageFilter
</span><span class=
"s3">.new(
</span>\CIFlashTransition
<span class=
"s3">);
</span></p>
121 <p class=
"p9"><span class=
"Apple-tab-span"> </span></p>
122 <p class=
"p8"><span class=
"Apple-tab-span"> </span>f.dump;
</p>
123 <p class=
"p9"><span class=
"Apple-tab-span"> </span></p>
124 <p class=
"p8"><span class=
"Apple-tab-span"> </span>f.attributes;
</p>
125 <p class=
"p9"><span class=
"Apple-tab-span"> </span></p>
126 <p class=
"p8"><span class=
"Apple-tab-span"> </span>f.attributeRange(
<span class=
"s5">\time
</span>);
</p>
127 <p class=
"p9"><span class=
"Apple-tab-span"> </span></p>
128 <p class=
"p10"><span class=
"s3"><span class=
"Apple-tab-span"> </span></span>// getting all attributes MIN - MAX possible values
</p>
129 <p class=
"p8"><span class=
"Apple-tab-span"> </span>(
</p>
130 <p class=
"p8"><span class=
"Apple-tab-span"> </span>f.attributes.keysDo({
<span class=
"s4">|attr|
</span></p>
131 <p class=
"p10"><span class=
"s3"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>(attr ++
</span><span class=
"s8">" = "</span><span class=
"s3"> + f.attributeRange(attr)).postln;
</span>// nil results means there is no min max for those attributes
</p>
132 <p class=
"p8"><span class=
"Apple-tab-span"> </span>});
</p>
133 <p class=
"p8"><span class=
"Apple-tab-span"> </span>)
</p>
134 <p class=
"p9"><span class=
"Apple-tab-span"> </span></p>
135 <p class=
"p3"><span class=
"Apple-tab-span"> </span><b>values
</b></p>
136 <p class=
"p3"><b><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></b>returns all the values you setted for each attributes. If a value is not explicitely setted
</p>
137 <p class=
"p3"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>for an attribute, it will be set to default when applied to the SCImage.
</p>
138 <p class=
"p4"><br></p>
139 <p class=
"p8"><span class=
"Apple-tab-span"> </span>(
</p>
140 <p class=
"p7"><span class=
"s3"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>f =
</span><span class=
"s4">SCImageFilter
</span><span class=
"s3">.new(
</span>\CIStarShineGenerator
<span class=
"s3">);
</span></p>
141 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"s10"><span class=
"Apple-tab-span"> </span></span>f.center_([
200,
200]);
</p>
142 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>f.radius_(
200*
0.05);
</p>
143 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>f.color_(
<span class=
"s4">Color
</span>.blue);
</p>
144 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>f.crossWidth_(
2.0);
</p>
145 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>f.crossAngle_(
0.0);
</p>
146 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>f.crossOpacity_(-
4.0);
</p>
147 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>f.values.postln;
</p>
148 <p class=
"p8"><span class=
"Apple-tab-span"> </span>)
</p>
149 <p class=
"p9"><br></p>
150 <p class=
"p3"><span class=
"s12"><span class=
"Apple-tab-span"> </span></span><b>set( args )
</b></p>
151 <p class=
"p3"><b><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></b>set the attributes for this SCImageFilter
</p>
152 <p class=
"p8"><span class=
"s10"><span class=
"Apple-tab-span"> </span></span>(
</p>
153 <p class=
"p7"><span class=
"s3"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>f =
</span><span class=
"s4">SCImageFilter
</span><span class=
"s3">.new(
</span>\CIStarShineGenerator
<span class=
"s3">);
</span></p>
154 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"s10"><span class=
"Apple-tab-span"> </span></span>f.set(
<span class=
"s5">\center
</span>, [
200,
200],
<span class=
"s5">\radius
</span>,
200*
0.05,
<span class=
"s5">\color
</span>,
<span class=
"s4">Color
</span>.blue,
<span class=
"s5">\crossWidth
</span>,
2.0);
</p>
155 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>f.values.postln;
</p>
156 <p class=
"p8"><span class=
"Apple-tab-span"> </span>)
<span class=
"s10"><span class=
"Apple-tab-span"> </span></span></p>
157 <p class=
"p9"><br></p>
158 <p class=
"p3"><span class=
"s12"><span class=
"Apple-tab-span"> </span></span><b>enable_(yorn)
</b></p>
159 <p class=
"p3"><b><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></b>enable or not the Filter when applied to a SCImage. If
<b>yorn
</b> is false, applying the filter will do
</p>
160 <p class=
"p3"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>nothing.
</p>
161 <p class=
"p4"><span class=
"Apple-tab-span"> </span></p>
162 <p class=
"p3"><span class=
"Apple-tab-span"> </span><b>enable
</b></p>
163 <p class=
"p3"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>is the filter enabled ?
<b>true
</b> is default
</p>
164 <p class=
"p4"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
165 <p class=
"p4"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
166 <p class=
"p4"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
167 <p class=
"p9"><br></p>
168 <p class=
"p10">//EXAMPLES
</p>
169 <p class=
"p9"><br></p>
170 <p class=
"p9"><br></p>
171 <p class=
"p10">// thor's fast experimentation request
</p>
172 <p class=
"p10">// example with the filters array wich allows you to use filters without applying them in place
</p>
173 <p class=
"p10">// convenient for RT use / test or whatever...
</p>
174 <p class=
"p9"><br></p>
175 <p class=
"p10">// here scale down the image otherwise with the zoomblur it will take your computer
</p>
176 <p class=
"p10">// to its knees using addFilter and not applyFilter
</p>
177 <p class=
"p10">// kinda fast swapping test
</p>
178 <p class=
"p9"><br></p>
179 <p class=
"p8">a =
<span class=
"s4">SCImage
</span>.new(
<span class=
"s8">"/Library/Desktop Pictures/Plants/Peony.jpg"</span>).scalesWhenResized_(
<span class=
"s4">true
</span>).setSize(
500,
400);
</p>
180 <p class=
"p10"><span class=
"s3">a.plot;
</span>// look at me first - i am beautiful
</p>
181 <p class=
"p9"><br></p>
182 <p class=
"p10">// but i want you to be posterize
</p>
184 <p class=
"p7"><span class=
"s3">h =
</span><span class=
"s4">SCImageFilter
</span><span class=
"s3">.new(
</span>\CIColorPosterize
<span class=
"s3">);
</span></p>
185 <p class=
"p10"><span class=
"s3">a.addFilter(h);
</span>// first call needed
</p>
186 <p class=
"p10"><span class=
"s3">a.plot;
</span>// there should have it
</p>
188 <p class=
"p9"><br></p>
189 <p class=
"p10">// then you can freely access and set the slot directly - easier
</p>
191 <p class=
"p8">a.filters[
0] =
<span class=
"s4">SCImageFilter
</span>.new(
<span class=
"s5">\CIColorInvert
</span>);
</p>
192 <p class=
"p8">a.plot;
</p>
194 <p class=
"p9"><br></p>
195 <p class=
"p10">// again
</p>
197 <p class=
"p8">a.filters[
0] =
<span class=
"s4">SCImageFilter
</span>.new(
<span class=
"s5">\CIZoomBlur
</span>);
</p>
198 <p class=
"p8">a.plot;
</p>
200 <p class=
"p9"><br></p>
201 <p class=
"p10">// again
</p>
203 <p class=
"p8">a.filters[
0] =
<span class=
"s4">SCImageFilter
</span>.new(
<span class=
"s5">\CIRandomGenerator
</span>);
</p>
204 <p class=
"p8">a.plot;
</p>
206 <p class=
"p9"><br></p>
208 <p class=
"p8">a.removeAllFilters;
</p>
209 <p class=
"p8">a.plot(freeOnClose:
<span class=
"s4">true
</span>);
</p>
211 <p class=
"p9"><br></p>
212 <p class=
"p9"><br></p>
213 <p class=
"p10">// ** Masking Example **
</p>
215 <p class=
"p10"><span class=
"s3">f =
</span><span class=
"s4">SCImageFilter
</span><span class=
"s3">.new(
</span><span class=
"s5">\CIColorMonochrome
</span><span class=
"s3">);
</span>// create a GrayScale image
</p>
216 <p class=
"p10"><span class=
"s3">g =
</span><span class=
"s4">SCImageFilter
</span><span class=
"s3">.new(
</span><span class=
"s5">\CISourceInCompositing
</span><span class=
"s3">);
</span>// compositing we will use
</p>
217 <p class=
"p8">f.color_(
<span class=
"s4">Color
</span>.black);
</p>
218 <p class=
"p8">f.intensity_(
1.0);
</p>
219 <p class=
"p8">a =
<span class=
"s4">SCImage
</span>.new(
<span class=
"s4">Document
</span>.current.dir +/+
<span class=
"s8">"vduck2.jpg"</span>);
</p>
220 <p class=
"p8">a.bounds;
</p>
221 <p class=
"p8">b =
<span class=
"s4">SCImage
</span>.new(
<span class=
"s4">Document
</span>.current.dir +/+
<span class=
"s8">"flowers2.jpg"</span>);
</p>
222 <p class=
"p10"><span class=
"s3">a.applyFilters([f,
</span><span class=
"s4">SCImageFilter
</span><span class=
"s3">(
</span><span class=
"s5">\CIColorInvert
</span><span class=
"s3">),
</span><span class=
"s4">SCImageFilter
</span><span class=
"s3">(
</span><span class=
"s5">\CIMaskToAlpha
</span><span class=
"s3">)]);
</span>// grayscale + invert + maskToAlpha = create a mask
</p>
223 <p class=
"p10"><span class=
"s3">g.backgroundImage_(a);
</span>// set up background image
</p>
224 <p class=
"p10"><span class=
"s3">b.applyFilters(g);
</span>// create masked image
</p>
225 <p class=
"p8">a.free;
</p>
226 <p class=
"p10"><span class=
"s3">w = b.plot(freeOnClose:
</span><span class=
"s4">true
</span><span class=
"s3">, background:
</span><span class=
"s4">Color
</span><span class=
"s3">.clear);
</span>// set to clear color to see plainly the image
</p>
228 <p class=
"p9"><br></p>
229 <p class=
"p9"><br></p>
230 <p class=
"p10">// *** Kinda very simple real time FX using the .filters property of SCImage **
</p>
231 <p class=
"p10">// SCImage.filters provides a way to set up filters to apply in the rendering chain
</p>
232 <p class=
"p10">// this can be useful to modify in RT some filter properties
</p>
233 <p class=
"p10">// but they won't be processed inplace, they will be computed at each rendering
</p>
234 <p class=
"p10">// here the filter calc is performed at each rendering call
</p>
235 <p class=
"p10">// so this is convenient but not optimal
</p>
236 <p class=
"p10">// SCPhotoshop :)
</p>
238 <p class=
"p8"><span class=
"s4">var
</span> width=
500, height=
500, centerVector;
</p>
239 <p class=
"p8"><span class=
"s4">var
</span> controller, specs;
</p>
240 <p class=
"p9"><br></p>
241 <p class=
"p8">centerVector = [width*
0.5, height*
0.5];
</p>
242 <p class=
"p8">a =
<span class=
"s4">SCImage
</span>.new(
500@
500);
</p>
243 <p class=
"p8">a.accelerated_(
<span class=
"s4">true
</span>);
</p>
244 <p class=
"p7"><span class=
"s3">f =
</span><span class=
"s4">SCImageFilter
</span><span class=
"s3">.new(
</span>\CIStarShineGenerator
<span class=
"s3">);
</span></p>
245 <p class=
"p11"><span class=
"s3">g =
</span>SCImageFilter
<span class=
"s3">.new(
</span><span class=
"s5">\CIPixellate
</span><span class=
"s3">);
</span></p>
246 <p class=
"p11"><span class=
"s3">h =
</span>SCImageFilter
<span class=
"s3">.new(
</span><span class=
"s5">\CIZoomBlur
</span><span class=
"s3">);
</span></p>
247 <p class=
"p9"><br></p>
248 <p class=
"p8">f.center_(centerVector);
</p>
249 <p class=
"p8">f.radius_(width*
0.05);
</p>
250 <p class=
"p8">f.color_(
<span class=
"s4">Color
</span>.green);
</p>
251 <p class=
"p8">f.crossWidth_(
2.0);
</p>
252 <p class=
"p8">f.crossAngle_(
0.0);
</p>
253 <p class=
"p8">f.crossOpacity_(-
4.0);
</p>
254 <p class=
"p8">g.center_(centerVector);
</p>
255 <p class=
"p8">h.center_(centerVector);
</p>
256 <p class=
"p8">h.amount_(
50);
</p>
257 <p class=
"p9"><br></p>
258 <p class=
"p10">// simple example control
</p>
259 <p class=
"p8">specs = [
</p>
260 <p class=
"p8"><span class=
"Apple-tab-span"> </span>[f,
<span class=
"s5">\crossOpacity_
</span>, [-
8,
0].asSpec, -
4],
</p>
261 <p class=
"p8"><span class=
"Apple-tab-span"> </span>[f,
<span class=
"s5">\crossAngle_
</span>, [-pi, pi].asSpec,
0.0],
</p>
262 <p class=
"p8"><span class=
"Apple-tab-span"> </span>[h,
<span class=
"s5">\amount_
</span>, [
0,
200].asSpec,
50],
</p>
263 <p class=
"p9"><span class=
"Apple-tab-span"> </span></p>
264 <p class=
"p10"><span class=
"s3">];
</span>// CIStarShine opacity, CIZoomBlur
</p>
265 <p class=
"p9"><br></p>
266 <p class=
"p8">controller =
<span class=
"s4">SCWindow
</span>.new(
<span class=
"s8">"Close Me First !!!"</span>,
<span class=
"s4">Rect
</span>(
400,
400,
300,specs.size *
40));
</p>
267 <p class=
"p8">controller.view.decorator =
<span class=
"s4">FlowLayout
</span>(controller.view.bounds.insetBy(
10),
10@
10);
</p>
268 <p class=
"p8">specs.size.do {
<span class=
"s4">|i|
</span></p>
269 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"s4">SCSlider
</span>.new(controller,
<span class=
"s4">Rect
</span>(
0,
0,
150,
20))
</p>
270 <p class=
"p8"><span class=
"Apple-tab-span"> </span>.action_({
<span class=
"s4">|obj|
</span></p>
271 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>specs[i][
0].perform(specs[i][
1], specs[i][
2].map(obj.value));
</p>
272 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>w.refresh;
</p>
273 <p class=
"p8"><span class=
"Apple-tab-span"> </span>})
</p>
274 <p class=
"p8"><span class=
"Apple-tab-span"> </span>.value_(specs[i][
2].unmap(specs[i][
3]));
</p>
275 <p class=
"p8"><span class=
"Apple-tab-span"> </span>controller.view.decorator.nextLine;
</p>
277 <p class=
"p9"><br></p>
278 <p class=
"p10">// adding filters
</p>
279 <p class=
"p8">a.addFilter(f);
</p>
280 <p class=
"p8">a.addFilter(g);
</p>
281 <p class=
"p8">a.addFilter(h);
</p>
282 <p class=
"p9"><br></p>
283 <p class=
"p8">a.filters.do {
<span class=
"s4">|filt, i|
</span></p>
284 <p class=
"p8"><span class=
"Apple-tab-span"> </span>if(i !=
0, {
</p>
285 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s4">SCButton
</span>.new(controller,
<span class=
"s4">Rect
</span>(
0,
0,
20,
20))
</p>
286 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>.action_({
<span class=
"s4">|obj|
</span></p>
287 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>filt.enable_(obj.value !=
1);
</p>
288 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>w.refresh;
</p>
289 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>})
</p>
290 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>.states_([[
<span class=
"s8">""</span>,
<span class=
"s4">Color
</span>.white], [
<span class=
"s8">""</span>,
<span class=
"s4">Color
</span>.white,
<span class=
"s4">Color
</span>.black]]);
</p>
291 <p class=
"p8"><span class=
"Apple-tab-span"> </span>});
</p>
293 <p class=
"p9"><br></p>
294 <p class=
"p10">// plotting
</p>
295 <p class=
"p8">w = a.plot(background:
<span class=
"s4">Color
</span>.black);
</p>
296 <p class=
"p8">controller.front;
</p>
297 <p class=
"p8">controller.onClose_({
</p>
298 <p class=
"p8"><span class=
"Apple-tab-span"> </span>{
</p>
299 <p class=
"p8"><span class=
"Apple-tab-span"> </span>w.close;
</p>
300 <p class=
"p8"><span class=
"Apple-tab-span"> </span>}.defer(
0.1);
</p>
301 <p class=
"p8">});
</p>
303 <p class=
"p9"><br></p>
304 <p class=
"p9"><br></p>
305 <p class=
"p10">/*
</p>
306 <p class=
"p10">// ******** Using EXTERNAL NI Image Units Generator + FX *******
</p>
307 <p class=
"p10">// Download them --- MIGHT BE
10.5 Only so
</p>
308 <p class=
"p10">// http://www.noiseindustries.com/downloads/Units.dmg
</p>
309 <p class=
"p10">// When using for the first time an Image plugin, it might take some extra time due to the plugin loading
</p>
310 <p class=
"p10">// Random
</p>
312 <p class=
"p10">f = SCImageFilter.new(\NINoiseGenerator);
</p>
313 <p class=
"p10">f.width_(
500); f.height_(
500);
</p>
314 <p class=
"p10">f.grayscale_(true);
</p>
315 <p class=
"p10">a = SCImage.new(
500@
500);
</p>
316 <p class=
"p10">a.applyFilters(f);
</p>
317 <p class=
"p10">w = a.plot(freeOnClose:true, background:Color.black);
</p>
319 <p class=
"p14"><br></p>
320 <p class=
"p14"><br></p>
322 <p class=
"p10">f = SCImageFilter.new(\NIDropShadow);
</p>
323 <p class=
"p10">f.offsetX_(
0);
</p>
324 <p class=
"p10">f.offsetY_(
0);
</p>
325 <p class=
"p10">f.radius_(
30);
</p>
326 <p class=
"p10">f.shadowColor_(Color.red);
</p>
327 <p class=
"p10">a = SCImage.new(
"vduck2.jpg");
</p>
328 <p class=
"p10">a.applyFilters(f, a.bounds.outsetBy(
500));
</p>
329 <p class=
"p10">w = a.plot(freeOnClose:true, background:Color.clear);
</p>
330 <p class=
"p10">a.bounds;
</p>
332 <p class=
"p14"><br></p>
334 <p class=
"p10">f = SCImageFilter.new(\NIDotsGenerator);
</p>
335 <p class=
"p10">f.softness_(
1);
</p>
336 <p class=
"p10">a = SCImage.new(
500@
500);
</p>
337 <p class=
"p10">a.applyFilters(f);
</p>
338 <p class=
"p10">w = a.plot(freeOnClose:true, background:Color.black);
</p>
340 <p class=
"p14"><br></p>
342 <p class=
"p10">f = SCImageFilter.new(\NICircle);
</p>
343 <p class=
"p10">a = SCImage.new(
500@
500);
</p>
344 <p class=
"p10">a.applyFilters(f);
</p>
345 <p class=
"p10">w = a.plot(freeOnClose:true);
</p>
347 <p class=
"p10">*/
</p>