You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@flex.apache.org by Alex Harui <ah...@adobe.com> on 2017/03/07 16:02:38 UTC
Re: git commit: [flex-asjs] [refs/heads/develop] - Added Shader files
(with compiler argument)
Hi,
Is it possible to use the upstream release instead? Even the flex-sdk
uses pbj files from the upstream. IIRC, we did that because not everyone
wanted to deal with installing the PB compiler.
Thanks,
-Alex
On 3/7/17, 2:25 AM, "harbs@apache.org" <ha...@apache.org> wrote:
>Repository: flex-asjs
>Updated Branches:
> refs/heads/develop 9657c4e9a -> 281c77860
>
>
>Added Shader files (with compiler argument)
>
>
>Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo
>Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/281c7786
>Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/281c7786
>Diff: ttp://git-wip-us.apache.org/repos/asf/flex-asjs/diff/281c7786
>
>Branch: refeads/develop
>Commit: 281c778607522da2aeca24f8212d551687684ce0
>Parents: 9657c4e
>Author: Harbs <ha...@in-tools.com>
>Authored: Tue Mar 7 12:25:26 2017 +0200
>Committer: Harbs <ha...@in-tools.com>
>Committed: Tue Mar 7 12:25:26 2017 +0200
>
>----------------------------------------------------------------------
> frameworks/projects/Graphics/build.xml | 1 +
> .../Graphics/src/main/flex/GraphicsClasses.as | 9 +
> .../flex/graphics/utils/shaderClasses/Color.pbk | 101 +++++++++
> .../grahics/utils/shaderClasses/ColorBurn.pbk | 149 +++++++++++++
> .../utils/shrClasses/ColorBurnShader.as | 62 ++++++
> .../graphics/utils/shaderClasses/ColorDodge.pbk | 151 +++++++++++++
> .../utils/shaderClasses/ColorDodgeShader.as | 61 +++++
> .../graphics/utils/shaderClasses/ColorShader.as | 61 +++++
> .../graphics/utils/shaderClasses/Exclusion.pbk | 105 +++++++++
> .../utils/shaderClasses/ExclusionShader.as | 61 +++++
> .../flex/graphics/utils/shaderClasses/Hue.pbk | 216 ++++++++++++++++++
> .../graphics/utils/shaderClasses/HueShader.as | 61 +++++
> .../graphics/utils/shaderClasses/Luminosity.pbk | 103 +++++++++
> .../shaderClasses/LuminosityMaskFilter.pbk | 133 +++++++++++
> .../utils/shaderClasses/LuminosityMaskShader.as | 97 ++++++++
> .../utils/shaderClasses/LuminosityShader.as | 60 +++++
> .../graphics/utils/shaderClasses/Saturation.pbk | 222 +++++++++++++++++++
> .../utils/shaderClasses/SaturationShader.as | 60 +++++
> .../graphics/utils/shaderClasses/SoftLight.pbk | 199 +++++++++++++++++
> .../utils/shaderClasses/SoftLightShader.as | 60 +++++
> 20 files changed, 1972 insertions(+)
>---------------------------------------------------------------------
>
>
>http://git-wip-us.apachrg/repos/asf/flex-asjs/blob/281c7786/frameworks/
>projects/Graphics/build.xml
>----------------------------------------------------------------------
>diff --git a/frameworks/projects/Graphics/build.xml
>b/frameworks/projects/Graphics/build.xml
>index b47b813..01cbeb5 100644
>--- a/frameworks/projects/Graphics/build.xml
>+++ b/frameworks/projects/Graphics/build.xml
>@@ -83,6 +83,7 @@
> <arg value="+env.AIR_HOME=${env.AIR_HOME}" />
> <arg value="-define=COMPILE::SWF,true" />
> <arg value="-define=COMPILE::JS,false" />
>+ <arg
lue="-compiler.byte-array-embed-class=org.apache.flex.core.ByteArrayAsse
>t" />
> </compc>
> <copy file="${basedir}/target/${target.name}"
>tofile="${FLEXJS_HOME}/frameworks/libs/${target.name}" />
> </target>
>
>http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/281c7786/frameworks/
>projects/Graphics/src/main/flex/GraphicsClasses.as
>----------------------------------------------------------------------
>diff --git
>a/frameworks/projects/Graphics/src/main/flex/GraphicsClasses.as
>b/frameworks/projects/Graphics/src/main/flex/GraphicsClasses.as
>index 3b87a56..5836c9e 100644
>--- a/frameworks/projects/Graphics/src/main/flex/GraphicsClasses.as
>+++ b/frameworks/projects/Graphics/src/main/flex/GraphicsClasses.as
>@@ -41,6 +41,15 @@ internal class GraphicsClasses
> COMPILE::SWF
> {
> import org.apache.flex.graphics.utils.PathHelper; PathHelper;
>+ import org.apache.flex.graphics.utils.shaderClasses.ColorBurnShader;
>ColorBurnShader;
>+ import org.apache.flex.graphics.utils.shaderClasses.ColorDodgeShader;
>ColorDodgeShader;
>+ import org.apache.flex.graphics.utils.shaderClasses.ColorShader;
>ColorShader;
>+ import org.apache.flex.graphics.utils.shaderClasses.ExclusionShader;
>ExclusionShader;
>+ import org.apache.flex.graphics.utils.shaderClasses.HueShader;
>HueShader;
>+ import
>org.apache.flex.graphics.utils.shaderClasses.LuminosityMaskShader;
>LuminosityMaskShader;
>+ import org.apache.flex.graphics.utils.shaderClasses.LuminosityShader;
>LuminosityShader;
>+ import org.apach.flex.graphics.utils.shaderClasses.SaturationShader;
>SaturationShader;
>+ import org.apache.flex.graphics.utils.shaderClasses.SoftLightShader;
>SoftLightShader;
> }
> import org.apache.flex.graphics.QuadrticCurve; QuadraticCurve;
> import org.apache.flex.graphics.ICircle; ICircle;
>
>http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/281c7786/frameworks/
>projects/Graphics/src/main/flex/orgapache/flex/graphics/utils/shaderClass
>es/Color.pbk
>---------------------------------------------------------------------
>diff --git
>a/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/util
>s/shaderClasses/Color.pbk
>b/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/util
>s/shaderClasses/Color.pbk
>new file mode 100644
>index 0000000..daedc3f
>--- /dev/null
>+++
>b/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/util
>s/shaderClasses/Color.pbk
>@@-0,0 +1,101 @@
>+/////////////////////////////////////////////////////////////////////////
>///////
>+//
>+// Licensed to the Apache Software Foundation (ASF) under one or more
>+// contributor license agreements. See the NOTICE file distributed with
>+// this work for additional information regarding copyright ownership.
>+// The ASF licenses this file to You under the Apache License, Version
>2.0
>+// (the "License"); you may not use this file except in compliance with
>+// the License. You may obtain a copy of the License at
>+//
>+// http://www.apache.org/licenses/LICENSE-2.0
>+//
>+// Unless required by applicable law or agreed to in writing, software
>+// distributed uder the License is distributed on an "AS IS" BASIS,
>+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
>implied.
>+// See the License for the specific language governing permissions and
>+// limitations under the License.
>+//
>+/////////////////////////////////////////////////////////////////////////
>///////
>+
>+<languageVersion : 1.0;>
>+kernel Color
>+< namespace : "Flame";
>+ vendor :"Adobe";
>+ version : 1;
>+ description : "Color blend mode";
>+>
>+{
>+ input image4 dst;
>+ input image4 src;
>+ output pixel4 result;
>+
>+ // PB bytecode can't do functions, use macros to define common
>functions
>+ // gets the max number out of the three
>+ #define max3( x, y, z ) ( max((x), max((y), (z))) )
>+ // gets the min number out of the three
>+ #define min3( x, y,z ) ( min((x), min((y), (z))) )
>+
>+ // gets the max number out of th three elements in a vector
>+ #define max3v(C) ( max3((C.x), (C.y) (C.z)) )
>+ // gets the min number out of the three elements in a vectr
>+ #define min3v(C) ( min3((C.x), (C.y), (C.z)) )
>+
>+ // Sat - returns float, takes n a pixel3, or pixel4
>+ #define saturation(C) ( (max3((C.r), (C.g), (C.b) - min3((C.r),
>(C.g), (C.b))) )
>+
>+ // Luminance - returns floattakes in a pixel3, or pixel4
>+ #define luminance(C) ( (((C.r) * 0.3) + ((C.g) * 0.59) + ((C.b) *
>0.11)) )
>+
>+ void
>+ evaluatePixel()
>+ {
>+ pixel4 a = sampleNearest(dst,outCoord()); // cb
>+ pixel4 b = sampleNearest(src,outCoord()); // cs
>+
>+ // remove premultiplied (srcCP/srcA, dstCP/dstA)
>+ pixel3 cb = a.rgb;
>+ pixel3 cs = b.rgb;
>+ if (a. > 0.0) {
>+ cb.rgb = a.rgb / a.a;
>+ }
>+ if (b.a > 0.0) {
>+ cs.rgb = b.rgb / b.a;
>+ }
>+
>+ // dstA' = (1-srcA)*dstA + srcA
>+ result.a = (1.0-b.a)*a.a + b.a;
>+
>+ // adjustment -> adjustedcs
>+ float3 adjVec = (cb - cs);
>+ float adjustment = luminance(adjVec);
>+ float3 adjustedcs = cs + adjustment;
>+
>+ // Blend()
>+
>+ /* --------------------------------------------------------
>+ * void clipcolor(inout float3 color)
>+ * clips color.
>+ * nput and output float3 color_cl
>+ *
>+ * -------------------------------------------------------- */
>+ float3 color_cl = adjustedcs;
>+ float lum_cl = luminance(color_cl);
>+ float3 lumVec = float3(lum_cl, lum_cl, lum_cl);
>+ float mini = min3v(color_cl);
>+ float maxi = max3v(color_cl);
>+ if (mini < 0.0) {
>+ mini = lum_cl - mini;
>+ // max(..., 0.0000001) prevents divide by 0
>+ color_cl = lumVec + (color_cl - lumVec)*lum_cl/max(mini,
>0.0000001);
>+ }
>+ if (maxi > 1.0) {
>+ maxi = maxi - lum_cl;
>+ // max(..., 0.0000001) prevents divide by 0
>+ color_cl = lumVec + (color_cl - lumVec)*(1.0 -
>lum_cl)/max(maxi, 0.0000001);
>+ }
>+ // end clipcolor - result: color_cl ---------------------- //
>+
>+ // dstCP' = (1-srcA)*dstCP + (1-dstA)*srcCP +
>srcA*dstA*Blend(srcCP/srcA, dstCP/dstA)
>+ result.rgb = ((1.0-b.a)*a.rgb) + ((1.0-a.a)*b.rgb) +
>b.a*a.a*color_cl.rgb;
>+ }
>+}
>\ No newline at end of file
>
>htt://git-wip-us.apache.org/repos/asf/flex-asjs/blob/281c7786/frameworks/
>projects/Graphics/src/main/flex/org/apache/flex/graphics/utils/shaderClass
>es/ColorBurn.pbk
>----------------------------------------------------------------------
>diff --git
>a/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/util
>s/shaderClasses/ColorBurn.pbk
>b/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/util
>s/shaderClasses/ColorBurn.pbk
>new file mode 100644
>index 0000000..99445c2
>--- /dev/null
>+++
>b/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/util
>s/shaderClasses/ColorBurn.pbk
>@@ -0,0 +1,149 @@
>+/////////////////////////////////////////////////////////////////////////
>///////
>+//
>+// Licensed to the Apache Software Foundation (ASF) under one or more
>+// contributor license agreements. See the NOTICE file distributed with
>+// this work for additional information regarding copyright ownership.
>+// The ASF licenses this file to You under the Apache License, Version
>2.0
>+// (the "License"); you may not use this file except in compliance with
>+// the License. You may obtain a copy of the License at
>+//
>+// http://www.apache.org/licenses/LICENSE-2.0
>+//
>+// Unless required by applicable law or agreed to in writing, software
>+// distributed under the License is distributed on an "AS IS" BAIS,
>+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
>implied.
>+// See the License for the specific language governig permissions and
>+// limitations under the License.
>+//
>+/////////////////////////////////////////////////////////////////////////
>///////
>+
>+<languageVersion : 1.0;>
>+
>+kernel ColorBurn
>+
>+< namespace : "Flame";
>+
>+ vendor : "Adobe";
>+
>+ version : 1;
>+
>+ description : "ColorBurn blend mode";
>+
>+>
>+
>+{
>+
>+ input image4 dst;
>+
>+ input image4 src;
>+
>+ output pixel4 result;
>+
>+
>+
>+ void
>+
>+ evaluatePixel()
>+
>+ {
>+
>+ pixel4 a = sampleNearest(dst,outCoord()); //cb
>+
>+ pixel4 b = sampleNearest(src,outCoord()); //cs
>+
>+
>+
>+ // remove premultiplied (srcCP/srcA, dstCP/dstA)
>+
>+ pixel3 cb = a.rgb;
>+
>+ pixel3 cs = b.rgb;
>+
>+ if (a.a > 0.0) {
>+
>+ cb.rgb = a.rgb / a.a;
>+
>+ }
>+
>+ if (b.a > 0.0) {
>+
>+ cs.rgb = b.rgb / b.a;
>+
>+ }
>+
>+
>+
>+ // dstA' = (1-srcA)*dstA + srcA
>+
>+ result.a = (1.0-b.a)*a.a + b.a;
>+
>+
>+
>+ // temp for Blend(srcCP/srcA, dstCP/dstA)
>+
>+ pixel3 blendResult;
>+
>+
>+
>+ // = 1, if cb = 1 (*** this case is AE/PS and AGM only, not PDF
>spec)
>+
>+ // = 0, if (1 ??? cb) >= cs
>+
>+ // = (1 ??? cb) / cs, otherwise
>+
>+ if (cb.r == 1.0) {
>+
>+ blendResult.r = 1.0;
>+
>+ } else if ((1.0 - cb.r) >= cs.r) {
>+
>+ blendResult.r = 0.0;
>+
>+ } else {
>+
>+ blendResult.r = 1.0 - (1.0 - cb.r) / cs.r;
>+
>+ }
>+
>+
>+
>+ if (cb.g == 1.0) {
>+
>+ blendResult.g = 1.0;
>+
>+ } else f ((1.0 - cb.g) >= cs.g) {
>+
>+ blendResult.g = 0.0;
>+
>+ } else {
>+
>+ blendResult.g = 1.0 - (1.0 - cb.g) / cs.g;
>+
>+ }
>+
>+
>+
>+ if (cb.b == 1.0) {
>+
>+ blendResult.b = 1.0;
>+
>+ } else if ((1.0 - cb.b) >= cs.b) {
>+
>+ blendResult.b = 0.0;
>+
>+ } else {
>+
>+ blendResult.b = 1.0 - (1.0 - cb.b) / cs.b;
>+
>+ }
>+
>+
>+
>+ // dstCP' = (1-srcA)*dstCP + (1-dstA)*srcCP +
>srcA*dstA*Blend(srcCP/rcA, dstCP/dstA)
>+
>+ result.rgb = (1.0-b.a)*a.rgb + (1.0-a.a)*b.rgb +
>b.a*a.a*blendResult.rgb;
>+
>+ }
>+
>+}
>+
>
>http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/281c7786/frameworks/
>projects/Graphics/src/main/flex/org/apache/flex/graphics/utils/shaderClass
>es/ColorBurnShader.as
>----------------------------------------------------------------------
>diff --git
>a/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/util
>s/shaderClasses/ColorBurnShader.as
>b/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/util
>s/shaderClasses/ColorBurnShader.as
>new file mode 100644
>index 0000000..bb96659
>--- /dev/null
>+++
>b/frameworks/proects/Graphics/src/main/flex/org/apache/flex/graphics/util
>s/shaderClasses/ColorBurnShader.as
>@@ -0,0 +1,62 @@
>+/////////////////////////////////////////////////////////////////////////
>///////
>+//
>+// Licensed to the Apache Software Foundation (ASF) under one or more
>+// contributor license agreements. See the NOTICE file distributed with
>+// this work for additional information regarding copyright ownerhip.
>+// The ASF licenses this file to You under the Apache License, Version
>2.0
>+// (the "License"); you may not use this file except in compliance with
>+// the License. You may obtain a copy of the License at
>+//
>+// http://www.apache.org/licenses/LICENSE-2.0
>+//
>+// Unless required by applicable law or agreed to in writing, software
>+// distributed under the License is distributed on n "AS IS" BASIS,
>+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, eithr express or
>implied.
>+// See the License for the specific languagegoverning permissions and
>+// limitations under the License.
>+//
>+////////////////////////////////////////////////////////////////////////
>///////
>+
>+package orapache.flex.graphics.utils.shaderClasses
>+{
>+import flash.display.Shader
>+import org.apache.flex.core.ByteArrayAsset;
>+
>+
>+/**
>+ * Creas a blend shader that is equivalent to
>+ * the 'Color Burn' blend mode for RGB premultiplied colors available
>+ * in Adobe Creative Suite tools. This blend mode is not native to
>Flash,
>+ * but is available in tools like Adobe Illustrator and Adobe
>Photoshop.
>+ *
>+ * <p>The 'colorburn' blend mode can be set on Flex groups and graphic
>+ * elements and the visual appearance in tools like Adobe Ilustrator
>and
>+ * Adobe Photoshop will be mimicked through this blend shader.</p>
>+ *
>+ * @langversion 3.0
>+ * @playerversion Flash 10
>+ * @playerversion AIR 1.5
>+ * @productversion Flex 4
>+ *
>+ * @includeExample examples/ColorBurnShaderExample.mxml
>+ */
>+public class ColorBurnShader extends flash.display.Shader
>+{
>+ [Embed(source="ColorBurn.pbj", mimeType="application/octet-stream")]
>+ private static var ShaderClass:Class;
>+
>+ /**
>+ * Constructor.
>+ *
>+ * @langversion 3.0
>+ * @playerversion Flash 10
>+ * @playerversion AIR 1.5
>+ * @productversion Flex 4
>+ */
>+ public function ColorBurnShader()
>+ {
>+ super(new ShaderClass());
>+ }
>+
>+}
>+}
>
>http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/281c7786/frameworks/
>projects/Graphics/src/main/flex/org/apache/flex/graphics/utils/shaderClass
>es/ColorDodge.pbk
>----------------------------------------------------------------------
>diff --git
>a/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/util
>s/shaderClasses/ColorDodge.pbk
>b/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/util
>s/shaderClasses/ColorDodge.pbk
>new file mode 100644
>index 0000000..11d6ca2
>--- /dev/null
>+++
>b/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/util
>s/shaderClasses/ColorDodge.pbk
>@@ -0,0 +1,151 @@
>+/////////////////////////////////////////////////////////////////////////
>///////
>+//
>+// Licensed to the Apache Software Foundation (ASF) under one or more
>+// contributor license agreements. See the NOTICE file distributed with
>+// this work for additional information regarding copyright ownership.
>+// The ASF licenses this file to You under the Apache License, Version
>2.0
>+// (the "License"); you may not use this file except in compliance with
>+// the License. You may obtain a copy of the License at
>+//
>+// http://www.apache.org/licenses/LICENSE-2.0
>+//
>+// Unless required by applicable law or agreed to in writing, software
>+// distributed under the License is distributed on an "AS IS" BASIS,
>+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
>implied.
>+// See the License for the specific language governing permissions and
>+// limitations under the License.
>+//
>+/////////////////////////////////////////////////////////////////////////
>///////
>+
>+<languageVersion : 1.0;>
>+
>+kernel ColorDodge
>+
>+< namespace : "Flame";
>+
>+ vendor : "Adobe";
>+
>+ version : 1;
>+
>+ description : "ColorDodge blend mode";
>+
>+>
>+
>+{
>+
>+ input image4 dst;
>+
>+ input image4 src;
>+
>+ output pixel4 result;
>+
>+
>+
>+ void
>+
>+ evaluatePixel()
>+
>+ {
>+
>+ pixel4 a = sampleNearest(dst,outCoord()); // cb
>+
>+ pixel4 b = sampleNearest(src,outCoord()); // cs
>+
>+
>+
>+ // remove premultiplied (srcCP/srcA, dstCP/dstA)
>+
>+ pixel3 cb = a.rgb;
>+
>+ pixel3 cs = b.rgb;
>+
>+ if (a.a > 0.0) {
>+
>+ cb.rgb = a.rgb / a.a;
>+
>+ }
>+
>+ if (b.a > 0.0) {
>+
>+ cs.rgb = b.rgb / b.a;
>+
>+ }
>+
>+
>+
>+ // dstA' = (1-srcA)*dstA + srcA
>+
>+ result.a = (1.0-b.a)*a.a + b.a;
>+
>+
>+
>+ // temp for Blend(srcCP/srcA, dstCP/dstA)
>+
>+ pixel3 blendResult;
>+
>+
>+
>+ // = 0, if cb = 0 (*** this case is AE/PS and AGM only, not PDF
>spec)
>+
>+ // = 1, if cb >= (1 -cs)
>+
>+ // = cb / (1 -cs), otherwise
>+
>+
>+
>+ if (cb.r == 0.0) {
>+
>+ blendResult.r = 0.0;
>+
>+ } else if ( cb.r >= (1.0 - cs.r)) {
>+
>+ blendResult.r = 1.0;
>+
>+ } else {
>+
>+ blendResult.r = cb.r / (1.0 - cs.r);
>+
>+ }
>+
>+
>+
>+ if (cb.g == 0.0) {
>+
>+ blendResult.g = 0.0;
>+
>+ } else if ( cb.g >= (1.0 - cs.g)) {
>+
>+ blendResult.g = 1.0;
>+
>+ } else {
>+
>+ blendResult.g = cb.g / (1.0 - cs.g);
>+
>+ }
>+
>+
>+
>+ if (cb.b == 0.0) {
>+
>+ blendResult.b = 0.0;
>+
>+ } else if ( cb.b >= (1.0 - cs.b)) {
>+
>+ blendResult.b = 1.0;
>+
>+ } else {
>+
>+ blendResult.b = cb.b / (1.0 - cs.b);
>+
>+ }
>+
>+
>+
>+ // dstCP' = (1-srcA)*dstCP + (1-dstA)*srcCP +
>srcA*dstA*Blend(srcCP/srcA, dstCP/dstA)
>+
>+ result.rgb = (1.0-b.a)*a.rgb + (1.0-a.a)*b.rgb +
>b.a*a.a*blendResult.rgb;
>+
>+ }
>+
>+}
>+
>
>http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/281c7786/frameworks/
>projects/Graphics/src/main/flex/org/apache/flex/graphics/utils/shaderClass
>es/ColorDodgeShader.as
>----------------------------------------------------------------------
>diff --git
>a/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/util
>s/shaderClasses/ColorDodgeShader.as
>b/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/util
>s/shaderClasses/ColorDodgeShader.as
>new file mode 100644
>index 0000000..8d32620
>--- /dev/null
>+++
>b/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/util
>s/shaderClasses/ColorDodgeShader.as
>@@ -0,0 +1,61 @@
>+/////////////////////////////////////////////////////////////////////////
>///////
>+//
>+// Licensed to the Apache Software Foundation (ASF) under one or more
>+// contributor license agreements. See the NOTICE file distributed with
>+// this work for additional information regarding copyright ownership.
>+// The ASF licenses this file to You under the Apache License, Version
>2.0
>+// (the "License"); you may not use this file except in compliance with
>+// the License. You may obtain a copy of the License at
>+//
>+// http://www.apache.org/licenses/LICENSE-2.0
>+//
>+// Unless required by applicable law or agreed to in writing, software
>+// distributed under the License is distributed on an "AS IS" BASIS,
>+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
>implied.
>+// See the License for the specific language governing permissions and
>+// limitations under the License.
>+//
>+/////////////////////////////////////////////////////////////////////////
>///////
>+
>+package org.apache.flex.graphics.utils.shaderClasses
>+{
>+import flash.display.Shader;
>+import org.apache.flex.core.ByteArrayAsset;
>+
>+/**
>+ * Creates a blend shader that is equivalent to
>+ * the 'Color Dodge' blend mode for RGB premultiplied colors available
>+ * in Adobe Creative Suite tools. This blend mode is not native to
>Flash,
>+ * but is available in tools like Adobe Illustrator and Adobe
>Photoshop.
>+ *
>+ * <p>The 'colordodge' blend mode can be set on Flex groups and graphic
>
>+ * elements. The visual appearance in tools like Adobe Illustrator and
>+ * Adobe Photoshop will be mimicked through this blend shader.</p>
>+ *
>+ * @langversion 3.0
>+ * @playerversion Flash 10
>+ * @playerversion AIR 1.5
>+ * @productversion Flex 4
>+ *
>+ * @includeExample examples/ColorDodgeShaderExample.mxml
>+ */
>+public class ColorDodgeShader extends flash.display.Shader
>+{
>+ [Embed(source="ColorDodge.pbj", mimeType="application/octet-stream")]
>+ private static var ShaderClass:Class;
>+
>+ /**
>+ * Constructor.
>+ *
>+ * @langversion 3.0
>+ * @playerversion Flash 10
>+ * @playerversion AIR 1.5
>+ * @productversion Flex 4
>+ */
>+ public function ColorDodgeShader()
>+ {
>+ super(new ShaderClass());
>+ }
>+
>+}
>+}
>
>http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/281c7786/frameworks/
>projects/Graphics/src/main/flex/org/apache/flex/graphics/utils/shaderClass
>es/ColorShader.as
>----------------------------------------------------------------------
>diff --git
>a/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/util
>s/shaderClasses/ColorShader.as
>b/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/util
>s/shaderClasses/ColorShader.as
>new file mode 100644
>index 0000000..81d0607
>--- /dev/null
>+++
>b/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/util
>s/shaderClasses/ColorShader.as
>@@ -0,0 +1,61 @@
>+/////////////////////////////////////////////////////////////////////////
>///////
>+//
>+// Licensed to the Apache Software Foundation (ASF) under one or more
>+// contributor license agreements. See the NOTICE file distributed with
>+// this work for additional information regarding copyright ownership.
>+// The ASF licenses this file to You under the Apache License, Version
>2.0
>+// (the "License"); you may not use this file except in compliance with
>+// the License. You may obtain a copy of the License at
>+//
>+// http://www.apache.org/licenses/LICENSE-2.0
>+//
>+// Unless required by applicable law or agreed to in writing, software
>+// distributed under the License is distributed on an "AS IS" BASIS,
>+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
>implied.
>+// See the License for the specific language governing permissions and
>+// limitations under the License.
>+//
>+/////////////////////////////////////////////////////////////////////////
>///////
>+
>+package org.apache.flex.graphics.utils.shaderClasses
>+{
>+import flash.display.Shader;
>+import org.apache.flex.core.ByteArrayAsset;
>+
>+/**
>+ * The ColorShader class creates a blend shader that is equivalent to
>+ * the 'Color' blend mode for RGB premultiplied colors available
>+ * in Adobe Creative Suite tools. This blend mode is not native to
>Flash,
>+ * but is available in tools like Adobe Illustrator and Adobe
>Photoshop.
>+ *
>+ * The 'color' blend mode can be set on Flex groups and graphic
>+ * elements and the visual appearance in tools like Adobe Illustrator
>and
>+ * Adobe Photoshop will be mimicked through this blend shader.
>+ *
>+ * @langversion 3.0
>+ * @playerversion Flash 10
>+ * @playerversion AIR 1.5
>+ * @productversion Flex 4
>+ *
>+ * @includeExample examples/ColorShaderExample.mxml
>+ */
>+public class ColorShader extends flash.display.Shader
>+{
>+ [Embed(source="Color.pbj", mimeType="application/octet-stream")]
>+ private static var ShaderClass:Class;
>+
>+ /**
>+ * Constructor.
>+ *
>+ * @langversion 3.0
>+ * @playerversion Flash 10
>+ * @playerversion AIR 1.5
>+ * @productversion Flex 4
>+ */
>+ public function ColorShader()
>+ {
>+ super(new ShaderClass());
>+ }
>+
>+}
>+}
>
>http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/281c7786/frameworks/
>projects/Graphics/src/main/flex/org/apache/flex/graphics/utils/shaderClass
>es/Exclusion.pbk
>----------------------------------------------------------------------
>diff --git
>a/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/util
>s/shaderClasses/Exclusion.pbk
>b/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/util
>s/shaderClasses/Exclusion.pbk
>new file mode 100644
>index 0000000..d7fc369
>--- /dev/null
>+++
>b/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/util
>s/shaderClasses/Exclusion.pbk
>@@ -0,0 +1,105 @@
>+/////////////////////////////////////////////////////////////////////////
>///////
>+//
>+// Licensed to the Apache Software Foundation (ASF) under one or more
>+// contributor license agreements. See the NOTICE file distributed with
>+// this work for additional information regarding copyright ownership.
>+// The ASF licenses this file to You under the Apache License, Version
>2.0
>+// (the "License"); you may not use this file except in compliance with
>+// the License. You may obtain a copy of the License at
>+//
>+// http://www.apache.org/licenses/LICENSE-2.0
>+//
>+// Unless required by applicable law or agreed to in writing, software
>+// distributed under the License is distributed on an "AS IS" BASIS,
>+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
>implied.
>+// See the License for the specific language governing permissions and
>+// limitations under the License.
>+//
>+/////////////////////////////////////////////////////////////////////////
>///////
>+
>+<languageVersion : 1.0;>
>+
>+kernel Exclusion
>+
>+< namespace : "Flame";
>+
>+ vendor : "Adobe";
>+
>+ version : 1;
>+
>+ description : "Exclusion blend mode";
>+
>+>
>+
>+{
>+
>+ input image4 dst;
>+
>+ input image4 src;
>+
>+ output pixel4 result;
>+
>+
>+
>+ void
>+
>+ evaluatePixel()
>+
>+ {
>+
>+ pixel4 a = sampleNearest(dst,outCoord()); // cb
>+
>+ pixel4 b = sampleNearest(src,outCoord()); // cs
>+
>+
>+
>+ // remove premultiplied (srcCP/srcA, dstCP/dstA)
>+
>+ //pixel3 cb, cs;
>+
>+ pixel3 cb = a.rgb;
>+
>+ pixel3 cs = b.rgb;
>+
>+
>+
>+ if (a.a > 0.0) {
>+
>+ cb.rgb = a.rgb / a.a;
>+
>+ }
>+
>+ if (b.a > 0.0) {
>+
>+ cs.rgb = b.rgb / b.a;
>+
>+ }
>+
>+
>+
>+ // dstA' = (1-srcA)*dstA + srcA
>+
>+ result.a = (1.0-b.a)*a.a + b.a;
>+
>+
>+
>+ // temp for Blend(srcCP/srcA, dstCP/dstA)
>+
>+ float3 blendResult;
>+
>+
>+
>+ // cb + cs ??? 2*cs*cb
>+
>+ blendResult.rgb = cb.rgb + cs.rgb - 2.0*cs.rgb*cb.rgb;
>+
>+
>+
>+ // dstCP' = (1-srcA)*dstCP + (1-dstA)*srcCP +
>srcA*dstA*Blend(srcCP/srcA, dstCP/dstA)
>+
>+ result.rgb = ((1.0-b.a)*a.rgb) + ((1.0-a.a)*b.rgb) +
>b.a*a.a*blendResult.rgb;
>+
>+ }
>+
>+}
>+
>
>http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/281c7786/frameworks/
>projects/Graphics/src/main/flex/org/apache/flex/graphics/utils/shaderClass
>es/ExclusionShader.as
>----------------------------------------------------------------------
>diff --git
>a/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/util
>s/shaderClasses/ExclusionShader.as
>b/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/util
>s/shaderClasses/ExclusionShader.as
>new file mode 100644
>index 0000000..198a48d
>--- /dev/null
>+++
>b/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/util
>s/shaderClasses/ExclusionShader.as
>@@ -0,0 +1,61 @@
>+/////////////////////////////////////////////////////////////////////////
>///////
>+//
>+// Licensed to the Apache Software Foundation (ASF) under one or more
>+// contributor license agreements. See the NOTICE file distributed with
>+// this work for additional information regarding copyright ownership.
>+// The ASF licenses this file to You under the Apache License, Version
>2.0
>+// (the "License"); you may not use this file except in compliance with
>+// the License. You may obtain a copy of the License at
>+//
>+// http://www.apache.org/licenses/LICENSE-2.0
>+//
>+// Unless required by applicable law or agreed to in writing, software
>+// distributed under the License is distributed on an "AS IS" BASIS,
>+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
>implied.
>+// See the License for the specific language governing permissions and
>+// limitations under the License.
>+//
>+/////////////////////////////////////////////////////////////////////////
>///////
>+
>+package org.apache.flex.graphics.utils.shaderClasses
>+{
>+import flash.display.Shader;
>+import org.apache.flex.core.ByteArrayAsset;
>+
>+/**
>+ * Creates a blend shader that is equivalent to
>+ * the 'Exclusion' blend mode for RGB premultiplied colors available
>+ * in Adobe Creative Suite tools. This blend mode is not native to
>Flash,
>+ * but is available in tools like Adobe Illustrator and Adobe
>Photoshop.
>+ *
>+ * <p>The 'exclusion' blend mode can be set on Flex groups and graphic
>+ * elements. The visual appearance in tools like Adobe Illustrator and
>+ * Adobe Photoshop will be mimicked through this blend shader.</p>
>+ *
>+ * @langversion 3.0
>+ * @playerversion Flash 10
>+ * @playerversion AIR 1.5
>+ * @productversion Flex 4
>+ *
>+ * @includeExample examples/ExclusionShaderExample.mxml
>+ */
>+public class ExclusionShader extends flash.display.Shader
>+{
>+ [Embed(source="Exclusion.pbj", mimeType="application/octet-stream")]
>+ private static var ShaderClass:Class;
>+
>+ /**
>+ * Constructor.
>+ *
>+ * @langversion 3.0
>+ * @playerversion Flash 10
>+ * @playerversion AIR 1.5
>+ * @productversion Flex 4
>+ */
>+ public function ExclusionShader()
>+ {
>+ super(new ShaderClass());
>+ }
>+
>+}
>+}
>
>http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/281c7786/frameworks/
>projects/Graphics/src/main/flex/org/apache/flex/graphics/utils/shaderClass
>es/Hue.pbk
>----------------------------------------------------------------------
>diff --git
>a/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/util
>s/shaderClasses/Hue.pbk
>b/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/util
>s/shaderClasses/Hue.pbk
>new file mode 100644
>index 0000000..5ef71f6
>--- /dev/null
>+++
>b/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/util
>s/shaderClasses/Hue.pbk
>@@ -0,0 +1,216 @@
>+/////////////////////////////////////////////////////////////////////////
>///////
>+//
>+// Licensed to the Apache Software Foundation (ASF) under one or more
>+// contributor license agreements. See the NOTICE file distributed with
>+// this work for additional information regarding copyright ownership.
>+// The ASF licenses this file to You under the Apache License, Version
>2.0
>+// (the "License"); you may not use this file except in compliance with
>+// the License. You may obtain a copy of the License at
>+//
>+// http://www.apache.org/licenses/LICENSE-2.0
>+//
>+// Unless required by applicable law or agreed to in writing, software
>+// distributed under the License is distributed on an "AS IS" BASIS,
>+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
>implied.
>+// See the License for the specific language governing permissions and
>+// limitations under the License.
>+//
>+/////////////////////////////////////////////////////////////////////////
>///////
>+
>+<languageVersion : 1.0;>
>+kernel Hue
>+< namespace : "Flame";
>+ vendor : "Adobe";
>+ version : 1;
>+ description : "Hue blend mode";
>+>
>+{
>+ input image4 dst;
>+ input image4 src;
>+ output pixel4 result;
>+
>+ // PB bytecode can't do functions, use macros to define common
>functions
>+ // gets the max number out of the three
>+ #define max3( x, y, z ) ( max((x), max((y), (z))) )
>+ // gets the min number out of the three
>+ #define min3( x, y, z ) ( min((x), min((y), (z))) )
>+
>+ // gets the max number out of the three elements in a vector
>+ #define max3v(C) ( max3((C.x), (C.y), (C.z)) )
>+ // gets the min number out of the three elements in a vector
>+ #define min3v(C) ( min3((C.x), (C.y), (C.z)) )
>+
>+ // Sat - returns float, takes in a pixel3, or pixel4
>+ #define saturation(C) ( (max3((C.r), (C.g), (C.b)) - min3((C.r),
>(C.g), (C.b))) )
>+
>+ // Luminance - returns float, takes in a pixel3, or pixel4
>+ #define luminance(C) ( (((C.r) * 0.3) + ((C.g) * 0.59) + ((C.b) *
>0.11)) )
>+
>+ void
>+ evaluatePixel()
>+ {
>+ pixel4 a = sampleNearest(dst,outCoord()); // cb
>+ pixel4 b = sampleNearest(src,outCoord()); // cs
>+
>+ // remove premultiplied (srcCP/srcA, dstCP/dstA)
>+ pixel3 cb, cs;
>+ if (a.a > 0.0) {
>+ cb.rgb = a.rgb / a.a;
>+ }
>+ if (b.a > 0.0) {
>+ cs.rgb = b.rgb / b.a;
>+ }
>+
>+ // dstA' = (1-srcA)*dstA + srcA
>+ result.a = (1.0-b.a)*a.a + b.a;
>+
>+
>+ // setSat(cs, Sat(cb))
>+
>+ // setSat (setSatColor, sat) -> setSatResult
>+ /* --------------------------------------------------------
>+ * void setsaturation(inout float3 color, in float satVal)
>+ * makes color have the target saturation.
>+ * input and output of float3 color
>+ * input of the target saturation
>+ *
>+ * --------------------------------------------------------
>+ void setsatcomponents(inout float minComp, inout float midComp,
>inout float maxComp, in float satVal)
>+ {
>+ midComp -= minComp;
>+ maxComp -= minComp;
>+ minComp = 0.0;
>+ if (maxComp > 0.0) {
>+ // max(..., 0.0000001) prevents divide by 0
>+ midComp *= satVal/max(maxComp, 0.0000001);
>+ maxComp = satVal;
>+ }
>+ }
>+ */
>+
>+ float3 color = cs.rgb;
>+ float satVal = saturation(cb);
>+
>+ if (color.x <= color.y) {
>+ if (color.y <= color.z) {
>+ // x <= y <= z
>+ // setsatcomponents(color.x, color.y, color.z, satVal);
>+ // min, mid, max, val
>+
>+ color.y -= color.x;
>+ color.z -= color.x;
>+ color.x = 0.0;
>+ if (color.z > 0.0) {
>+ // max(..., 0.0000001) prevents divide by 0
>+ color.y *= satVal/max(color.z, 0.0000001);
>+ color.z = satVal;
>+ }
>+
>+ } else {
>+ if (color.x <= color.z) {
>+ // x <= z <= y
>+ // setsatcomponents(color.x, color.z, color.y,
>satVal);
>+ // min, mid, max, value
>+
>+ color.z -= color.x;
>+ color.y -= color.x;
>+ color.x = 0.0;
>+ if (color.y > 0.0) {
>+ // max(..., 0.0000001) prevents divide by 0
>+ color.z *= satVal/max(color.y, 0.0000001);
>+ color.y = satVal;
>+ }
>+ } else {
>+ // z <= x <= y
>+ // setsatcomponents(color.z, color.x, color.y,
>satVal);
>+ // min, mid, max, val
>+
>+ color.x -= color.z;
>+ color.y -= color.z;
>+ color.z = 0.0;
>+ if (color.y > 0.0) {
>+ // max(..., 0.0000001) prevents divide by 0
>+ color.x *= satVal/max(color.y, 0.0000001);
>+ color.y = satVal;
>+ }
>+ }
>+ }
>+ } else {
>+ if (color.x <= color.z) {
>+ // y <= x <= z
>+ // setsatcomponents(color.y, color.x, color.z, satVal);
>+
>+ color.x -= color.y;
>+ color.z -= color.y;
>+ color.y = 0.0;
>+ if (color.z > 0.0) {
>+ // max(..., 0.0000001) prevents divide by 0
>+ color.x *= satVal/max(color.z, 0.0000001);
>+ color.z = satVal;
>+ }
>+ } else {
>+ if (color.y <= color.z) {
>+ // y <= z <= x
>+ // setsatcomponents(color.y, color.z, color.x,
>satVal);
>+ // min, mid, max, val
>+
>+ color.z -= color.y;
>+ color.x -= color.y;
>+ color.y = 0.0;
>+ if (color.x > 0.0) {
>+ // max(..., 0.0000001) prevents divide by 0
>+ color.z *= satVal/max(color.x, 0.0000001);
>+ color.x = satVal;
>+ }
>+ } else {
>+ // z <= y <= x
>+ // setsatcomponents(color.z, color.y, color.x,
>satVal);
>+ // min, mid, max, val
>+
>+ color.y -= color.z;
>+ color.x -= color.z;
>+ color.z = 0.0;
>+ if (color.x > 0.0) {
>+ // max(..., 0.0000001) prevents divide by 0
>+ color.y *= satVal/max(color.x, 0.0000001);
>+ color.x = satVal;
>+ }
>+ }
>+ }
>+ }
>+ // end setSaturation - result: color ---------------------- //
>+
>+ // intermediate adjustment (setSatResult) -> adjustedcs
>+ float3 adjVec = (cb - color);
>+ float adjustment = luminance(adjVec);
>+ float3 adjustedcs = color + adjustment;
>+
>+ // ClipRGB(adjustedcs) -> blendResult
>+
>+ /* --------------------------------------------------------
>+ * void clipcolor(inout float3 color)
>+ * clips color.
>+ * input and output float3 color_cl
>+ *
>+ * -------------------------------------------------------- */
>+ float3 color_cl = adjustedcs;
>+ float lum_cl = luminance(color_cl);
>+ float3 lumVec = float3(lum_cl, lum_cl, lum_cl);
>+ float mini = min3v(color_cl);
>+ float maxi = max3v(color_cl);
>+ if (mini < 0.0) {
>+ mini = lum_cl - mini;
>+ // max(..., 0.0000001) prevents divide by 0
>+ color_cl = lumVec + (color_cl - lumVec)*lum_cl/max(mini,
>0.0000001);
>+ }
>+ if (maxi > 1.0) {
>+ maxi = maxi - lum_cl;
>+ // max(..., 0.0000001) prevents divide by 0
>+ color_cl = lumVec + (color_cl - lumVec)*(1.0 -
>lum_cl)/max(maxi, 0.0000001);
>+ }
>+ // end clipcolor - result: color_cl ---------------------- //
>+
>+ // dstCP' = (1-srcA)*dstCP + (1-dstA)*srcCP +
>srcA*dstA*Blend(srcCP/srcA, dstCP/dstA)
>+ result.rgb = ((1.0-b.a)*a.rgb) + ((1.0-a.a)*b.rgb) +
>b.a*a.a*color_cl.rgb;
>+ }
>+}
>
>http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/281c7786/frameworks/
>projects/Graphics/src/main/flex/org/apache/flex/graphics/utils/shaderClass
>es/HueShader.as
>----------------------------------------------------------------------
>diff --git
>a/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/util
>s/shaderClasses/HueShader.as
>b/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/util
>s/shaderClasses/HueShader.as
>new file mode 100644
>index 0000000..7c61804
>--- /dev/null
>+++
>b/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/util
>s/shaderClasses/HueShader.as
>@@ -0,0 +1,61 @@
>+/////////////////////////////////////////////////////////////////////////
>///////
>+//
>+// Licensed to the Apache Software Foundation (ASF) under one or more
>+// contributor license agreements. See the NOTICE file distributed with
>+// this work for additional information regarding copyright ownership.
>+// The ASF licenses this file to You under the Apache License, Version
>2.0
>+// (the "License"); you may not use this file except in compliance with
>+// the License. You may obtain a copy of the License at
>+//
>+// http://www.apache.org/licenses/LICENSE-2.0
>+//
>+// Unless required by applicable law or agreed to in writing, software
>+// distributed under the License is distributed on an "AS IS" BASIS,
>+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
>implied.
>+// See the License for the specific language governing permissions and
>+// limitations under the License.
>+//
>+/////////////////////////////////////////////////////////////////////////
>///////
>+
>+package org.apache.flex.graphics.utils.shaderClasses
>+{
>+import flash.display.Shader;
>+import org.apache.flex.core.ByteArrayAsset;
>+
>+/**
>+ * Creates a blend shader that is equivalent to
>+ * the 'Hue' blend mode for RGB premultiplied colors available
>+ * in Adobe Creative Suite tools. This blend mode is not native to
>Flash,
>+ * but is available in tools like Adobe Illustrator and Adobe
>Photoshop.
>+ *
>+ * <p>The 'hue' blend mode can be set on Flex groups and graphic
>+ * elements. The visual appearance in tools like Adobe Illustrator and
>+ * Adobe Photoshop will be mimicked through this blend shader.</p>
>+ *
>+ * @langversion 3.0
>+ * @playerversion Flash 10
>+ * @playerversion AIR 1.5
>+ * @productversion Flex 4
>+ *
>+ * @includeExample examples/HueShaderExample.mxml
>+ */
>+public class HueShader extends flash.display.Shader
>+{
>+ [Embed(source="Hue.pbj", mimeType="application/octet-stream")]
>+ private static var ShaderClass:Class;
>+
>+ /**
>+ * Constructor.
>+ *
>+ * @langversion 3.0
>+ * @playerversion Flash 10
>+ * @playerversion AIR 1.5
>+ * @productversion Flex 4
>+ */
>+ public function HueShader()
>+ {
>+ super(new ShaderClass());
>+ }
>+
>+}
>+}
>
>http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/281c7786/frameworks/
>projects/Graphics/src/main/flex/org/apache/flex/graphics/utils/shaderClass
>es/Luminosity.pbk
>----------------------------------------------------------------------
>diff --git
>a/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/util
>s/shaderClasses/Luminosity.pbk
>b/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/util
>s/shaderClasses/Luminosity.pbk
>new file mode 100644
>index 0000000..586f35d
>--- /dev/null
>+++
>b/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/util
>s/shaderClasses/Luminosity.pbk
>@@ -0,0 +1,103 @@
>+/////////////////////////////////////////////////////////////////////////
>///////
>+//
>+// Licensed to the Apache Software Foundation (ASF) under one or more
>+// contributor license agreements. See the NOTICE file distributed with
>+// this work for additional information regarding copyright ownership.
>+// The ASF licenses this file to You under the Apache License, Version
>2.0
>+// (the "License"); you may not use this file except in compliance with
>+// the License. You may obtain a copy of the License at
>+//
>+// http://www.apache.org/licenses/LICENSE-2.0
>+//
>+// Unless required by applicable law or agreed to in writing, software
>+// distributed under the License is distributed on an "AS IS" BASIS,
>+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
>implied.
>+// See the License for the specific language governing permissions and
>+// limitations under the License.
>+//
>+/////////////////////////////////////////////////////////////////////////
>///////
>+
>+<languageVersion : 1.0;>
>+kernel Luminosity
>+< namespace : "Flame";
>+ vendor : "Adobe";
>+ version : 1;
>+ description : "Luminosity blend mode";
>+>
>+{
>+ input image4 dst;
>+ input image4 src;
>+ output pixel4 result;
>+
>+ // PB bytecode can't do functions, use macros to define common
>functions
>+ // gets the max number out of the three
>+ #define max3( x, y, z ) ( max((x), max((y), (z))) )
>+ // gets the min number out of the three
>+ #define min3( x, y, z ) ( min((x), min((y), (z))) )
>+
>+ // gets the max number out of the three elements in a vector
>+ #define max3v(C) ( max3((C.x), (C.y), (C.z)) )
>+ // gets the min number out of the three elements in a vector
>+ #define min3v(C) ( min3((C.x), (C.y), (C.z)) )
>+
>+ // Sat - returns float, takes in a pixel3, or pixel4
>+ #define saturation(C) ( (max3((C.r), (C.g), (C.b)) - min3((C.r),
>(C.g), (C.b))) )
>+
>+ // Luminance - returns float, takes in a pixel3, or pixel4
>+ #define luminance(C) ( (((C.r) * 0.3) + ((C.g) * 0.59) + ((C.b) *
>0.11)) )
>+
>+ void
>+ evaluatePixel()
>+ {
>+ pixel4 a = sampleNearest(dst,outCoord()); // cb
>+ pixel4 b = sampleNearest(src,outCoord()); // cs
>+
>+ // remove premultiplied (srcCP/srcA, dstCP/dstA)
>+ pixel3 cb = a.rgb;
>+ pixel3 cs = b.rgb;
>+ if (a.a > 0.0) {
>+ cb.rgb = a.rgb / a.a;
>+ }
>+ if (b.a > 0.0) {
>+ cs.rgb = b.rgb / b.a;
>+ }
>+
>+ // dstA' = (1-srcA)*dstA + srcA
>+ result.a = (1.0-b.a)*a.a + b.a;
>+
>+ // adjustment
>+ // color = color + lum_cb - luminance(color);
>+ // dstColorOld - dstColor
>+ float3 adjVec = cs.rgb - cb.rgb;
>+ float adjustment = luminance(adjVec);
>+ float3 adjustedColor = cb + adjustment;
>+
>+ // ClipRGB(adjustedColor) -> color_cl
>+
>+ /* --------------------------------------------------------
>+ * void clipcolor(inout float3 color)
>+ * clips color.
>+ * input and output float3 color_cl
>+ *
>+ * -------------------------------------------------------- */
>+ float3 color_cl = adjustedColor;
>+ float lum_cl = luminance(color_cl);
>+ float3 lumVec = float3(lum_cl, lum_cl, lum_cl);
>+ float mini = min3v(color_cl);
>+ float maxi = max3v(color_cl);
>+ if (mini < 0.0) {
>+ mini = lum_cl - mini;
>+ // max(..., 0.0000001) prevents divide by 0
>+ color_cl = lumVec + (color_cl - lumVec)*lum_cl/max(mini,
>0.0000001);
>+ }
>+ if (maxi > 1.0) {
>+ maxi = maxi - lum_cl;
>+ // max(..., 0.0000001) prevents divide by 0
>+ color_cl = lumVec + (color_cl - lumVec)*(1.0 -
>lum_cl)/max(maxi, 0.0000001);
>+ }
>+ // end clipcolor - result: color_cl ---------------------- //
>+
>+ // dstCP' = (1-srcA)*dstCP + (1-dstA)*srcCP +
>srcA*dstA*Blend(srcCP/srcA, dstCP/dstA)
>+ result.rgb = ((1.0-b.a)*a.rgb) + ((1.0-a.a)*b.rgb) +
>b.a*a.a*color_cl.rgb;
>+ }
>+}
>
>http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/281c7786/frameworks/
>projects/Graphics/src/main/flex/org/apache/flex/graphics/utils/shaderClass
>es/LuminosityMaskFilter.pbk
>----------------------------------------------------------------------
>diff --git
>a/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/util
>s/shaderClasses/LuminosityMaskFilter.pbk
>b/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/util
>s/shaderClasses/LuminosityMaskFilter.pbk
>new file mode 100644
>index 0000000..10757a6
>--- /dev/null
>+++
>b/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/util
>s/shaderClasses/LuminosityMaskFilter.pbk
>@@ -0,0 +1,133 @@
>+/////////////////////////////////////////////////////////////////////////
>///////
>+//
>+// Licensed to the Apache Software Foundation (ASF) under one or more
>+// contributor license agreements. See the NOTICE file distributed with
>+// this work for additional information regarding copyright ownership.
>+// The ASF licenses this file to You under the Apache License, Version
>2.0
>+// (the "License"); you may not use this file except in compliance with
>+// the License. You may obtain a copy of the License at
>+//
>+// http://www.apache.org/licenses/LICENSE-2.0
>+//
>+// Unless required by applicable law or agreed to in writing, software
>+// distributed under the License is distributed on an "AS IS" BASIS,
>+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
>implied.
>+// See the License for the specific language governing permissions and
>+// limitations under the License.
>+//
>+/////////////////////////////////////////////////////////////////////////
>///////
>+
>+<languageVersion : 1.0;>
>+
>+kernel LuminosityMaskFilter
>+
>+< namespace : "Flame";
>+
>+ vendor : "Adobe";
>+
>+ version : 0;
>+
>+ description : "Luminosity Mask filter - Flex SDK";
>+
>+>
>+
>+{
>+
>+ parameter int mode <
>+
>+ minValue:int(0);
>+
>+ maxValue:int(3);
>+
>+ defaultValue:int(0);
>+
>+ >;
>+
>+
>+
>+ input image4 mask;
>+
>+ output pixel4 result;
>+
>+
>+
>+ void
>+
>+ evaluatePixel()
>+
>+ {
>+
>+ result = sampleNearest(mask, outCoord());
>+
>+
>+
>+ // AI Luminosity mask calculation
>+
>+ // input is artwork mask argb
>+
>+ // Flex will only use alpha channel in an "alpha" mask
>+
>+ // calculate new alpha channel using AI luminosity calculation
>+
>+
>+
>+ // invert option is mode bit 1
>+
>+ // clip option is mode bit 2
>+
>+
>+
>+ // if (clip != invert) background = 0 else background = 1
>+
>+ // luminosity = 0.3*red + 0.59*green + 0.11*blue
>+
>+ // output alpha = alpha*luminosity + (1-alpha)*background;
>+
>+ // if (invert) output alpha = 1 - output alpha
>+
>+
>+
>+ // calculate alpha*luminosity for result argb
>+
>+ // in flash, the mask artwork is premultiplied
>+
>+ // so we use luminosity and not alpha*luminosity
>+
>+ float alphaLum = (0.3 * result.r) + (0.59 * result.g) + (0.11 *
>result.b);
>+
>+
>+
>+ // mode 0 - clip 0, invert 0, background 1 = alpha*luminosity +
>(1-alpha)*1
>+
>+ if (mode == 0)
>+
>+ result.a = 1.0 - result.a + alphaLum;
>+
>+
>+
>+ // mode 1 - clip 0, invert 1, background 0 = 1 -
>(alpha*luminosity + (1-alpha)*0)
>+
>+ if (mode == 1)
>+
>+ result.a = 1.0 - alphaLum;
>+
>+
>+
>+ // mode 2 - clip 1, invert 0, background 0 = alpha*luminosity +
>(1-alpha)*0
>+
>+ if (mode == 2)
>+
>+ result.a = alphaLum;
>+
>+
>+
>+ // mode 3 - clip 1, invert 1, background 1 = 1 -
>(alpha*luminosity + (1-alpha)*1)
>+
>+ if (mode == 3)
>+
>+ result.a = result.a - alphaLum;
>+
>+ }
>+
>+}
>+
>
>http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/281c7786/frameworks/
>projects/Graphics/src/main/flex/org/apache/flex/graphics/utils/shaderClass
>es/LuminosityMaskShader.as
>----------------------------------------------------------------------
>diff --git
>a/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/util
>s/shaderClasses/LuminosityMaskShader.as
>b/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/util
>s/shaderClasses/LuminosityMaskShader.as
>new file mode 100644
>index 0000000..dec94ed
>--- /dev/null
>+++
>b/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/util
>s/shaderClasses/LuminosityMaskShader.as
>@@ -0,0 +1,97 @@
>+/////////////////////////////////////////////////////////////////////////
>///////
>+//
>+// Licensed to the Apache Software Foundation (ASF) under one or more
>+// contributor license agreements. See the NOTICE file distributed with
>+// this work for additional information regarding copyright ownership.
>+// The ASF licenses this file to You under the Apache License, Version
>2.0
>+// (the "License"); you may not use this file except in compliance with
>+// the License. You may obtain a copy of the License at
>+//
>+// http://www.apache.org/licenses/LICENSE-2.0
>+//
>+// Unless required by applicable law or agreed to in writing, software
>+// distributed under the License is distributed on an "AS IS" BASIS,
>+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
>implied.
>+// See the License for the specific language governing permissions and
>+// limitations under the License.
>+//
>+/////////////////////////////////////////////////////////////////////////
>///////
>+
>+package org.apache.flex.graphics.utils.shaderClasses
>+{
>+import flash.display.Shader;
>+import org.apache.flex.core.ByteArrayAsset;
>+
>+/**
>+ * Creates a blend shader that is equivalent
>+ * to the luminosity masking option (also known as soft masking)
>available
>+ * in Adobe Creative Suite tools. This mask type is not native to
>Flash,
>+ * but is available in tools like Adobe Illustrator and Adobe
>Photoshop.
>+ *
>+ * <p>A luminosity mask type can be set on Flex groups and graphic
>+ * elements. The visual appearance in tools like Adobe Illustrator and
>+ * Adobe Photoshop will be mimicked through this blend shader.</p>
>+ *
>+ * @see spark.primitives.supportClasses.GraphicElement#maskType
>+ * @see spark.components.supportClasses.GroupBase#maskType
>+ *
>+ * @langversion 3.0
>+ * @playerversion Flash 10
>+ * @playerversion AIR 1.5
>+ * @productversion Flex 4
>+ *
>+ * @includeExample examples/LuminosityMaskShaderExample.mxml
>+ */
>+
>+public class LuminosityMaskShader extends Shader
>+{
>+ [Embed(source="LuminosityMaskFilter.pbj",
>mimeType="application/octet-stream")]
>+ private static var ShaderClass:Class;
>+
>+ /**
>+ * Constructor.
>+ *
>+ * @langversion 3.0
>+ * @playerversion Flash 10
>+ * @playerversion AIR 1.5
>+ * @productversion Flex 4
>+ */
>+ public function LuminosityMaskShader()
>+ {
>+ super(new ShaderClass());
>+ }
>+
>+ /**
>+ * A convenience field that takes into account whether
>luminosityClip and/or
>+ * luminosityInvert are on or off.
>+ *
>+ * <ul>
>+ * <li>mode 0 = luminosityClip off, luminosityInvert off</li>
>+ * <li>mode 1 = luminosityClip off, luminosityInvert on</li>
>+ * <li>mode 2 = luminosityClip on, luminosityInvert off</li>
>+ * <li>mode 3 = luminosityClip on, luminosityInvert on </li>
>+ * </ul>
>+ *
>+ * @see
>spark.primitives.supportClasses.GraphicElement#luminosityClip
>+ * @see
>spark.primitives.supportClasses.GraphicElement#luminosityInvert
>+ * @see spark.components.supportClasses.GroupBase#luminosityClip
>+ * @see spark.components.supportClasses.GroupBase#luminosityInvert
>+ *
>+ * @langversion 3.0
>+ * @playerversion Flash 10
>+ * @playerversion AIR 1.5
>+ * @productversion Flex 4
>+ */
>+ public function get mode():int
>+ {
>+ return this.data.mode.value;
>+ }
>+
>+ public function set mode(v:int):void
>+ {
>+ if (mode ==-1)
>+ return;
>+ this.data.mode.value=[v];
>+ }
>+}
>+}
>
>http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/281c7786/frameworks/
>projects/Graphics/src/main/flex/org/apache/flex/graphics/utils/shaderClass
>es/LuminosityShader.as
>----------------------------------------------------------------------
>diff --git
>a/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/util
>s/shaderClasses/LuminosityShader.as
>b/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/util
>s/shaderClasses/LuminosityShader.as
>new file mode 100644
>index 0000000..cdf9a25
>--- /dev/null
>+++
>b/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/util
>s/shaderClasses/LuminosityShader.as
>@@ -0,0 +1,60 @@
>+/////////////////////////////////////////////////////////////////////////
>///////
>+//
>+// Licensed to the Apache Software Foundation (ASF) under one or more
>+// contributor license agreements. See the NOTICE file distributed with
>+// this work for additional information regarding copyright ownership.
>+// The ASF licenses this file to You under the Apache License, Version
>2.0
>+// (the "License"); you may not use this file except in compliance with
>+// the License. You may obtain a copy of the License at
>+//
>+// http://www.apache.org/licenses/LICENSE-2.0
>+//
>+// Unless required by applicable law or agreed to in writing, software
>+// distributed under the License is distributed on an "AS IS" BASIS,
>+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
>implied.
>+// See the License for the specific language governing permissions and
>+// limitations under the License.
>+//
>+/////////////////////////////////////////////////////////////////////////
>///////
>+
>+package org.apache.flex.graphics.utils.shaderClasses
>+{
>+import flash.display.Shader;
>+import org.apache.flex.core.ByteArrayAsset;
>+
>+/**
>+ * Creates a blend shader that is equivalent to
>+ * the 'Luminosity' blend mode for RGB premultiplied colors available
>+ * in Adobe Creative Suite tools. This blend mode is not native to
>Flash,
>+ * but is available in tools like Adobe Illustrator and Adobe
>Photoshop.
>+ *
>+ * <p>The 'luminosity' blend mode can be set on Flex groups and graphic
>
>+ * elements. The visual appearance in tools like Adobe Illustrator and
>+ * Adobe Photoshop will be mimicked through this blend shader.</p>
>+ *
>+ * @langversion 3.0
>+ * @playerversion Flash 10
>+ * @playerversion AIR 1.5
>+ * @productversion Flex 4
>+ *
>+ * @includeExample examples/LuminosityShaderExample.mxml
>+ */
>+public class LuminosityShader extends flash.display.Shader
>+{
>+ [Embed(source="Luminosity.pbj", mimeType="application/octet-stream")]
>+ private static var ShaderClass:Class;
>+
>+ /**
>+ * Constructor.
>+ *
>+ * @langversion 3.0
>+ * @playerversion Flash 10
>+ * @playerversion AIR 1.5
>+ * @productversion Flex 4
>+ */
>+ public function LuminosityShader()
>+ {
>+ super(new ShaderClass());
>+ }
>+}
>+}
>
>http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/281c7786/frameworks/
>projects/Graphics/src/main/flex/org/apache/flex/graphics/utils/shaderClass
>es/Saturation.pbk
>----------------------------------------------------------------------
>diff --git
>a/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/util
>s/shaderClasses/Saturation.pbk
>b/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/util
>s/shaderClasses/Saturation.pbk
>new file mode 100644
>index 0000000..e9d3866
>--- /dev/null
>+++
>b/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/util
>s/shaderClasses/Saturation.pbk
>@@ -0,0 +1,222 @@
>+/////////////////////////////////////////////////////////////////////////
>///////
>+//
>+// Licensed to the Apache Software Foundation (ASF) under one or more
>+// contributor license agreements. See the NOTICE file distributed with
>+// this work for additional information regarding copyright ownership.
>+// The ASF licenses this file to You under the Apache License, Version
>2.0
>+// (the "License"); you may not use this file except in compliance with
>+// the License. You may obtain a copy of the License at
>+//
>+// http://www.apache.org/licenses/LICENSE-2.0
>+//
>+// Unless required by applicable law or agreed to in writing, software
>+// distributed under the License is distributed on an "AS IS" BASIS,
>+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
>implied.
>+// See the License for the specific language governing permissions and
>+// limitations under the License.
>+//
>+/////////////////////////////////////////////////////////////////////////
>///////
>+
>+<languageVersion : 1.0;>
>+kernel Saturation
>+< namespace : "Flame";
>+ vendor : "Adobe";
>+ version : 1;
>+ description : "Saturation blend mode";
>+>
>+{
>+ input image4 dst;
>+ input image4 src;
>+ output pixel4 result;
>+
>+ // PB bytecode can't do functions, use macros to define common
>functions
>+ // gets the max number out of the three
>+ #define max3( x, y, z ) ( max((x), max((y), (z))) )
>+ // gets the min number out of the three
>+ #define min3( x, y, z ) ( min((x), min((y), (z))) )
>+
>+ // gets the max number out of the three elements in a vector
>+ #define max3v(C) ( max3((C.x), (C.y), (C.z)) )
>+ // gets the min number out of the three elements in a vector
>+ #define min3v(C) ( min3((C.x), (C.y), (C.z)) )
>+
>+ // Sat - returns float, takes in a pixel3, or pixel4
>+ #define saturation(C) ( (max3((C.r), (C.g), (C.b)) - min3((C.r),
>(C.g), (C.b))) )
>+
>+ // Luminance - returns float, takes in a pixel3, or pixel4
>+ #define luminance(C) ( (((C.r) * 0.3) + ((C.g) * 0.59) + ((C.b) *
>0.11)) )
>+
>+ void
>+ evaluatePixel()
>+ {
>+ pixel4 a = sampleNearest(dst,outCoord()); // cb
>+ pixel4 b = sampleNearest(src,outCoord()); // cs
>+
>+ // remove premultiplied (srcCP/srcA, dstCP/dstA)
>+ pixel3 cb = a.rgb;
>+ pixel3 cs = b.rgb;
>+ if (a.a > 0.0) {
>+ cb.rgb = a.rgb / a.a;
>+ }
>+ if (b.a > 0.0) {
>+ cs.rgb = b.rgb / b.a;
>+ }
>+
>+ // dstA' = (1-srcA)*dstA + srcA
>+ result.a = (1.0-b.a)*a.a + b.a;
>+
>+ // record old version of cb
>+ //float3 old_cb.rgb = cb.rgb;
>+
>+ // SetSat(cb, Sat(cs))
>+
>+ // setSat (setSatColor, sat) -> setSatResult
>+ /* --------------------------------------------------------
>+ * void setsaturation(inout float3 color, in float satVal)
>+ * makes color have the target saturation.
>+ * input and output of float3 color
>+ * input of the target saturation
>+ *
>+ * --------------------------------------------------------
>+ void setsatcomponents(inout float minComp, inout float midComp,
>inout float maxComp, in float satVal)
>+ {
>+ midComp -= minComp;
>+ maxComp -= minComp;
>+ minComp = 0.0;
>+ if (maxComp > 0.0) {
>+ // max(..., 0.0000001) prevents divide by 0
>+ midComp *= satVal/max(maxComp, 0.0000001);
>+ maxComp = satVal;
>+ }
>+ }
>+ */
>+
>+ float3 color = cb.rgb;
>+ float satVal = saturation(cs);
>+
>+ if (color.x <= color.y) {
>+ if (color.y <= color.z) {
>+ // x <= y <= z
>+ // setsatcomponents(color.x, color.y, color.z, satVal);
>+ // min, mid, max, val
>+
>+ color.y -= color.x;
>+ color.z -= color.x;
>+ color.x = 0.0;
>+ if (color.z > 0.0) {
>+ // max(..., 0.0000001) prevents divide by 0
>+ color.y *= satVal/max(color.z, 0.0000001);
>+ color.z = satVal;
>+ }
>+
>+ } else {
>+ if (color.x <= color.z) {
>+ // x <= z <= y
>+ // setsatcomponents(color.x, color.z, color.y,
>satVal);
>+ // min, mid, max, value
>+
>+ color.z -= color.x;
>+ color.y -= color.x;
>+ color.x = 0.0;
>+ if (color.y > 0.0) {
>+ // max(..., 0.0000001) prevents divide by 0
>+ color.z *= satVal/max(color.y, 0.0000001);
>+ color.y = satVal;
>+ }
>+ } else {
>+ // z <= x <= y
>+ // setsatcomponents(color.z, color.x, color.y,
>satVal);
>+ // min, mid, max, val
>+
>+ color.x -= color.z;
>+ color.y -= color.z;
>+ color.z = 0.0;
>+ if (color.y > 0.0) {
>+ // max(..., 0.0000001) prevents divide by 0
>+ color.x *= satVal/max(color.y, 0.0000001);
>+ color.y = satVal;
>+ }
>+ }
>+ }
>+ } else {
>+ if (color.x <= color.z) {
>+ // y <= x <= z
>+ // setsatcomponents(color.y, color.x, color.z, satVal);
>+
>+ color.x -= color.y;
>+ color.z -= color.y;
>+ color.y = 0.0;
>+ if (color.z > 0.0) {
>+ // max(..., 0.0000001) prevents divide by 0
>+ color.x *= satVal/max(color.z, 0.0000001);
>+ color.z = satVal;
>+ }
>+ } else {
>+ if (color.y <= color.z) {
>+ // y <= z <= x
>+ // setsatcomponents(color.y, color.z, color.x,
>satVal);
>+ // min, mid, max, val
>+
>+ color.z -= color.y;
>+ color.x -= color.y;
>+ color.y = 0.0;
>+ if (color.x > 0.0) {
>+ // max(..., 0.0000001) prevents divide by 0
>+ color.z *= satVal/max(color.x, 0.0000001);
>+ color.x = satVal;
>+ }
>+ } else {
>+ // z <= y <= x
>+ // setsatcomponents(color.z, color.y, color.x,
>satVal);
>+ // min, mid, max, val
>+
>+ color.y -= color.z;
>+ color.x -= color.z;
>+ color.z = 0.0;
>+ if (color.x > 0.0) {
>+ // max(..., 0.0000001) prevents divide by 0
>+ color.y *= satVal/max(color.x, 0.0000001);
>+ color.x = satVal;
>+ }
>+ }
>+ }
>+ }
>+ // end setSaturation - result: color ---------------------- //
>+
>+ // adjustment
>+ //color = color + lum_cb - luminance(color);
>+ //dstColorOld - dstColor
>+ float3 adjVec = cb.rgb - color.rgb;
>+ float adjustment = luminance(adjVec);
>+ float3 adjustedColor = color + adjustment;
>+
>+ // ClipRGB(adjustedColor) -> color_cl
>+
>+ /* --------------------------------------------------------
>+ * void clipcolor(inout float3 color)
>+ * clips color.
>+ * input and output float3 color_cl
>+ *
>+ * -------------------------------------------------------- */
>+ float3 color_cl = adjustedColor;
>+ float lum_cl = luminance(color_cl);
>+ float3 lumVec = float3(lum_cl, lum_cl, lum_cl);
>+ float mini = min3v(color_cl);
>+ float maxi = max3v(color_cl);
>+ if (mini < 0.0) {
>+ mini = lum_cl - mini;
>+ // max(..., 0.0000001) prevents divide by 0
>+ color_cl = lumVec + (color_cl - lumVec)*lum_cl/max(mini,
>0.0000001);
>+ }
>+ if (maxi > 1.0) {
>+ maxi = maxi - lum_cl;
>+ // max(..., 0.0000001) prevents divide by 0
>+ color_cl = lumVec + (color_cl - lumVec)*(1.0 -
>lum_cl)/max(maxi, 0.0000001);
>+ }
>+ // end clipcolor - result: color_cl ---------------------- //
>+
>+
>+ // dstCP' = (1-srcA)*dstCP + (1-dstA)*srcCP +
>srcA*dstA*Blend(srcCP/srcA, dstCP/dstA)
>+ result .rgb = ((1.0-b.a)*a.rgb) + ((1.0-a.a)*b.rgb) +
>b.a*a.a*color_cl.rgb;
>+ }
>+}
>
>http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/281c7786/frameworks/
>projects/Graphics/src/main/flex/org/apache/flex/graphics/utils/shaderClass
>es/SaturationShader.as
>----------------------------------------------------------------------
>diff --git
>a/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/util
>s/shaderClasses/SaturationShader.as
>b/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/util
>s/shaderClasses/SaturationShader.as
>new file mode 100644
>index 0000000..02646ae
>--- /dev/null
>+++
>b/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/util
>s/shaderClasses/SaturationShader.as
>@@ -0,0 +1,60 @@
>+/////////////////////////////////////////////////////////////////////////
>///////
>+//
>+// Licensed to the Apache Software Foundation (ASF) under one or more
>+// contributor license agreements. See the NOTICE file distributed with
>+// this work for additional information regarding copyright ownership.
>+// The ASF licenses this file to You under the Apache License, Version
>2.0
>+// (the "License"); you may not use this file except in compliance with
>+// the License. You may obtain a copy of the License at
>+//
>+// http://www.apache.org/licenses/LICENSE-2.0
>+//
>+// Unless required by applicable law or agreed to in writing, software
>+// distributed under the License is distributed on an "AS IS" BASIS,
>+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
>implied.
>+// See the License for the specific language governing permissions and
>+// limitations under the License.
>+//
>+/////////////////////////////////////////////////////////////////////////
>///////
>+
>+package org.apache.flex.graphics.utils.shaderClasses
>+{
>+import flash.display.Shader;
>+import org.apache.flex.core.ByteArrayAsset;
>+
>+/**
>+ * Creates a blend shader that is equivalent to
>+ * the 'Saturation' blend mode for RGB premultiplied colors available
>+ * in Adobe Creative Suite tools. This blend mode is not native to
>Flash,
>+ * but is available in tools like Adobe Illustrator and Adobe
>Photoshop.
>+ *
>+ * <p>The 'saturation' blend mode can be set on Flex groups and graphic
>
>+ * elements. The visual appearance in tools like Adobe Illustrator and
>+ * Adobe Photoshop will be mimicked through this blend shader.</p>
>+ *
>+ * @langversion 3.0
>+ * @playerversion Flash 10
>+ * @playerversion AIR 1.5
>+ * @productversion Flex 4
>+ *
>+ * @includeExample examples/SaturationShaderExample.mxml
>+ */
>+public class SaturationShader extends flash.display.Shader
>+{
>+ [Embed(source="Saturation.pbj", mimeType="application/octet-stream")]
>+ private static var ShaderClass:Class;
>+
>+ /**
>+ * Constructor.
>+ *
>+ * @langversion 3.0
>+ * @playerversion Flash 10
>+ * @playerversion AIR 1.5
>+ * @productversion Flex 4
>+ */
>+ public function SaturationShader()
>+ {
>+ super(new ShaderClass());
>+ }
>+}
>+}
>
>http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/281c7786/frameworks/
>projects/Graphics/src/main/flex/org/apache/flex/graphics/utils/shaderClass
>es/SoftLight.pbk
>----------------------------------------------------------------------
>diff --git
>a/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/util
>s/shaderClasses/SoftLight.pbk
>b/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/util
>s/shaderClasses/SoftLight.pbk
>new file mode 100644
>index 0000000..e98735a
>--- /dev/null
>+++
>b/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/util
>s/shaderClasses/SoftLight.pbk
>@@ -0,0 +1,199 @@
>+/////////////////////////////////////////////////////////////////////////
>///////
>+//
>+// Licensed to the Apache Software Foundation (ASF) under one or more
>+// contributor license agreements. See the NOTICE file distributed with
>+// this work for additional information regarding copyright ownership.
>+// The ASF licenses this file to You under the Apache License, Version
>2.0
>+// (the "License"); you may not use this file except in compliance with
>+// the License. You may obtain a copy of the License at
>+//
>+// http://www.apache.org/licenses/LICENSE-2.0
>+//
>+// Unless required by applicable law or agreed to in writing, software
>+// distributed under the License is distributed on an "AS IS" BASIS,
>+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
>implied.
>+// See the License for the specific language governing permissions and
>+// limitations under the License.
>+//
>+/////////////////////////////////////////////////////////////////////////
>///////
>+
>+<languageVersion : 1.0;>
>+
>+kernel SoftLight
>+
>+< namespace : "Flame";
>+
>+ vendor : "Adobe";
>+
>+ version : 1;
>+
>+ description : "SoftLight blend mode";
>+
>+>
>+
>+{
>+
>+ input image4 dst;
>+
>+ input image4 src;
>+
>+ output pixel4 result;
>+
>+
>+
>+ void
>+
>+ evaluatePixel()
>+
>+ {
>+
>+ pixel4 a = sampleNearest(dst,outCoord()); // cb
>+
>+ pixel4 b = sampleNearest(src,outCoord()); // cs
>+
>+
>+
>+ // remove premultiplied (srcCP/srcA, dstCP/dstA)
>+
>+ pixel3 cb = a.rgb;
>+
>+ pixel3 cs = b.rgb;
>+
>+ if (a.a > 0.0) {
>+
>+ cb.rgb = a.rgb / a.a;
>+
>+ }
>+
>+ if (b.a > 0.0) {
>+
>+ cs.rgb = b.rgb / b.a;
>+
>+ }
>+
>+
>+
>+ // dstA' = (1-srcA)*dstA + srcA
>+
>+ result.a = (1.0-b.a)*a.a + b.a;
>+
>+
>+
>+ // B(cs,cb) = cb ??? (1 ??? 2*cs)*cb*(1-cb), if (cs <= 0.5)
>+
>+ // = cb + (2*cs ??? 1)*(D(cb) ??? cb), otherwise
>+
>+
>+
>+ float3 blendResult;
>+
>+
>+
>+ // red
>+
>+ if (cs.r <= 0.5) {
>+
>+ blendResult.r = cb.r - (1.0 -
>clamp(2.0*cs.r,0.0,1.0))*cb.r*(1.0-cb.r);
>+
>+ } else {
>+
>+ // this could be a helper function, but bytecode doesn't
>support this
>+
>+ // = ((16*x ??? 12)*x +4)*x, if x <= 0.25
>+
>+ // = x**0.5, otherwise
>+
>+ float dcb;
>+
>+ if (cb.r <= 0.25) {
>+
>+ dcb = ((16.0*cb.r - 12.0) *4.0)*cb.r;
>+
>+ } else {
>+
>+ dcb = sqrt(cb.r);
>+
>+ }
>+
>+
>+
>+ blendResult.r = cb.r + (2.0*cs.r - 1.0)*(dcb - cb.r);
>+
>+ }
>+
>+
>+
>+ // green
>+
>+ if (cs.g <= 0.5) {
>+
>+ blendResult.g = cb.g - (1.0 - 2.0*cs.g)*cb.g*(1.0-cb.g);
>+
>+ } else {
>+
>+ // = ((16*x ??? 12)*x +4)*x, if x <= 0.25
>+
>+ // = x**0.5, otherwise
>+
>+ float dcb;
>+
>+ if (cb.g <= 0.25) {
>+
>+ dcb = ((16.0*cb.g - 12.0) *4.0)*cb.g;
>+
>+ } else {
>+
>+ dcb = sqrt(cb.g);
>+
>+ }
>+
>+
>+
>+ blendResult.g = cb.g + (2.0*cs.g - 1.0)*(dcb - cb.g);
>+
>+ }
>+
>+
>+
>+ // blue
>+
>+ if (cs.b <= 0.5) {
>+
>+ blendResult.b = cb.b - (1.0 - 2.0*cs.b)*cb.b*(1.0-cb.b);
>+
>+ } else {
>+
>+ // = ((16*x ??? 12)*x +4)*x, if x <= 0.25
>+
>+ // = x**0.5, otherwise
>+
>+ float dcb;
>+
>+ if (cb.b <= 0.25) {
>+
>+ dcb = ((16.0*cb.b - 12.0) *4.0)*cb.b;
>+
>+ } else {
>+
>+ dcb = sqrt(cb.b);
>+
>+ }
>+
>+
>+
>+ blendResult.b = cb.b + (2.0*cs.b - 1.0)*(dcb - cb.b);
>+
>+ }
>+
>+
>+
>+
>+
>+ // dstCP' = (1-srcA)*dstCP + (1-dstA)*srcCP +
>srcA*dstA*Blend(srcCP/srcA, dstCP/dstA)
>+
>+ result.rgb = (1.0-b.a)*a.rgb + (1.0-a.a)*b.rgb +
>b.a*a.a*blendResult.rgb;
>+
>+ }
>+
>+}
>+
>
>http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/281c7786/frameworks/
>projects/Graphics/src/main/flex/org/apache/flex/graphics/utils/shaderClass
>es/SoftLightShader.as
>----------------------------------------------------------------------
>diff --git
>a/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/util
>s/shaderClasses/SoftLightShader.as
>b/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/util
>s/shaderClasses/SoftLightShader.as
>new file mode 100644
>index 0000000..3958cba
>--- /dev/null
>+++
>b/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/util
>s/shaderClasses/SoftLightShader.as
>@@ -0,0 +1,60 @@
>+/////////////////////////////////////////////////////////////////////////
>///////
>+//
>+// Licensed to the Apache Software Foundation (ASF) under one or more
>+// contributor license agreements. See the NOTICE file distributed with
>+// this work for additional information regarding copyright ownership.
>+// The ASF licenses this file to You under the Apache License, Version
>2.0
>+// (the "License"); you may not use this file except in compliance with
>+// the License. You may obtain a copy of the License at
>+//
>+// http://www.apache.org/licenses/LICENSE-2.0
>+//
>+// Unless required by applicable law or agreed to in writing, software
>+// distributed under the License is distributed on an "AS IS" BASIS,
>+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
>implied.
>+// See the License for the specific language governing permissions and
>+// limitations under the License.
>+//
>+/////////////////////////////////////////////////////////////////////////
>///////
>+
>+package org.apache.flex.graphics.utils.shaderClasses
>+{
>+import flash.display.Shader;
>+import org.apache.flex.core.ByteArrayAsset;
>+
>+/**
>+ * Creates a blend shader that is equivalent to
>+ * the 'Soft Light' blend mode for RGB premultiplied colors available
>+ * in Adobe Creative Suite tools. This blend mode is not native to
>Flash,
>+ * but is available in tools like Adobe Illustrator and Adobe
>Photoshop.
>+ *
>+ * <p>The 'softlight' blend mode can be set on Flex groups and graphic
>+ * elements. The visual appearance in tools like Adobe Illustrator and
>+ * Adobe Photoshop will be mimicked through this blend shader.</p>
>+ *
>+ * @langversion 3.0
>+ * @playerversion Flash 10
>+ * @playerversion AIR 1.5
>+ * @productversion Flex 4
>+ *
>+ * @includeExample examples/SoftLightShaderExample.mxml
>+ */
>+public class SoftLightShader extends flash.display.Shader
>+{
>+ [Embed(source="SoftLight.pbj", mimeType="application/octet-stream")]
>+ private static var ShaderClass:Class;
>+
>+ /**
>+ * Constructor.
>+ *
>+ * @langversion 3.0
>+ * @playerversion Flash 10
>+ * @playerversion AIR 1.5
>+ * @productversion Flex 4
>+ */
>+ public function SoftLightShader()
>+ {
>+ super(new ShaderClass());
>+ }
>+}
>+}
>
Re: git commit: [flex-asjs] [refs/heads/develop] - Added Shader
files (with compiler argument)
Posted by yishayw <yi...@hotmail.com>.
Fixed the Ant script and removed the pbj files. Waiting for advice on Maven
(where Jenkins is failing).
--
View this message in context: http://apache-flex-development.2333347.n4.nabble.com/Re-git-commit-flex-asjs-refs-heads-develop-Added-Shader-files-with-compiler-argument-tp60217p60254.html
Sent from the Apache Flex Development mailing list archive at Nabble.com.
Re: git commit: [flex-asjs] [refs/heads/develop] - Added Shader
files (with compiler argument)
Posted by yishayw <yi...@hotmail.com>.
This [1] seems to be the relevant thread. I'm trying to make this work for
FlexJS, but from what I understand this'll only help Ant builds. What's the
Maven equivalent?
[1]
http://apache-flex-development.2333347.n4.nabble.com/DISCUSS-Discuss-Release-Apache-Flex-PixelBender-Package-1-0-RC2-td33428i20.html
--
View this message in context: http://apache-flex-development.2333347.n4.nabble.com/Re-git-commit-flex-asjs-refs-heads-develop-Added-Shader-files-with-compiler-argument-tp60217p60253.html
Sent from the Apache Flex Development mailing list archive at Nabble.com.
Re: git commit: [flex-asjs] [refs/heads/develop] - Added Shader files
(with compiler argument)
Posted by Alex Harui <ah...@adobe.com>.
On 3/7/17, 10:26 AM, "Harbs" <ha...@gmail.com> wrote:
>I took the files from the flex-sdk repo. How did the files get there?
The pbj files are not under source control in flex-sdk. They are
downloaded from the Apache Flex Pixel Bender release.
>
>Can you fix this issue, because you obviously understand how and I
>haven’t a clue…
In theory, you can copy and tweak the pixel bender portion of
flex-sdk/frameworks/downloads.xml.
>
>Oh. Are you saying that we should reference the files in the flex-sdk
>directory? Wouldn’t that require building the flex-sdk as well?
No. There is a binary artifact available that we should be using.
-Alex
Re: git commit: [flex-asjs] [refs/heads/develop] - Added Shader files (with compiler argument)
Posted by Harbs <ha...@gmail.com>.
I took the files from the flex-sdk repo. How did the files get there?
Can you fix this issue, because you obviously understand how and I haven’t a clue…
Oh. Are you saying that we should reference the files in the flex-sdk directory? Wouldn’t that require building the flex-sdk as well?
> On Mar 7, 2017, at 8:01 PM, Alex Harui <ah...@adobe.com> wrote:
>
>
>
> On 3/7/17, 9:29 AM, "Harbs" <ha...@gmail.com> wrote:
>
>> I don’t understand what you mean.
>>
>> These files were just copied from the flex-sdk.
>>
>> Huh! The pbj files were not committed. It looks like they were excluded
>> in the .gitignore.
>>
>> I just fixed that.
>
> Funny! That was exactly the opposite reaction that we needed ;-).
>
> This is open source. PBJ files are object files. They should not be
> committed to our repos.
>
> And that's the uber point. The way to convert PBK to PBJ is via an Adobe
> tool, and most folks don't want to have to get the tool working in order
> to build our source releases.
>
> So even for the flex-sdk, several years ago, we created a special one-off
> PixelBender release. The flex-sdk download.xml script brings down the
> binary artifact and unpacks the PB files. I was trying to get you to use
> those same files. Otherwise, every PMC member who wants to vote on our
> source releases will have to install the Adobe tool.
>
> Please make the switch to the PixelBender release instead of putting the
> PB files in flex-asjs.
>
> Thanks,
> -Alex
>
Re: git commit: [flex-asjs] [refs/heads/develop] - Added Shader files
(with compiler argument)
Posted by Dev LFM <de...@gmail.com>.
Talking about pbj and pbk, does anyone have that oilpaint effect?
2017-03-07 18:01 GMT+00:00 Alex Harui <ah...@adobe.com>:
>
>
> On 3/7/17, 9:29 AM, "Harbs" <ha...@gmail.com> wrote:
>
> >I don’t understand what you mean.
> >
> >These files were just copied from the flex-sdk.
> >
> >Huh! The pbj files were not committed. It looks like they were excluded
> >in the .gitignore.
> >
> >I just fixed that.
>
> Funny! That was exactly the opposite reaction that we needed ;-).
>
> This is open source. PBJ files are object files. They should not be
> committed to our repos.
>
> And that's the uber point. The way to convert PBK to PBJ is via an Adobe
> tool, and most folks don't want to have to get the tool working in order
> to build our source releases.
>
> So even for the flex-sdk, several years ago, we created a special one-off
> PixelBender release. The flex-sdk download.xml script brings down the
> binary artifact and unpacks the PB files. I was trying to get you to use
> those same files. Otherwise, every PMC member who wants to vote on our
> source releases will have to install the Adobe tool.
>
> Please make the switch to the PixelBender release instead of putting the
> PB files in flex-asjs.
>
> Thanks,
> -Alex
>
>
Re: git commit: [flex-asjs] [refs/heads/develop] - Added Shader files
(with compiler argument)
Posted by Alex Harui <ah...@adobe.com>.
On 3/7/17, 9:29 AM, "Harbs" <ha...@gmail.com> wrote:
>I don’t understand what you mean.
>
>These files were just copied from the flex-sdk.
>
>Huh! The pbj files were not committed. It looks like they were excluded
>in the .gitignore.
>
>I just fixed that.
Funny! That was exactly the opposite reaction that we needed ;-).
This is open source. PBJ files are object files. They should not be
committed to our repos.
And that's the uber point. The way to convert PBK to PBJ is via an Adobe
tool, and most folks don't want to have to get the tool working in order
to build our source releases.
So even for the flex-sdk, several years ago, we created a special one-off
PixelBender release. The flex-sdk download.xml script brings down the
binary artifact and unpacks the PB files. I was trying to get you to use
those same files. Otherwise, every PMC member who wants to vote on our
source releases will have to install the Adobe tool.
Please make the switch to the PixelBender release instead of putting the
PB files in flex-asjs.
Thanks,
-Alex
Re: git commit: [flex-asjs] [refs/heads/develop] - Added Shader files (with compiler argument)
Posted by Harbs <ha...@gmail.com>.
I don’t understand what you mean.
These files were just copied from the flex-sdk.
Huh! The pbj files were not committed. It looks like they were excluded in the .gitignore.
I just fixed that.
> On Mar 7, 2017, at 6:02 PM, Alex Harui <ah...@adobe.com> wrote:
>
> Hi,
>
> Is it possible to use the upstream release instead? Even the flex-sdk
> uses pbj files from the upstream. IIRC, we did that because not everyone
> wanted to deal with installing the PB compiler.
>
> Thanks,
> -Alex
>
> On 3/7/17, 2:25 AM, "harbs@apache.org <ma...@apache.org>" <harbs@apache.org <ma...@apache.org>> wrote:
>
>> Repository: flex-asjs
>> Updated Branches:
>> refs/heads/develop 9657c4e9a -> 281c77860
>>
>>
>> Added Shader files (with compiler argument)
>>
>>
>> Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo <http://git-wip-us.apache.org/repos/asf/flex-asjs/repo>
>> Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/281c7786 <http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/281c7786>
>> Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/281c7786 <http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/281c7786>
>> Diff: ttp://git-wip-us.apache.org/repos/asf/flex-asjs/diff/281c7786 <ttp://git-wip-us.apache.org/repos/asf/flex-asjs/diff/281c7786>
>>
>> Branch: refeads/develop
>> Commit: 281c778607522da2aeca24f8212d551687684ce0
>> Parents: 9657c4e
>> Author: Harbs <harbs@in-tools.com <ma...@in-tools.com>>
>> Authored: Tue Mar 7 12:25:26 2017 +0200
>> Committer: Harbs <harbs@in-tools.com <ma...@in-tools.com>>
>> Committed: Tue Mar 7 12:25:26 2017 +0200
>>
>> ----------------------------------------------------------------------
>> frameworks/projects/Graphics/build.xml | 1 +
>> .../Graphics/src/main/flex/GraphicsClasses.as | 9 +
>> .../flex/graphics/utils/shaderClasses/Color.pbk | 101 +++++++++
>> .../grahics/utils/shaderClasses/ColorBurn.pbk | 149 +++++++++++++
>> .../utils/shrClasses/ColorBurnShader.as | 62 ++++++
>> .../graphics/utils/shaderClasses/ColorDodge.pbk | 151 +++++++++++++
>> .../utils/shaderClasses/ColorDodgeShader.as | 61 +++++
>> .../graphics/utils/shaderClasses/ColorShader.as | 61 +++++
>> .../graphics/utils/shaderClasses/Exclusion.pbk | 105 +++++++++
>> .../utils/shaderClasses/ExclusionShader.as | 61 +++++
>> .../flex/graphics/utils/shaderClasses/Hue.pbk | 216 ++++++++++++++++++
>> .../graphics/utils/shaderClasses/HueShader.as | 61 +++++
>> .../graphics/utils/shaderClasses/Luminosity.pbk | 103 +++++++++
>> .../shaderClasses/LuminosityMaskFilter.pbk | 133 +++++++++++
>> .../utils/shaderClasses/LuminosityMaskShader.as | 97 ++++++++
>> .../utils/shaderClasses/LuminosityShader.as | 60 +++++
>> .../graphics/utils/shaderClasses/Saturation.pbk | 222 +++++++++++++++++++
>> .../utils/shaderClasses/SaturationShader.as | 60 +++++
>> .../graphics/utils/shaderClasses/SoftLight.pbk | 199 +++++++++++++++++
>> .../utils/shaderClasses/SoftLightShader.as | 60 +++++
>> 20 files changed, 1972 insertions(+)
>> ---------------------------------------------------------------------
>>
>>
>> http://git-wip-us.apachrg/repos/asf/flex-asjs/blob/281c7786/frameworks/ <http://git-wip-us.apachrg/repos/asf/flex-asjs/blob/281c7786/frameworks/>
>> projects/Graphics/build.xml
>> ----------------------------------------------------------------------
>> diff --git a/frameworks/projects/Graphics/build.xml
>> b/frameworks/projects/Graphics/build.xml
>> index b47b813..01cbeb5 100644
>> --- a/frameworks/projects/Graphics/build.xml
>> +++ b/frameworks/projects/Graphics/build.xml
>> @@ -83,6 +83,7 @@
>> <arg value="+env.AIR_HOME=${env.AIR_HOME}" />
>> <arg value="-define=COMPILE::SWF,true" />
>> <arg value="-define=COMPILE::JS,false" />
>> + <arg
> lue="-compiler.byte-array-embed-class=org.apache.flex.core.ByteArrayAsse
>> t" />
>> </compc>
>> <copy file="${basedir}/target/${target.name}"
>> tofile="${FLEXJS_HOME}/frameworks/libs/${target.name}" />
>> </target>
>>
>> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/281c7786/frameworks/ <http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/281c7786/frameworks/>
>> projects/Graphics/src/main/flex/GraphicsClasses.as
>> ----------------------------------------------------------------------
>> diff --git
>> a/frameworks/projects/Graphics/src/main/flex/GraphicsClasses.as
>> b/frameworks/projects/Graphics/src/main/flex/GraphicsClasses.as
>> index 3b87a56..5836c9e 100644
>> --- a/frameworks/projects/Graphics/src/main/flex/GraphicsClasses.as
>> +++ b/frameworks/projects/Graphics/src/main/flex/GraphicsClasses.as
>> @@ -41,6 +41,15 @@ internal class GraphicsClasses
>> COMPILE::SWF
>> {
>> import org.apache.flex.graphics.utils.PathHelper; PathHelper;
>> + import org.apache.flex.graphics.utils.shaderClasses.ColorBurnShader;
>> ColorBurnShader;
>> + import org.apache.flex.graphics.utils.shaderClasses.ColorDodgeShader;
>> ColorDodgeShader;
>> + import org.apache.flex.graphics.utils.shaderClasses.ColorShader;
>> ColorShader;
>> + import org.apache.flex.graphics.utils.shaderClasses.ExclusionShader;
>> ExclusionShader;
>> + import org.apache.flex.graphics.utils.shaderClasses.HueShader;
>> HueShader;
>> + import
>> org.apache.flex.graphics.utils.shaderClasses.LuminosityMaskShader;
>> LuminosityMaskShader;
>> + import org.apache.flex.graphics.utils.shaderClasses.LuminosityShader;
>> LuminosityShader;
>> + import org.apach.flex.graphics.utils.shaderClasses.SaturationShader;
>> SaturationShader;
>> + import org.apache.flex.graphics.utils.shaderClasses.SoftLightShader;
>> SoftLightShader;
>> }
>> import org.apache.flex.graphics.QuadrticCurve; QuadraticCurve;
>> import org.apache.flex.graphics.ICircle; ICircle;
>>
>> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/281c7786/frameworks/ <http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/281c7786/frameworks/>
>> projects/Graphics/src/main/flex/orgapache/flex/graphics/utils/shaderClass
>> es/Color.pbk
>> ---------------------------------------------------------------------
>> diff --git
>> a/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/util
>> s/shaderClasses/Color.pbk
>> b/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/util
>> s/shaderClasses/Color.pbk
>> new file mode 100644
>> index 0000000..daedc3f
>> --- /dev/null
>> +++
>> b/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/util
>> s/shaderClasses/Color.pbk
>> @@-0,0 +1,101 @@
>> +/////////////////////////////////////////////////////////////////////////
>> ///////
>> +//
>> +// Licensed to the Apache Software Foundation (ASF) under one or more
>> +// contributor license agreements. See the NOTICE file distributed with
>> +// this work for additional information regarding copyright ownership.
>> +// The ASF licenses this file to You under the Apache License, Version
>> 2.0
>> +// (the "License"); you may not use this file except in compliance with
>> +// the License. You may obtain a copy of the License at
>> +//
>> +// http://www.apache.org/licenses/LICENSE-2.0 <http://www.apache.org/licenses/LICENSE-2.0>
>> +//
>> +// Unless required by applicable law or agreed to in writing, software
>> +// distributed uder the License is distributed on an "AS IS" BASIS,
>> +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
>> implied.
>> +// See the License for the specific language governing permissions and
>> +// limitations under the License.
>> +//
>> +/////////////////////////////////////////////////////////////////////////
>> ///////
>> +
>> +<languageVersion : 1.0;>
>> +kernel Color
>> +< namespace : "Flame";
>> + vendor :"Adobe";
>> + version : 1;
>> + description : "Color blend mode";
>> +>
>> +{
>> + input image4 dst;
>> + input image4 src;
>> + output pixel4 result;
>> +
>> + // PB bytecode can't do functions, use macros to define common
>> functions
>> + // gets the max number out of the three
>> + #define max3( x, y, z ) ( max((x), max((y), (z))) )
>> + // gets the min number out of the three
>> + #define min3( x, y,z ) ( min((x), min((y), (z))) )
>> +
>> + // gets the max number out of th three elements in a vector
>> + #define max3v(C) ( max3((C.x), (C.y) (C.z)) )
>> + // gets the min number out of the three elements in a vectr
>> + #define min3v(C) ( min3((C.x), (C.y), (C.z)) )
>> +
>> + // Sat - returns float, takes n a pixel3, or pixel4
>> + #define saturation(C) ( (max3((C.r), (C.g), (C.b) - min3((C.r),
>> (C.g), (C.b))) )
>> +
>> + // Luminance - returns floattakes in a pixel3, or pixel4
>> + #define luminance(C) ( (((C.r) * 0.3) + ((C.g) * 0.59) + ((C.b) *
>> 0.11)) )
>> +
>> + void
>> + evaluatePixel()
>> + {
>> + pixel4 a = sampleNearest(dst,outCoord()); // cb
>> + pixel4 b = sampleNearest(src,outCoord()); // cs
>> +
>> + // remove premultiplied (srcCP/srcA, dstCP/dstA)
>> + pixel3 cb = a.rgb;
>> + pixel3 cs = b.rgb;
>> + if (a. > 0.0) {
>> + cb.rgb = a.rgb / a.a;
>> + }
>> + if (b.a > 0.0) {
>> + cs.rgb = b.rgb / b.a;
>> + }
>> +
>> + // dstA' = (1-srcA)*dstA + srcA
>> + result.a = (1.0-b.a)*a.a + b.a;
>> +
>> + // adjustment -> adjustedcs
>> + float3 adjVec = (cb - cs);
>> + float adjustment = luminance(adjVec);
>> + float3 adjustedcs = cs + adjustment;
>> +
>> + // Blend()
>> +
>> + /* --------------------------------------------------------
>> + * void clipcolor(inout float3 color)
>> + * clips color.
>> + * nput and output float3 color_cl
>> + *
>> + * -------------------------------------------------------- */
>> + float3 color_cl = adjustedcs;
>> + float lum_cl = luminance(color_cl);
>> + float3 lumVec = float3(lum_cl, lum_cl, lum_cl);
>> + float mini = min3v(color_cl);
>> + float maxi = max3v(color_cl);
>> + if (mini < 0.0) {
>> + mini = lum_cl - mini;
>> + // max(..., 0.0000001) prevents divide by 0
>> + color_cl = lumVec + (color_cl - lumVec)*lum_cl/max(mini,
>> 0.0000001);
>> + }
>> + if (maxi > 1.0) {
>> + maxi = maxi - lum_cl;
>> + // max(..., 0.0000001) prevents divide by 0
>> + color_cl = lumVec + (color_cl - lumVec)*(1.0 -
>> lum_cl)/max(maxi, 0.0000001);
>> + }
>> + // end clipcolor - result: color_cl ---------------------- //
>> +
>> + // dstCP' = (1-srcA)*dstCP + (1-dstA)*srcCP +
>> srcA*dstA*Blend(srcCP/srcA, dstCP/dstA)
>> + result.rgb = ((1.0-b.a)*a.rgb) + ((1.0-a.a)*b.rgb) +
>> b.a*a.a*color_cl.rgb;
>> + }
>> +}
>> \ No newline at end of file
>>
>> htt://git-wip-us.apache.org/repos/asf/flex-asjs/blob/281c7786/frameworks/ <htt://git-wip-us.apache.org/repos/asf/flex-asjs/blob/281c7786/frameworks/>
>> projects/Graphics/src/main/flex/org/apache/flex/graphics/utils/shaderClass
>> es/ColorBurn.pbk
>> ----------------------------------------------------------------------
>> diff --git
>> a/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/util
>> s/shaderClasses/ColorBurn.pbk
>> b/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/util
>> s/shaderClasses/ColorBurn.pbk
>> new file mode 100644
>> index 0000000..99445c2
>> --- /dev/null
>> +++
>> b/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/util
>> s/shaderClasses/ColorBurn.pbk
>> @@ -0,0 +1,149 @@
>> +/////////////////////////////////////////////////////////////////////////
>> ///////
>> +//
>> +// Licensed to the Apache Software Foundation (ASF) under one or more
>> +// contributor license agreements. See the NOTICE file distributed with
>> +// this work for additional information regarding copyright ownership.
>> +// The ASF licenses this file to You under the Apache License, Version
>> 2.0
>> +// (the "License"); you may not use this file except in compliance with
>> +// the License. You may obtain a copy of the License at
>> +//
>> +// http://www.apache.org/licenses/LICENSE-2.0 <http://www.apache.org/licenses/LICENSE-2.0>
>> +//
>> +// Unless required by applicable law or agreed to in writing, software
>> +// distributed under the License is distributed on an "AS IS" BAIS,
>> +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
>> implied.
>> +// See the License for the specific language governig permissions and
>> +// limitations under the License.
>> +//
>> +/////////////////////////////////////////////////////////////////////////
>> ///////
>> +
>> +<languageVersion : 1.0;>
>> +
>> +kernel ColorBurn
>> +
>> +< namespace : "Flame";
>> +
>> + vendor : "Adobe";
>> +
>> + version : 1;
>> +
>> + description : "ColorBurn blend mode";
>> +
>> +>
>> +
>> +{
>> +
>> + input image4 dst;
>> +
>> + input image4 src;
>> +
>> + output pixel4 result;
>> +
>> +
>> +
>> + void
>> +
>> + evaluatePixel()
>> +
>> + {
>> +
>> + pixel4 a = sampleNearest(dst,outCoord()); //cb
>> +
>> + pixel4 b = sampleNearest(src,outCoord()); //cs
>> +
>> +
>> +
>> + // remove premultiplied (srcCP/srcA, dstCP/dstA)
>> +
>> + pixel3 cb = a.rgb;
>> +
>> + pixel3 cs = b.rgb;
>> +
>> + if (a.a > 0.0) {
>> +
>> + cb.rgb = a.rgb / a.a;
>> +
>> + }
>> +
>> + if (b.a > 0.0) {
>> +
>> + cs.rgb = b.rgb / b.a;
>> +
>> + }
>> +
>> +
>> +
>> + // dstA' = (1-srcA)*dstA + srcA
>> +
>> + result.a = (1.0-b.a)*a.a + b.a;
>> +
>> +
>> +
>> + // temp for Blend(srcCP/srcA, dstCP/dstA)
>> +
>> + pixel3 blendResult;
>> +
>> +
>> +
>> + // = 1, if cb = 1 (*** this case is AE/PS and AGM only, not PDF
>> spec)
>> +
>> + // = 0, if (1 ??? cb) >= cs
>> +
>> + // = (1 ??? cb) / cs, otherwise
>> +
>> + if (cb.r == 1.0) {
>> +
>> + blendResult.r = 1.0;
>> +
>> + } else if ((1.0 - cb.r) >= cs.r) {
>> +
>> + blendResult.r = 0.0;
>> +
>> + } else {
>> +
>> + blendResult.r = 1.0 - (1.0 - cb.r) / cs.r;
>> +
>> + }
>> +
>> +
>> +
>> + if (cb.g == 1.0) {
>> +
>> + blendResult.g = 1.0;
>> +
>> + } else f ((1.0 - cb.g) >= cs.g) {
>> +
>> + blendResult.g = 0.0;
>> +
>> + } else {
>> +
>> + blendResult.g = 1.0 - (1.0 - cb.g) / cs.g;
>> +
>> + }
>> +
>> +
>> +
>> + if (cb.b == 1.0) {
>> +
>> + blendResult.b = 1.0;
>> +
>> + } else if ((1.0 - cb.b) >= cs.b) {
>> +
>> + blendResult.b = 0.0;
>> +
>> + } else {
>> +
>> + blendResult.b = 1.0 - (1.0 - cb.b) / cs.b;
>> +
>> + }
>> +
>> +
>> +
>> + // dstCP' = (1-srcA)*dstCP + (1-dstA)*srcCP +
>> srcA*dstA*Blend(srcCP/rcA, dstCP/dstA)
>> +
>> + result.rgb = (1.0-b.a)*a.rgb + (1.0-a.a)*b.rgb +
>> b.a*a.a*blendResult.rgb;
>> +
>> + }
>> +
>> +}
>> +
>>
>> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/281c7786/frameworks/ <http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/281c7786/frameworks/>
>> projects/Graphics/src/main/flex/org/apache/flex/graphics/utils/shaderClass
>> es/ColorBurnShader.as
>> ----------------------------------------------------------------------
>> diff --git
>> a/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/util
>> s/shaderClasses/ColorBurnShader.as
>> b/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/util
>> s/shaderClasses/ColorBurnShader.as
>> new file mode 100644
>> index 0000000..bb96659
>> --- /dev/null
>> +++
>> b/frameworks/proects/Graphics/src/main/flex/org/apache/flex/graphics/util
>> s/shaderClasses/ColorBurnShader.as
>> @@ -0,0 +1,62 @@
>> +/////////////////////////////////////////////////////////////////////////
>> ///////
>> +//
>> +// Licensed to the Apache Software Foundation (ASF) under one or more
>> +// contributor license agreements. See the NOTICE file distributed with
>> +// this work for additional information regarding copyright ownerhip.
>> +// The ASF licenses this file to You under the Apache License, Version
>> 2.0
>> +// (the "License"); you may not use this file except in compliance with
>> +// the License. You may obtain a copy of the License at
>> +//
>> +// http://www.apache.org/licenses/LICENSE-2.0 <http://www.apache.org/licenses/LICENSE-2.0>
>> +//
>> +// Unless required by applicable law or agreed to in writing, software
>> +// distributed under the License is distributed on n "AS IS" BASIS,
>> +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, eithr express or
>> implied.
>> +// See the License for the specific languagegoverning permissions and
>> +// limitations under the License.
>> +//
>> +////////////////////////////////////////////////////////////////////////
>> ///////
>> +
>> +package orapache.flex.graphics.utils.shaderClasses
>> +{
>> +import flash.display.Shader
>> +import org.apache.flex.core.ByteArrayAsset;
>> +
>> +
>> +/**
>> + * Creas a blend shader that is equivalent to
>> + * the 'Color Burn' blend mode for RGB premultiplied colors available
>> + * in Adobe Creative Suite tools. This blend mode is not native to
>> Flash,
>> + * but is available in tools like Adobe Illustrator and Adobe
>> Photoshop.
>> + *
>> + * <p>The 'colorburn' blend mode can be set on Flex groups and graphic
>> + * elements and the visual appearance in tools like Adobe Ilustrator
>> and
>> + * Adobe Photoshop will be mimicked through this blend shader.</p>
>> + *
>> + * @langversion 3.0
>> + * @playerversion Flash 10
>> + * @playerversion AIR 1.5
>> + * @productversion Flex 4
>> + *
>> + * @includeExample examples/ColorBurnShaderExample.mxml
>> + */
>> +public class ColorBurnShader extends flash.display.Shader
>> +{
>> + [Embed(source="ColorBurn.pbj", mimeType="application/octet-stream")]
>> + private static var ShaderClass:Class;
>> +
>> + /**
>> + * Constructor.
>> + *
>> + * @langversion 3.0
>> + * @playerversion Flash 10
>> + * @playerversion AIR 1.5
>> + * @productversion Flex 4
>> + */
>> + public function ColorBurnShader()
>> + {
>> + super(new ShaderClass());
>> + }
>> +
>> +}
>> +}
>>
>> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/281c7786/frameworks/
>> projects/Graphics/src/main/flex/org/apache/flex/graphics/utils/shaderClass
>> es/ColorDodge.pbk
>> ----------------------------------------------------------------------
>> diff --git
>> a/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/util
>> s/shaderClasses/ColorDodge.pbk
>> b/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/util
>> s/shaderClasses/ColorDodge.pbk
>> new file mode 100644
>> index 0000000..11d6ca2
>> --- /dev/null
>> +++
>> b/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/util
>> s/shaderClasses/ColorDodge.pbk
>> @@ -0,0 +1,151 @@
>> +/////////////////////////////////////////////////////////////////////////
>> ///////
>> +//
>> +// Licensed to the Apache Software Foundation (ASF) under one or more
>> +// contributor license agreements. See the NOTICE file distributed with
>> +// this work for additional information regarding copyright ownership.
>> +// The ASF licenses this file to You under the Apache License, Version
>> 2.0
>> +// (the "License"); you may not use this file except in compliance with
>> +// the License. You may obtain a copy of the License at
>> +//
>> +// http://www.apache.org/licenses/LICENSE-2.0
>> +//
>> +// Unless required by applicable law or agreed to in writing, software
>> +// distributed under the License is distributed on an "AS IS" BASIS,
>> +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
>> implied.
>> +// See the License for the specific language governing permissions and
>> +// limitations under the License.
>> +//
>> +/////////////////////////////////////////////////////////////////////////
>> ///////
>> +
>> +<languageVersion : 1.0;>
>> +
>> +kernel ColorDodge
>> +
>> +< namespace : "Flame";
>> +
>> + vendor : "Adobe";
>> +
>> + version : 1;
>> +
>> + description : "ColorDodge blend mode";
>> +
>> +>
>> +
>> +{
>> +
>> + input image4 dst;
>> +
>> + input image4 src;
>> +
>> + output pixel4 result;
>> +
>> +
>> +
>> + void
>> +
>> + evaluatePixel()
>> +
>> + {
>> +
>> + pixel4 a = sampleNearest(dst,outCoord()); // cb
>> +
>> + pixel4 b = sampleNearest(src,outCoord()); // cs
>> +
>> +
>> +
>> + // remove premultiplied (srcCP/srcA, dstCP/dstA)
>> +
>> + pixel3 cb = a.rgb;
>> +
>> + pixel3 cs = b.rgb;
>> +
>> + if (a.a > 0.0) {
>> +
>> + cb.rgb = a.rgb / a.a;
>> +
>> + }
>> +
>> + if (b.a > 0.0) {
>> +
>> + cs.rgb = b.rgb / b.a;
>> +
>> + }
>> +
>> +
>> +
>> + // dstA' = (1-srcA)*dstA + srcA
>> +
>> + result.a = (1.0-b.a)*a.a + b.a;
>> +
>> +
>> +
>> + // temp for Blend(srcCP/srcA, dstCP/dstA)
>> +
>> + pixel3 blendResult;
>> +
>> +
>> +
>> + // = 0, if cb = 0 (*** this case is AE/PS and AGM only, not PDF
>> spec)
>> +
>> + // = 1, if cb >= (1 -cs)
>> +
>> + // = cb / (1 -cs), otherwise
>> +
>> +
>> +
>> + if (cb.r == 0.0) {
>> +
>> + blendResult.r = 0.0;
>> +
>> + } else if ( cb.r >= (1.0 - cs.r)) {
>> +
>> + blendResult.r = 1.0;
>> +
>> + } else {
>> +
>> + blendResult.r = cb.r / (1.0 - cs.r);
>> +
>> + }
>> +
>> +
>> +
>> + if (cb.g == 0.0) {
>> +
>> + blendResult.g = 0.0;
>> +
>> + } else if ( cb.g >= (1.0 - cs.g)) {
>> +
>> + blendResult.g = 1.0;
>> +
>> + } else {
>> +
>> + blendResult.g = cb.g / (1.0 - cs.g);
>> +
>> + }
>> +
>> +
>> +
>> + if (cb.b == 0.0) {
>> +
>> + blendResult.b = 0.0;
>> +
>> + } else if ( cb.b >= (1.0 - cs.b)) {
>> +
>> + blendResult.b = 1.0;
>> +
>> + } else {
>> +
>> + blendResult.b = cb.b / (1.0 - cs.b);
>> +
>> + }
>> +
>> +
>> +
>> + // dstCP' = (1-srcA)*dstCP + (1-dstA)*srcCP +
>> srcA*dstA*Blend(srcCP/srcA, dstCP/dstA)
>> +
>> + result.rgb = (1.0-b.a)*a.rgb + (1.0-a.a)*b.rgb +
>> b.a*a.a*blendResult.rgb;
>> +
>> + }
>> +
>> +}
>> +
>>
>> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/281c7786/frameworks/
>> projects/Graphics/src/main/flex/org/apache/flex/graphics/utils/shaderClass
>> es/ColorDodgeShader.as
>> ----------------------------------------------------------------------
>> diff --git
>> a/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/util
>> s/shaderClasses/ColorDodgeShader.as
>> b/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/util
>> s/shaderClasses/ColorDodgeShader.as
>> new file mode 100644
>> index 0000000..8d32620
>> --- /dev/null
>> +++
>> b/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/util
>> s/shaderClasses/ColorDodgeShader.as
>> @@ -0,0 +1,61 @@
>> +/////////////////////////////////////////////////////////////////////////
>> ///////
>> +//
>> +// Licensed to the Apache Software Foundation (ASF) under one or more
>> +// contributor license agreements. See the NOTICE file distributed with
>> +// this work for additional information regarding copyright ownership.
>> +// The ASF licenses this file to You under the Apache License, Version
>> 2.0
>> +// (the "License"); you may not use this file except in compliance with
>> +// the License. You may obtain a copy of the License at
>> +//
>> +// http://www.apache.org/licenses/LICENSE-2.0
>> +//
>> +// Unless required by applicable law or agreed to in writing, software
>> +// distributed under the License is distributed on an "AS IS" BASIS,
>> +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
>> implied.
>> +// See the License for the specific language governing permissions and
>> +// limitations under the License.
>> +//
>> +/////////////////////////////////////////////////////////////////////////
>> ///////
>> +
>> +package org.apache.flex.graphics.utils.shaderClasses
>> +{
>> +import flash.display.Shader;
>> +import org.apache.flex.core.ByteArrayAsset;
>> +
>> +/**
>> + * Creates a blend shader that is equivalent to
>> + * the 'Color Dodge' blend mode for RGB premultiplied colors available
>> + * in Adobe Creative Suite tools. This blend mode is not native to
>> Flash,
>> + * but is available in tools like Adobe Illustrator and Adobe
>> Photoshop.
>> + *
>> + * <p>The 'colordodge' blend mode can be set on Flex groups and graphic
>>
>> + * elements. The visual appearance in tools like Adobe Illustrator and
>> + * Adobe Photoshop will be mimicked through this blend shader.</p>
>> + *
>> + * @langversion 3.0
>> + * @playerversion Flash 10
>> + * @playerversion AIR 1.5
>> + * @productversion Flex 4
>> + *
>> + * @includeExample examples/ColorDodgeShaderExample.mxml
>> + */
>> +public class ColorDodgeShader extends flash.display.Shader
>> +{
>> + [Embed(source="ColorDodge.pbj", mimeType="application/octet-stream")]
>> + private static var ShaderClass:Class;
>> +
>> + /**
>> + * Constructor.
>> + *
>> + * @langversion 3.0
>> + * @playerversion Flash 10
>> + * @playerversion AIR 1.5
>> + * @productversion Flex 4
>> + */
>> + public function ColorDodgeShader()
>> + {
>> + super(new ShaderClass());
>> + }
>> +
>> +}
>> +}
>>
>> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/281c7786/frameworks/
>> projects/Graphics/src/main/flex/org/apache/flex/graphics/utils/shaderClass
>> es/ColorShader.as
>> ----------------------------------------------------------------------
>> diff --git
>> a/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/util
>> s/shaderClasses/ColorShader.as
>> b/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/util
>> s/shaderClasses/ColorShader.as
>> new file mode 100644
>> index 0000000..81d0607
>> --- /dev/null
>> +++
>> b/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/util
>> s/shaderClasses/ColorShader.as
>> @@ -0,0 +1,61 @@
>> +/////////////////////////////////////////////////////////////////////////
>> ///////
>> +//
>> +// Licensed to the Apache Software Foundation (ASF) under one or more
>> +// contributor license agreements. See the NOTICE file distributed with
>> +// this work for additional information regarding copyright ownership.
>> +// The ASF licenses this file to You under the Apache License, Version
>> 2.0
>> +// (the "License"); you may not use this file except in compliance with
>> +// the License. You may obtain a copy of the License at
>> +//
>> +// http://www.apache.org/licenses/LICENSE-2.0
>> +//
>> +// Unless required by applicable law or agreed to in writing, software
>> +// distributed under the License is distributed on an "AS IS" BASIS,
>> +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
>> implied.
>> +// See the License for the specific language governing permissions and
>> +// limitations under the License.
>> +//
>> +/////////////////////////////////////////////////////////////////////////
>> ///////
>> +
>> +package org.apache.flex.graphics.utils.shaderClasses
>> +{
>> +import flash.display.Shader;
>> +import org.apache.flex.core.ByteArrayAsset;
>> +
>> +/**
>> + * The ColorShader class creates a blend shader that is equivalent to
>> + * the 'Color' blend mode for RGB premultiplied colors available
>> + * in Adobe Creative Suite tools. This blend mode is not native to
>> Flash,
>> + * but is available in tools like Adobe Illustrator and Adobe
>> Photoshop.
>> + *
>> + * The 'color' blend mode can be set on Flex groups and graphic
>> + * elements and the visual appearance in tools like Adobe Illustrator
>> and
>> + * Adobe Photoshop will be mimicked through this blend shader.
>> + *
>> + * @langversion 3.0
>> + * @playerversion Flash 10
>> + * @playerversion AIR 1.5
>> + * @productversion Flex 4
>> + *
>> + * @includeExample examples/ColorShaderExample.mxml
>> + */
>> +public class ColorShader extends flash.display.Shader
>> +{
>> + [Embed(source="Color.pbj", mimeType="application/octet-stream")]
>> + private static var ShaderClass:Class;
>> +
>> + /**
>> + * Constructor.
>> + *
>> + * @langversion 3.0
>> + * @playerversion Flash 10
>> + * @playerversion AIR 1.5
>> + * @productversion Flex 4
>> + */
>> + public function ColorShader()
>> + {
>> + super(new ShaderClass());
>> + }
>> +
>> +}
>> +}
>>
>> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/281c7786/frameworks/
>> projects/Graphics/src/main/flex/org/apache/flex/graphics/utils/shaderClass
>> es/Exclusion.pbk
>> ----------------------------------------------------------------------
>> diff --git
>> a/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/util
>> s/shaderClasses/Exclusion.pbk
>> b/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/util
>> s/shaderClasses/Exclusion.pbk
>> new file mode 100644
>> index 0000000..d7fc369
>> --- /dev/null
>> +++
>> b/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/util
>> s/shaderClasses/Exclusion.pbk
>> @@ -0,0 +1,105 @@
>> +/////////////////////////////////////////////////////////////////////////
>> ///////
>> +//
>> +// Licensed to the Apache Software Foundation (ASF) under one or more
>> +// contributor license agreements. See the NOTICE file distributed with
>> +// this work for additional information regarding copyright ownership.
>> +// The ASF licenses this file to You under the Apache License, Version
>> 2.0
>> +// (the "License"); you may not use this file except in compliance with
>> +// the License. You may obtain a copy of the License at
>> +//
>> +// http://www.apache.org/licenses/LICENSE-2.0
>> +//
>> +// Unless required by applicable law or agreed to in writing, software
>> +// distributed under the License is distributed on an "AS IS" BASIS,
>> +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
>> implied.
>> +// See the License for the specific language governing permissions and
>> +// limitations under the License.
>> +//
>> +/////////////////////////////////////////////////////////////////////////
>> ///////
>> +
>> +<languageVersion : 1.0;>
>> +
>> +kernel Exclusion
>> +
>> +< namespace : "Flame";
>> +
>> + vendor : "Adobe";
>> +
>> + version : 1;
>> +
>> + description : "Exclusion blend mode";
>> +
>> +>
>> +
>> +{
>> +
>> + input image4 dst;
>> +
>> + input image4 src;
>> +
>> + output pixel4 result;
>> +
>> +
>> +
>> + void
>> +
>> + evaluatePixel()
>> +
>> + {
>> +
>> + pixel4 a = sampleNearest(dst,outCoord()); // cb
>> +
>> + pixel4 b = sampleNearest(src,outCoord()); // cs
>> +
>> +
>> +
>> + // remove premultiplied (srcCP/srcA, dstCP/dstA)
>> +
>> + //pixel3 cb, cs;
>> +
>> + pixel3 cb = a.rgb;
>> +
>> + pixel3 cs = b.rgb;
>> +
>> +
>> +
>> + if (a.a > 0.0) {
>> +
>> + cb.rgb = a.rgb / a.a;
>> +
>> + }
>> +
>> + if (b.a > 0.0) {
>> +
>> + cs.rgb = b.rgb / b.a;
>> +
>> + }
>> +
>> +
>> +
>> + // dstA' = (1-srcA)*dstA + srcA
>> +
>> + result.a = (1.0-b.a)*a.a + b.a;
>> +
>> +
>> +
>> + // temp for Blend(srcCP/srcA, dstCP/dstA)
>> +
>> + float3 blendResult;
>> +
>> +
>> +
>> + // cb + cs ??? 2*cs*cb
>> +
>> + blendResult.rgb = cb.rgb + cs.rgb - 2.0*cs.rgb*cb.rgb;
>> +
>> +
>> +
>> + // dstCP' = (1-srcA)*dstCP + (1-dstA)*srcCP +
>> srcA*dstA*Blend(srcCP/srcA, dstCP/dstA)
>> +
>> + result.rgb = ((1.0-b.a)*a.rgb) + ((1.0-a.a)*b.rgb) +
>> b.a*a.a*blendResult.rgb;
>> +
>> + }
>> +
>> +}
>> +
>>
>> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/281c7786/frameworks/
>> projects/Graphics/src/main/flex/org/apache/flex/graphics/utils/shaderClass
>> es/ExclusionShader.as
>> ----------------------------------------------------------------------
>> diff --git
>> a/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/util
>> s/shaderClasses/ExclusionShader.as
>> b/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/util
>> s/shaderClasses/ExclusionShader.as
>> new file mode 100644
>> index 0000000..198a48d
>> --- /dev/null
>> +++
>> b/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/util
>> s/shaderClasses/ExclusionShader.as
>> @@ -0,0 +1,61 @@
>> +/////////////////////////////////////////////////////////////////////////
>> ///////
>> +//
>> +// Licensed to the Apache Software Foundation (ASF) under one or more
>> +// contributor license agreements. See the NOTICE file distributed with
>> +// this work for additional information regarding copyright ownership.
>> +// The ASF licenses this file to You under the Apache License, Version
>> 2.0
>> +// (the "License"); you may not use this file except in compliance with
>> +// the License. You may obtain a copy of the License at
>> +//
>> +// http://www.apache.org/licenses/LICENSE-2.0
>> +//
>> +// Unless required by applicable law or agreed to in writing, software
>> +// distributed under the License is distributed on an "AS IS" BASIS,
>> +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
>> implied.
>> +// See the License for the specific language governing permissions and
>> +// limitations under the License.
>> +//
>> +/////////////////////////////////////////////////////////////////////////
>> ///////
>> +
>> +package org.apache.flex.graphics.utils.shaderClasses
>> +{
>> +import flash.display.Shader;
>> +import org.apache.flex.core.ByteArrayAsset;
>> +
>> +/**
>> + * Creates a blend shader that is equivalent to
>> + * the 'Exclusion' blend mode for RGB premultiplied colors available
>> + * in Adobe Creative Suite tools. This blend mode is not native to
>> Flash,
>> + * but is available in tools like Adobe Illustrator and Adobe
>> Photoshop.
>> + *
>> + * <p>The 'exclusion' blend mode can be set on Flex groups and graphic
>> + * elements. The visual appearance in tools like Adobe Illustrator and
>> + * Adobe Photoshop will be mimicked through this blend shader.</p>
>> + *
>> + * @langversion 3.0
>> + * @playerversion Flash 10
>> + * @playerversion AIR 1.5
>> + * @productversion Flex 4
>> + *
>> + * @includeExample examples/ExclusionShaderExample.mxml
>> + */
>> +public class ExclusionShader extends flash.display.Shader
>> +{
>> + [Embed(source="Exclusion.pbj", mimeType="application/octet-stream")]
>> + private static var ShaderClass:Class;
>> +
>> + /**
>> + * Constructor.
>> + *
>> + * @langversion 3.0
>> + * @playerversion Flash 10
>> + * @playerversion AIR 1.5
>> + * @productversion Flex 4
>> + */
>> + public function ExclusionShader()
>> + {
>> + super(new ShaderClass());
>> + }
>> +
>> +}
>> +}
>>
>> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/281c7786/frameworks/
>> projects/Graphics/src/main/flex/org/apache/flex/graphics/utils/shaderClass
>> es/Hue.pbk
>> ----------------------------------------------------------------------
>> diff --git
>> a/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/util
>> s/shaderClasses/Hue.pbk
>> b/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/util
>> s/shaderClasses/Hue.pbk
>> new file mode 100644
>> index 0000000..5ef71f6
>> --- /dev/null
>> +++
>> b/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/util
>> s/shaderClasses/Hue.pbk
>> @@ -0,0 +1,216 @@
>> +/////////////////////////////////////////////////////////////////////////
>> ///////
>> +//
>> +// Licensed to the Apache Software Foundation (ASF) under one or more
>> +// contributor license agreements. See the NOTICE file distributed with
>> +// this work for additional information regarding copyright ownership.
>> +// The ASF licenses this file to You under the Apache License, Version
>> 2.0
>> +// (the "License"); you may not use this file except in compliance with
>> +// the License. You may obtain a copy of the License at
>> +//
>> +// http://www.apache.org/licenses/LICENSE-2.0
>> +//
>> +// Unless required by applicable law or agreed to in writing, software
>> +// distributed under the License is distributed on an "AS IS" BASIS,
>> +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
>> implied.
>> +// See the License for the specific language governing permissions and
>> +// limitations under the License.
>> +//
>> +/////////////////////////////////////////////////////////////////////////
>> ///////
>> +
>> +<languageVersion : 1.0;>
>> +kernel Hue
>> +< namespace : "Flame";
>> + vendor : "Adobe";
>> + version : 1;
>> + description : "Hue blend mode";
>> +>
>> +{
>> + input image4 dst;
>> + input image4 src;
>> + output pixel4 result;
>> +
>> + // PB bytecode can't do functions, use macros to define common
>> functions
>> + // gets the max number out of the three
>> + #define max3( x, y, z ) ( max((x), max((y), (z))) )
>> + // gets the min number out of the three
>> + #define min3( x, y, z ) ( min((x), min((y), (z))) )
>> +
>> + // gets the max number out of the three elements in a vector
>> + #define max3v(C) ( max3((C.x), (C.y), (C.z)) )
>> + // gets the min number out of the three elements in a vector
>> + #define min3v(C) ( min3((C.x), (C.y), (C.z)) )
>> +
>> + // Sat - returns float, takes in a pixel3, or pixel4
>> + #define saturation(C) ( (max3((C.r), (C.g), (C.b)) - min3((C.r),
>> (C.g), (C.b))) )
>> +
>> + // Luminance - returns float, takes in a pixel3, or pixel4
>> + #define luminance(C) ( (((C.r) * 0.3) + ((C.g) * 0.59) + ((C.b) *
>> 0.11)) )
>> +
>> + void
>> + evaluatePixel()
>> + {
>> + pixel4 a = sampleNearest(dst,outCoord()); // cb
>> + pixel4 b = sampleNearest(src,outCoord()); // cs
>> +
>> + // remove premultiplied (srcCP/srcA, dstCP/dstA)
>> + pixel3 cb, cs;
>> + if (a.a > 0.0) {
>> + cb.rgb = a.rgb / a.a;
>> + }
>> + if (b.a > 0.0) {
>> + cs.rgb = b.rgb / b.a;
>> + }
>> +
>> + // dstA' = (1-srcA)*dstA + srcA
>> + result.a = (1.0-b.a)*a.a + b.a;
>> +
>> +
>> + // setSat(cs, Sat(cb))
>> +
>> + // setSat (setSatColor, sat) -> setSatResult
>> + /* --------------------------------------------------------
>> + * void setsaturation(inout float3 color, in float satVal)
>> + * makes color have the target saturation.
>> + * input and output of float3 color
>> + * input of the target saturation
>> + *
>> + * --------------------------------------------------------
>> + void setsatcomponents(inout float minComp, inout float midComp,
>> inout float maxComp, in float satVal)
>> + {
>> + midComp -= minComp;
>> + maxComp -= minComp;
>> + minComp = 0.0;
>> + if (maxComp > 0.0) {
>> + // max(..., 0.0000001) prevents divide by 0
>> + midComp *= satVal/max(maxComp, 0.0000001);
>> + maxComp = satVal;
>> + }
>> + }
>> + */
>> +
>> + float3 color = cs.rgb;
>> + float satVal = saturation(cb);
>> +
>> + if (color.x <= color.y) {
>> + if (color.y <= color.z) {
>> + // x <= y <= z
>> + // setsatcomponents(color.x, color.y, color.z, satVal);
>> + // min, mid, max, val
>> +
>> + color.y -= color.x;
>> + color.z -= color.x;
>> + color.x = 0.0;
>> + if (color.z > 0.0) {
>> + // max(..., 0.0000001) prevents divide by 0
>> + color.y *= satVal/max(color.z, 0.0000001);
>> + color.z = satVal;
>> + }
>> +
>> + } else {
>> + if (color.x <= color.z) {
>> + // x <= z <= y
>> + // setsatcomponents(color.x, color.z, color.y,
>> satVal);
>> + // min, mid, max, value
>> +
>> + color.z -= color.x;
>> + color.y -= color.x;
>> + color.x = 0.0;
>> + if (color.y > 0.0) {
>> + // max(..., 0.0000001) prevents divide by 0
>> + color.z *= satVal/max(color.y, 0.0000001);
>> + color.y = satVal;
>> + }
>> + } else {
>> + // z <= x <= y
>> + // setsatcomponents(color.z, color.x, color.y,
>> satVal);
>> + // min, mid, max, val
>> +
>> + color.x -= color.z;
>> + color.y -= color.z;
>> + color.z = 0.0;
>> + if (color.y > 0.0) {
>> + // max(..., 0.0000001) prevents divide by 0
>> + color.x *= satVal/max(color.y, 0.0000001);
>> + color.y = satVal;
>> + }
>> + }
>> + }
>> + } else {
>> + if (color.x <= color.z) {
>> + // y <= x <= z
>> + // setsatcomponents(color.y, color.x, color.z, satVal);
>> +
>> + color.x -= color.y;
>> + color.z -= color.y;
>> + color.y = 0.0;
>> + if (color.z > 0.0) {
>> + // max(..., 0.0000001) prevents divide by 0
>> + color.x *= satVal/max(color.z, 0.0000001);
>> + color.z = satVal;
>> + }
>> + } else {
>> + if (color.y <= color.z) {
>> + // y <= z <= x
>> + // setsatcomponents(color.y, color.z, color.x,
>> satVal);
>> + // min, mid, max, val
>> +
>> + color.z -= color.y;
>> + color.x -= color.y;
>> + color.y = 0.0;
>> + if (color.x > 0.0) {
>> + // max(..., 0.0000001) prevents divide by 0
>> + color.z *= satVal/max(color.x, 0.0000001);
>> + color.x = satVal;
>> + }
>> + } else {
>> + // z <= y <= x
>> + // setsatcomponents(color.z, color.y, color.x,
>> satVal);
>> + // min, mid, max, val
>> +
>> + color.y -= color.z;
>> + color.x -= color.z;
>> + color.z = 0.0;
>> + if (color.x > 0.0) {
>> + // max(..., 0.0000001) prevents divide by 0
>> + color.y *= satVal/max(color.x, 0.0000001);
>> + color.x = satVal;
>> + }
>> + }
>> + }
>> + }
>> + // end setSaturation - result: color ---------------------- //
>> +
>> + // intermediate adjustment (setSatResult) -> adjustedcs
>> + float3 adjVec = (cb - color);
>> + float adjustment = luminance(adjVec);
>> + float3 adjustedcs = color + adjustment;
>> +
>> + // ClipRGB(adjustedcs) -> blendResult
>> +
>> + /* --------------------------------------------------------
>> + * void clipcolor(inout float3 color)
>> + * clips color.
>> + * input and output float3 color_cl
>> + *
>> + * -------------------------------------------------------- */
>> + float3 color_cl = adjustedcs;
>> + float lum_cl = luminance(color_cl);
>> + float3 lumVec = float3(lum_cl, lum_cl, lum_cl);
>> + float mini = min3v(color_cl);
>> + float maxi = max3v(color_cl);
>> + if (mini < 0.0) {
>> + mini = lum_cl - mini;
>> + // max(..., 0.0000001) prevents divide by 0
>> + color_cl = lumVec + (color_cl - lumVec)*lum_cl/max(mini,
>> 0.0000001);
>> + }
>> + if (maxi > 1.0) {
>> + maxi = maxi - lum_cl;
>> + // max(..., 0.0000001) prevents divide by 0
>> + color_cl = lumVec + (color_cl - lumVec)*(1.0 -
>> lum_cl)/max(maxi, 0.0000001);
>> + }
>> + // end clipcolor - result: color_cl ---------------------- //
>> +
>> + // dstCP' = (1-srcA)*dstCP + (1-dstA)*srcCP +
>> srcA*dstA*Blend(srcCP/srcA, dstCP/dstA)
>> + result.rgb = ((1.0-b.a)*a.rgb) + ((1.0-a.a)*b.rgb) +
>> b.a*a.a*color_cl.rgb;
>> + }
>> +}
>>
>> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/281c7786/frameworks/
>> projects/Graphics/src/main/flex/org/apache/flex/graphics/utils/shaderClass
>> es/HueShader.as
>> ----------------------------------------------------------------------
>> diff --git
>> a/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/util
>> s/shaderClasses/HueShader.as
>> b/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/util
>> s/shaderClasses/HueShader.as
>> new file mode 100644
>> index 0000000..7c61804
>> --- /dev/null
>> +++
>> b/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/util
>> s/shaderClasses/HueShader.as
>> @@ -0,0 +1,61 @@
>> +/////////////////////////////////////////////////////////////////////////
>> ///////
>> +//
>> +// Licensed to the Apache Software Foundation (ASF) under one or more
>> +// contributor license agreements. See the NOTICE file distributed with
>> +// this work for additional information regarding copyright ownership.
>> +// The ASF licenses this file to You under the Apache License, Version
>> 2.0
>> +// (the "License"); you may not use this file except in compliance with
>> +// the License. You may obtain a copy of the License at
>> +//
>> +// http://www.apache.org/licenses/LICENSE-2.0
>> +//
>> +// Unless required by applicable law or agreed to in writing, software
>> +// distributed under the License is distributed on an "AS IS" BASIS,
>> +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
>> implied.
>> +// See the License for the specific language governing permissions and
>> +// limitations under the License.
>> +//
>> +/////////////////////////////////////////////////////////////////////////
>> ///////
>> +
>> +package org.apache.flex.graphics.utils.shaderClasses
>> +{
>> +import flash.display.Shader;
>> +import org.apache.flex.core.ByteArrayAsset;
>> +
>> +/**
>> + * Creates a blend shader that is equivalent to
>> + * the 'Hue' blend mode for RGB premultiplied colors available
>> + * in Adobe Creative Suite tools. This blend mode is not native to
>> Flash,
>> + * but is available in tools like Adobe Illustrator and Adobe
>> Photoshop.
>> + *
>> + * <p>The 'hue' blend mode can be set on Flex groups and graphic
>> + * elements. The visual appearance in tools like Adobe Illustrator and
>> + * Adobe Photoshop will be mimicked through this blend shader.</p>
>> + *
>> + * @langversion 3.0
>> + * @playerversion Flash 10
>> + * @playerversion AIR 1.5
>> + * @productversion Flex 4
>> + *
>> + * @includeExample examples/HueShaderExample.mxml
>> + */
>> +public class HueShader extends flash.display.Shader
>> +{
>> + [Embed(source="Hue.pbj", mimeType="application/octet-stream")]
>> + private static var ShaderClass:Class;
>> +
>> + /**
>> + * Constructor.
>> + *
>> + * @langversion 3.0
>> + * @playerversion Flash 10
>> + * @playerversion AIR 1.5
>> + * @productversion Flex 4
>> + */
>> + public function HueShader()
>> + {
>> + super(new ShaderClass());
>> + }
>> +
>> +}
>> +}
>>
>> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/281c7786/frameworks/
>> projects/Graphics/src/main/flex/org/apache/flex/graphics/utils/shaderClass
>> es/Luminosity.pbk
>> ----------------------------------------------------------------------
>> diff --git
>> a/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/util
>> s/shaderClasses/Luminosity.pbk
>> b/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/util
>> s/shaderClasses/Luminosity.pbk
>> new file mode 100644
>> index 0000000..586f35d
>> --- /dev/null
>> +++
>> b/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/util
>> s/shaderClasses/Luminosity.pbk
>> @@ -0,0 +1,103 @@
>> +/////////////////////////////////////////////////////////////////////////
>> ///////
>> +//
>> +// Licensed to the Apache Software Foundation (ASF) under one or more
>> +// contributor license agreements. See the NOTICE file distributed with
>> +// this work for additional information regarding copyright ownership.
>> +// The ASF licenses this file to You under the Apache License, Version
>> 2.0
>> +// (the "License"); you may not use this file except in compliance with
>> +// the License. You may obtain a copy of the License at
>> +//
>> +// http://www.apache.org/licenses/LICENSE-2.0
>> +//
>> +// Unless required by applicable law or agreed to in writing, software
>> +// distributed under the License is distributed on an "AS IS" BASIS,
>> +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
>> implied.
>> +// See the License for the specific language governing permissions and
>> +// limitations under the License.
>> +//
>> +/////////////////////////////////////////////////////////////////////////
>> ///////
>> +
>> +<languageVersion : 1.0;>
>> +kernel Luminosity
>> +< namespace : "Flame";
>> + vendor : "Adobe";
>> + version : 1;
>> + description : "Luminosity blend mode";
>> +>
>> +{
>> + input image4 dst;
>> + input image4 src;
>> + output pixel4 result;
>> +
>> + // PB bytecode can't do functions, use macros to define common
>> functions
>> + // gets the max number out of the three
>> + #define max3( x, y, z ) ( max((x), max((y), (z))) )
>> + // gets the min number out of the three
>> + #define min3( x, y, z ) ( min((x), min((y), (z))) )
>> +
>> + // gets the max number out of the three elements in a vector
>> + #define max3v(C) ( max3((C.x), (C.y), (C.z)) )
>> + // gets the min number out of the three elements in a vector
>> + #define min3v(C) ( min3((C.x), (C.y), (C.z)) )
>> +
>> + // Sat - returns float, takes in a pixel3, or pixel4
>> + #define saturation(C) ( (max3((C.r), (C.g), (C.b)) - min3((C.r),
>> (C.g), (C.b))) )
>> +
>> + // Luminance - returns float, takes in a pixel3, or pixel4
>> + #define luminance(C) ( (((C.r) * 0.3) + ((C.g) * 0.59) + ((C.b) *
>> 0.11)) )
>> +
>> + void
>> + evaluatePixel()
>> + {
>> + pixel4 a = sampleNearest(dst,outCoord()); // cb
>> + pixel4 b = sampleNearest(src,outCoord()); // cs
>> +
>> + // remove premultiplied (srcCP/srcA, dstCP/dstA)
>> + pixel3 cb = a.rgb;
>> + pixel3 cs = b.rgb;
>> + if (a.a > 0.0) {
>> + cb.rgb = a.rgb / a.a;
>> + }
>> + if (b.a > 0.0) {
>> + cs.rgb = b.rgb / b.a;
>> + }
>> +
>> + // dstA' = (1-srcA)*dstA + srcA
>> + result.a = (1.0-b.a)*a.a + b.a;
>> +
>> + // adjustment
>> + // color = color + lum_cb - luminance(color);
>> + // dstColorOld - dstColor
>> + float3 adjVec = cs.rgb - cb.rgb;
>> + float adjustment = luminance(adjVec);
>> + float3 adjustedColor = cb + adjustment;
>> +
>> + // ClipRGB(adjustedColor) -> color_cl
>> +
>> + /* --------------------------------------------------------
>> + * void clipcolor(inout float3 color)
>> + * clips color.
>> + * input and output float3 color_cl
>> + *
>> + * -------------------------------------------------------- */
>> + float3 color_cl = adjustedColor;
>> + float lum_cl = luminance(color_cl);
>> + float3 lumVec = float3(lum_cl, lum_cl, lum_cl);
>> + float mini = min3v(color_cl);
>> + float maxi = max3v(color_cl);
>> + if (mini < 0.0) {
>> + mini = lum_cl - mini;
>> + // max(..., 0.0000001) prevents divide by 0
>> + color_cl = lumVec + (color_cl - lumVec)*lum_cl/max(mini,
>> 0.0000001);
>> + }
>> + if (maxi > 1.0) {
>> + maxi = maxi - lum_cl;
>> + // max(..., 0.0000001) prevents divide by 0
>> + color_cl = lumVec + (color_cl - lumVec)*(1.0 -
>> lum_cl)/max(maxi, 0.0000001);
>> + }
>> + // end clipcolor - result: color_cl ---------------------- //
>> +
>> + // dstCP' = (1-srcA)*dstCP + (1-dstA)*srcCP +
>> srcA*dstA*Blend(srcCP/srcA, dstCP/dstA)
>> + result.rgb = ((1.0-b.a)*a.rgb) + ((1.0-a.a)*b.rgb) +
>> b.a*a.a*color_cl.rgb;
>> + }
>> +}
>>
>> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/281c7786/frameworks/
>> projects/Graphics/src/main/flex/org/apache/flex/graphics/utils/shaderClass
>> es/LuminosityMaskFilter.pbk
>> ----------------------------------------------------------------------
>> diff --git
>> a/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/util
>> s/shaderClasses/LuminosityMaskFilter.pbk
>> b/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/util
>> s/shaderClasses/LuminosityMaskFilter.pbk
>> new file mode 100644
>> index 0000000..10757a6
>> --- /dev/null
>> +++
>> b/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/util
>> s/shaderClasses/LuminosityMaskFilter.pbk
>> @@ -0,0 +1,133 @@
>> +/////////////////////////////////////////////////////////////////////////
>> ///////
>> +//
>> +// Licensed to the Apache Software Foundation (ASF) under one or more
>> +// contributor license agreements. See the NOTICE file distributed with
>> +// this work for additional information regarding copyright ownership.
>> +// The ASF licenses this file to You under the Apache License, Version
>> 2.0
>> +// (the "License"); you may not use this file except in compliance with
>> +// the License. You may obtain a copy of the License at
>> +//
>> +// http://www.apache.org/licenses/LICENSE-2.0
>> +//
>> +// Unless required by applicable law or agreed to in writing, software
>> +// distributed under the License is distributed on an "AS IS" BASIS,
>> +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
>> implied.
>> +// See the License for the specific language governing permissions and
>> +// limitations under the License.
>> +//
>> +/////////////////////////////////////////////////////////////////////////
>> ///////
>> +
>> +<languageVersion : 1.0;>
>> +
>> +kernel LuminosityMaskFilter
>> +
>> +< namespace : "Flame";
>> +
>> + vendor : "Adobe";
>> +
>> + version : 0;
>> +
>> + description : "Luminosity Mask filter - Flex SDK";
>> +
>> +>
>> +
>> +{
>> +
>> + parameter int mode <
>> +
>> + minValue:int(0);
>> +
>> + maxValue:int(3);
>> +
>> + defaultValue:int(0);
>> +
>> + >;
>> +
>> +
>> +
>> + input image4 mask;
>> +
>> + output pixel4 result;
>> +
>> +
>> +
>> + void
>> +
>> + evaluatePixel()
>> +
>> + {
>> +
>> + result = sampleNearest(mask, outCoord());
>> +
>> +
>> +
>> + // AI Luminosity mask calculation
>> +
>> + // input is artwork mask argb
>> +
>> + // Flex will only use alpha channel in an "alpha" mask
>> +
>> + // calculate new alpha channel using AI luminosity calculation
>> +
>> +
>> +
>> + // invert option is mode bit 1
>> +
>> + // clip option is mode bit 2
>> +
>> +
>> +
>> + // if (clip != invert) background = 0 else background = 1
>> +
>> + // luminosity = 0.3*red + 0.59*green + 0.11*blue
>> +
>> + // output alpha = alpha*luminosity + (1-alpha)*background;
>> +
>> + // if (invert) output alpha = 1 - output alpha
>> +
>> +
>> +
>> + // calculate alpha*luminosity for result argb
>> +
>> + // in flash, the mask artwork is premultiplied
>> +
>> + // so we use luminosity and not alpha*luminosity
>> +
>> + float alphaLum = (0.3 * result.r) + (0.59 * result.g) + (0.11 *
>> result.b);
>> +
>> +
>> +
>> + // mode 0 - clip 0, invert 0, background 1 = alpha*luminosity +
>> (1-alpha)*1
>> +
>> + if (mode == 0)
>> +
>> + result.a = 1.0 - result.a + alphaLum;
>> +
>> +
>> +
>> + // mode 1 - clip 0, invert 1, background 0 = 1 -
>> (alpha*luminosity + (1-alpha)*0)
>> +
>> + if (mode == 1)
>> +
>> + result.a = 1.0 - alphaLum;
>> +
>> +
>> +
>> + // mode 2 - clip 1, invert 0, background 0 = alpha*luminosity +
>> (1-alpha)*0
>> +
>> + if (mode == 2)
>> +
>> + result.a = alphaLum;
>> +
>> +
>> +
>> + // mode 3 - clip 1, invert 1, background 1 = 1 -
>> (alpha*luminosity + (1-alpha)*1)
>> +
>> + if (mode == 3)
>> +
>> + result.a = result.a - alphaLum;
>> +
>> + }
>> +
>> +}
>> +
>>
>> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/281c7786/frameworks/
>> projects/Graphics/src/main/flex/org/apache/flex/graphics/utils/shaderClass
>> es/LuminosityMaskShader.as
>> ----------------------------------------------------------------------
>> diff --git
>> a/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/util
>> s/shaderClasses/LuminosityMaskShader.as
>> b/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/util
>> s/shaderClasses/LuminosityMaskShader.as
>> new file mode 100644
>> index 0000000..dec94ed
>> --- /dev/null
>> +++
>> b/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/util
>> s/shaderClasses/LuminosityMaskShader.as
>> @@ -0,0 +1,97 @@
>> +/////////////////////////////////////////////////////////////////////////
>> ///////
>> +//
>> +// Licensed to the Apache Software Foundation (ASF) under one or more
>> +// contributor license agreements. See the NOTICE file distributed with
>> +// this work for additional information regarding copyright ownership.
>> +// The ASF licenses this file to You under the Apache License, Version
>> 2.0
>> +// (the "License"); you may not use this file except in compliance with
>> +// the License. You may obtain a copy of the License at
>> +//
>> +// http://www.apache.org/licenses/LICENSE-2.0
>> +//
>> +// Unless required by applicable law or agreed to in writing, software
>> +// distributed under the License is distributed on an "AS IS" BASIS,
>> +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
>> implied.
>> +// See the License for the specific language governing permissions and
>> +// limitations under the License.
>> +//
>> +/////////////////////////////////////////////////////////////////////////
>> ///////
>> +
>> +package org.apache.flex.graphics.utils.shaderClasses
>> +{
>> +import flash.display.Shader;
>> +import org.apache.flex.core.ByteArrayAsset;
>> +
>> +/**
>> + * Creates a blend shader that is equivalent
>> + * to the luminosity masking option (also known as soft masking)
>> available
>> + * in Adobe Creative Suite tools. This mask type is not native to
>> Flash,
>> + * but is available in tools like Adobe Illustrator and Adobe
>> Photoshop.
>> + *
>> + * <p>A luminosity mask type can be set on Flex groups and graphic
>> + * elements. The visual appearance in tools like Adobe Illustrator and
>> + * Adobe Photoshop will be mimicked through this blend shader.</p>
>> + *
>> + * @see spark.primitives.supportClasses.GraphicElement#maskType
>> + * @see spark.components.supportClasses.GroupBase#maskType
>> + *
>> + * @langversion 3.0
>> + * @playerversion Flash 10
>> + * @playerversion AIR 1.5
>> + * @productversion Flex 4
>> + *
>> + * @includeExample examples/LuminosityMaskShaderExample.mxml
>> + */
>> +
>> +public class LuminosityMaskShader extends Shader
>> +{
>> + [Embed(source="LuminosityMaskFilter.pbj",
>> mimeType="application/octet-stream")]
>> + private static var ShaderClass:Class;
>> +
>> + /**
>> + * Constructor.
>> + *
>> + * @langversion 3.0
>> + * @playerversion Flash 10
>> + * @playerversion AIR 1.5
>> + * @productversion Flex 4
>> + */
>> + public function LuminosityMaskShader()
>> + {
>> + super(new ShaderClass());
>> + }
>> +
>> + /**
>> + * A convenience field that takes into account whether
>> luminosityClip and/or
>> + * luminosityInvert are on or off.
>> + *
>> + * <ul>
>> + * <li>mode 0 = luminosityClip off, luminosityInvert off</li>
>> + * <li>mode 1 = luminosityClip off, luminosityInvert on</li>
>> + * <li>mode 2 = luminosityClip on, luminosityInvert off</li>
>> + * <li>mode 3 = luminosityClip on, luminosityInvert on </li>
>> + * </ul>
>> + *
>> + * @see
>> spark.primitives.supportClasses.GraphicElement#luminosityClip
>> + * @see
>> spark.primitives.supportClasses.GraphicElement#luminosityInvert
>> + * @see spark.components.supportClasses.GroupBase#luminosityClip
>> + * @see spark.components.supportClasses.GroupBase#luminosityInvert
>> + *
>> + * @langversion 3.0
>> + * @playerversion Flash 10
>> + * @playerversion AIR 1.5
>> + * @productversion Flex 4
>> + */
>> + public function get mode():int
>> + {
>> + return this.data.mode.value;
>> + }
>> +
>> + public function set mode(v:int):void
>> + {
>> + if (mode ==-1)
>> + return;
>> + this.data.mode.value=[v];
>> + }
>> +}
>> +}
>>
>> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/281c7786/frameworks/
>> projects/Graphics/src/main/flex/org/apache/flex/graphics/utils/shaderClass
>> es/LuminosityShader.as
>> ----------------------------------------------------------------------
>> diff --git
>> a/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/util
>> s/shaderClasses/LuminosityShader.as
>> b/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/util
>> s/shaderClasses/LuminosityShader.as
>> new file mode 100644
>> index 0000000..cdf9a25
>> --- /dev/null
>> +++
>> b/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/util
>> s/shaderClasses/LuminosityShader.as
>> @@ -0,0 +1,60 @@
>> +/////////////////////////////////////////////////////////////////////////
>> ///////
>> +//
>> +// Licensed to the Apache Software Foundation (ASF) under one or more
>> +// contributor license agreements. See the NOTICE file distributed with
>> +// this work for additional information regarding copyright ownership.
>> +// The ASF licenses this file to You under the Apache License, Version
>> 2.0
>> +// (the "License"); you may not use this file except in compliance with
>> +// the License. You may obtain a copy of the License at
>> +//
>> +// http://www.apache.org/licenses/LICENSE-2.0
>> +//
>> +// Unless required by applicable law or agreed to in writing, software
>> +// distributed under the License is distributed on an "AS IS" BASIS,
>> +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
>> implied.
>> +// See the License for the specific language governing permissions and
>> +// limitations under the License.
>> +//
>> +/////////////////////////////////////////////////////////////////////////
>> ///////
>> +
>> +package org.apache.flex.graphics.utils.shaderClasses
>> +{
>> +import flash.display.Shader;
>> +import org.apache.flex.core.ByteArrayAsset;
>> +
>> +/**
>> + * Creates a blend shader that is equivalent to
>> + * the 'Luminosity' blend mode for RGB premultiplied colors available
>> + * in Adobe Creative Suite tools. This blend mode is not native to
>> Flash,
>> + * but is available in tools like Adobe Illustrator and Adobe
>> Photoshop.
>> + *
>> + * <p>The 'luminosity' blend mode can be set on Flex groups and graphic
>>
>> + * elements. The visual appearance in tools like Adobe Illustrator and
>> + * Adobe Photoshop will be mimicked through this blend shader.</p>
>> + *
>> + * @langversion 3.0
>> + * @playerversion Flash 10
>> + * @playerversion AIR 1.5
>> + * @productversion Flex 4
>> + *
>> + * @includeExample examples/LuminosityShaderExample.mxml
>> + */
>> +public class LuminosityShader extends flash.display.Shader
>> +{
>> + [Embed(source="Luminosity.pbj", mimeType="application/octet-stream")]
>> + private static var ShaderClass:Class;
>> +
>> + /**
>> + * Constructor.
>> + *
>> + * @langversion 3.0
>> + * @playerversion Flash 10
>> + * @playerversion AIR 1.5
>> + * @productversion Flex 4
>> + */
>> + public function LuminosityShader()
>> + {
>> + super(new ShaderClass());
>> + }
>> +}
>> +}
>>
>> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/281c7786/frameworks/
>> projects/Graphics/src/main/flex/org/apache/flex/graphics/utils/shaderClass
>> es/Saturation.pbk
>> ----------------------------------------------------------------------
>> diff --git
>> a/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/util
>> s/shaderClasses/Saturation.pbk
>> b/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/util
>> s/shaderClasses/Saturation.pbk
>> new file mode 100644
>> index 0000000..e9d3866
>> --- /dev/null
>> +++
>> b/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/util
>> s/shaderClasses/Saturation.pbk
>> @@ -0,0 +1,222 @@
>> +/////////////////////////////////////////////////////////////////////////
>> ///////
>> +//
>> +// Licensed to the Apache Software Foundation (ASF) under one or more
>> +// contributor license agreements. See the NOTICE file distributed with
>> +// this work for additional information regarding copyright ownership.
>> +// The ASF licenses this file to You under the Apache License, Version
>> 2.0
>> +// (the "License"); you may not use this file except in compliance with
>> +// the License. You may obtain a copy of the License at
>> +//
>> +// http://www.apache.org/licenses/LICENSE-2.0
>> +//
>> +// Unless required by applicable law or agreed to in writing, software
>> +// distributed under the License is distributed on an "AS IS" BASIS,
>> +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
>> implied.
>> +// See the License for the specific language governing permissions and
>> +// limitations under the License.
>> +//
>> +/////////////////////////////////////////////////////////////////////////
>> ///////
>> +
>> +<languageVersion : 1.0;>
>> +kernel Saturation
>> +< namespace : "Flame";
>> + vendor : "Adobe";
>> + version : 1;
>> + description : "Saturation blend mode";
>> +>
>> +{
>> + input image4 dst;
>> + input image4 src;
>> + output pixel4 result;
>> +
>> + // PB bytecode can't do functions, use macros to define common
>> functions
>> + // gets the max number out of the three
>> + #define max3( x, y, z ) ( max((x), max((y), (z))) )
>> + // gets the min number out of the three
>> + #define min3( x, y, z ) ( min((x), min((y), (z))) )
>> +
>> + // gets the max number out of the three elements in a vector
>> + #define max3v(C) ( max3((C.x), (C.y), (C.z)) )
>> + // gets the min number out of the three elements in a vector
>> + #define min3v(C) ( min3((C.x), (C.y), (C.z)) )
>> +
>> + // Sat - returns float, takes in a pixel3, or pixel4
>> + #define saturation(C) ( (max3((C.r), (C.g), (C.b)) - min3((C.r),
>> (C.g), (C.b))) )
>> +
>> + // Luminance - returns float, takes in a pixel3, or pixel4
>> + #define luminance(C) ( (((C.r) * 0.3) + ((C.g) * 0.59) + ((C.b) *
>> 0.11)) )
>> +
>> + void
>> + evaluatePixel()
>> + {
>> + pixel4 a = sampleNearest(dst,outCoord()); // cb
>> + pixel4 b = sampleNearest(src,outCoord()); // cs
>> +
>> + // remove premultiplied (srcCP/srcA, dstCP/dstA)
>> + pixel3 cb = a.rgb;
>> + pixel3 cs = b.rgb;
>> + if (a.a > 0.0) {
>> + cb.rgb = a.rgb / a.a;
>> + }
>> + if (b.a > 0.0) {
>> + cs.rgb = b.rgb / b.a;
>> + }
>> +
>> + // dstA' = (1-srcA)*dstA + srcA
>> + result.a = (1.0-b.a)*a.a + b.a;
>> +
>> + // record old version of cb
>> + //float3 old_cb.rgb = cb.rgb;
>> +
>> + // SetSat(cb, Sat(cs))
>> +
>> + // setSat (setSatColor, sat) -> setSatResult
>> + /* --------------------------------------------------------
>> + * void setsaturation(inout float3 color, in float satVal)
>> + * makes color have the target saturation.
>> + * input and output of float3 color
>> + * input of the target saturation
>> + *
>> + * --------------------------------------------------------
>> + void setsatcomponents(inout float minComp, inout float midComp,
>> inout float maxComp, in float satVal)
>> + {
>> + midComp -= minComp;
>> + maxComp -= minComp;
>> + minComp = 0.0;
>> + if (maxComp > 0.0) {
>> + // max(..., 0.0000001) prevents divide by 0
>> + midComp *= satVal/max(maxComp, 0.0000001);
>> + maxComp = satVal;
>> + }
>> + }
>> + */
>> +
>> + float3 color = cb.rgb;
>> + float satVal = saturation(cs);
>> +
>> + if (color.x <= color.y) {
>> + if (color.y <= color.z) {
>> + // x <= y <= z
>> + // setsatcomponents(color.x, color.y, color.z, satVal);
>> + // min, mid, max, val
>> +
>> + color.y -= color.x;
>> + color.z -= color.x;
>> + color.x = 0.0;
>> + if (color.z > 0.0) {
>> + // max(..., 0.0000001) prevents divide by 0
>> + color.y *= satVal/max(color.z, 0.0000001);
>> + color.z = satVal;
>> + }
>> +
>> + } else {
>> + if (color.x <= color.z) {
>> + // x <= z <= y
>> + // setsatcomponents(color.x, color.z, color.y,
>> satVal);
>> + // min, mid, max, value
>> +
>> + color.z -= color.x;
>> + color.y -= color.x;
>> + color.x = 0.0;
>> + if (color.y > 0.0) {
>> + // max(..., 0.0000001) prevents divide by 0
>> + color.z *= satVal/max(color.y, 0.0000001);
>> + color.y = satVal;
>> + }
>> + } else {
>> + // z <= x <= y
>> + // setsatcomponents(color.z, color.x, color.y,
>> satVal);
>> + // min, mid, max, val
>> +
>> + color.x -= color.z;
>> + color.y -= color.z;
>> + color.z = 0.0;
>> + if (color.y > 0.0) {
>> + // max(..., 0.0000001) prevents divide by 0
>> + color.x *= satVal/max(color.y, 0.0000001);
>> + color.y = satVal;
>> + }
>> + }
>> + }
>> + } else {
>> + if (color.x <= color.z) {
>> + // y <= x <= z
>> + // setsatcomponents(color.y, color.x, color.z, satVal);
>> +
>> + color.x -= color.y;
>> + color.z -= color.y;
>> + color.y = 0.0;
>> + if (color.z > 0.0) {
>> + // max(..., 0.0000001) prevents divide by 0
>> + color.x *= satVal/max(color.z, 0.0000001);
>> + color.z = satVal;
>> + }
>> + } else {
>> + if (color.y <= color.z) {
>> + // y <= z <= x
>> + // setsatcomponents(color.y, color.z, color.x,
>> satVal);
>> + // min, mid, max, val
>> +
>> + color.z -= color.y;
>> + color.x -= color.y;
>> + color.y = 0.0;
>> + if (color.x > 0.0) {
>> + // max(..., 0.0000001) prevents divide by 0
>> + color.z *= satVal/max(color.x, 0.0000001);
>> + color.x = satVal;
>> + }
>> + } else {
>> + // z <= y <= x
>> + // setsatcomponents(color.z, color.y, color.x,
>> satVal);
>> + // min, mid, max, val
>> +
>> + color.y -= color.z;
>> + color.x -= color.z;
>> + color.z = 0.0;
>> + if (color.x > 0.0) {
>> + // max(..., 0.0000001) prevents divide by 0
>> + color.y *= satVal/max(color.x, 0.0000001);
>> + color.x = satVal;
>> + }
>> + }
>> + }
>> + }
>> + // end setSaturation - result: color ---------------------- //
>> +
>> + // adjustment
>> + //color = color + lum_cb - luminance(color);
>> + //dstColorOld - dstColor
>> + float3 adjVec = cb.rgb - color.rgb;
>> + float adjustment = luminance(adjVec);
>> + float3 adjustedColor = color + adjustment;
>> +
>> + // ClipRGB(adjustedColor) -> color_cl
>> +
>> + /* --------------------------------------------------------
>> + * void clipcolor(inout float3 color)
>> + * clips color.
>> + * input and output float3 color_cl
>> + *
>> + * -------------------------------------------------------- */
>> + float3 color_cl = adjustedColor;
>> + float lum_cl = luminance(color_cl);
>> + float3 lumVec = float3(lum_cl, lum_cl, lum_cl);
>> + float mini = min3v(color_cl);
>> + float maxi = max3v(color_cl);
>> + if (mini < 0.0) {
>> + mini = lum_cl - mini;
>> + // max(..., 0.0000001) prevents divide by 0
>> + color_cl = lumVec + (color_cl - lumVec)*lum_cl/max(mini,
>> 0.0000001);
>> + }
>> + if (maxi > 1.0) {
>> + maxi = maxi - lum_cl;
>> + // max(..., 0.0000001) prevents divide by 0
>> + color_cl = lumVec + (color_cl - lumVec)*(1.0 -
>> lum_cl)/max(maxi, 0.0000001);
>> + }
>> + // end clipcolor - result: color_cl ---------------------- //
>> +
>> +
>> + // dstCP' = (1-srcA)*dstCP + (1-dstA)*srcCP +
>> srcA*dstA*Blend(srcCP/srcA, dstCP/dstA)
>> + result .rgb = ((1.0-b.a)*a.rgb) + ((1.0-a.a)*b.rgb) +
>> b.a*a.a*color_cl.rgb;
>> + }
>> +}
>>
>> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/281c7786/frameworks/
>> projects/Graphics/src/main/flex/org/apache/flex/graphics/utils/shaderClass
>> es/SaturationShader.as
>> ----------------------------------------------------------------------
>> diff --git
>> a/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/util
>> s/shaderClasses/SaturationShader.as
>> b/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/util
>> s/shaderClasses/SaturationShader.as
>> new file mode 100644
>> index 0000000..02646ae
>> --- /dev/null
>> +++
>> b/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/util
>> s/shaderClasses/SaturationShader.as
>> @@ -0,0 +1,60 @@
>> +/////////////////////////////////////////////////////////////////////////
>> ///////
>> +//
>> +// Licensed to the Apache Software Foundation (ASF) under one or more
>> +// contributor license agreements. See the NOTICE file distributed with
>> +// this work for additional information regarding copyright ownership.
>> +// The ASF licenses this file to You under the Apache License, Version
>> 2.0
>> +// (the "License"); you may not use this file except in compliance with
>> +// the License. You may obtain a copy of the License at
>> +//
>> +// http://www.apache.org/licenses/LICENSE-2.0
>> +//
>> +// Unless required by applicable law or agreed to in writing, software
>> +// distributed under the License is distributed on an "AS IS" BASIS,
>> +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
>> implied.
>> +// See the License for the specific language governing permissions and
>> +// limitations under the License.
>> +//
>> +/////////////////////////////////////////////////////////////////////////
>> ///////
>> +
>> +package org.apache.flex.graphics.utils.shaderClasses
>> +{
>> +import flash.display.Shader;
>> +import org.apache.flex.core.ByteArrayAsset;
>> +
>> +/**
>> + * Creates a blend shader that is equivalent to
>> + * the 'Saturation' blend mode for RGB premultiplied colors available
>> + * in Adobe Creative Suite tools. This blend mode is not native to
>> Flash,
>> + * but is available in tools like Adobe Illustrator and Adobe
>> Photoshop.
>> + *
>> + * <p>The 'saturation' blend mode can be set on Flex groups and graphic
>>
>> + * elements. The visual appearance in tools like Adobe Illustrator and
>> + * Adobe Photoshop will be mimicked through this blend shader.</p>
>> + *
>> + * @langversion 3.0
>> + * @playerversion Flash 10
>> + * @playerversion AIR 1.5
>> + * @productversion Flex 4
>> + *
>> + * @includeExample examples/SaturationShaderExample.mxml
>> + */
>> +public class SaturationShader extends flash.display.Shader
>> +{
>> + [Embed(source="Saturation.pbj", mimeType="application/octet-stream")]
>> + private static var ShaderClass:Class;
>> +
>> + /**
>> + * Constructor.
>> + *
>> + * @langversion 3.0
>> + * @playerversion Flash 10
>> + * @playerversion AIR 1.5
>> + * @productversion Flex 4
>> + */
>> + public function SaturationShader()
>> + {
>> + super(new ShaderClass());
>> + }
>> +}
>> +}
>>
>> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/281c7786/frameworks/
>> projects/Graphics/src/main/flex/org/apache/flex/graphics/utils/shaderClass
>> es/SoftLight.pbk
>> ----------------------------------------------------------------------
>> diff --git
>> a/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/util
>> s/shaderClasses/SoftLight.pbk
>> b/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/util
>> s/shaderClasses/SoftLight.pbk
>> new file mode 100644
>> index 0000000..e98735a
>> --- /dev/null
>> +++
>> b/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/util
>> s/shaderClasses/SoftLight.pbk
>> @@ -0,0 +1,199 @@
>> +/////////////////////////////////////////////////////////////////////////
>> ///////
>> +//
>> +// Licensed to the Apache Software Foundation (ASF) under one or more
>> +// contributor license agreements. See the NOTICE file distributed with
>> +// this work for additional information regarding copyright ownership.
>> +// The ASF licenses this file to You under the Apache License, Version
>> 2.0
>> +// (the "License"); you may not use this file except in compliance with
>> +// the License. You may obtain a copy of the License at
>> +//
>> +// http://www.apache.org/licenses/LICENSE-2.0
>> +//
>> +// Unless required by applicable law or agreed to in writing, software
>> +// distributed under the License is distributed on an "AS IS" BASIS,
>> +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
>> implied.
>> +// See the License for the specific language governing permissions and
>> +// limitations under the License.
>> +//
>> +/////////////////////////////////////////////////////////////////////////
>> ///////
>> +
>> +<languageVersion : 1.0;>
>> +
>> +kernel SoftLight
>> +
>> +< namespace : "Flame";
>> +
>> + vendor : "Adobe";
>> +
>> + version : 1;
>> +
>> + description : "SoftLight blend mode";
>> +
>> +>
>> +
>> +{
>> +
>> + input image4 dst;
>> +
>> + input image4 src;
>> +
>> + output pixel4 result;
>> +
>> +
>> +
>> + void
>> +
>> + evaluatePixel()
>> +
>> + {
>> +
>> + pixel4 a = sampleNearest(dst,outCoord()); // cb
>> +
>> + pixel4 b = sampleNearest(src,outCoord()); // cs
>> +
>> +
>> +
>> + // remove premultiplied (srcCP/srcA, dstCP/dstA)
>> +
>> + pixel3 cb = a.rgb;
>> +
>> + pixel3 cs = b.rgb;
>> +
>> + if (a.a > 0.0) {
>> +
>> + cb.rgb = a.rgb / a.a;
>> +
>> + }
>> +
>> + if (b.a > 0.0) {
>> +
>> + cs.rgb = b.rgb / b.a;
>> +
>> + }
>> +
>> +
>> +
>> + // dstA' = (1-srcA)*dstA + srcA
>> +
>> + result.a = (1.0-b.a)*a.a + b.a;
>> +
>> +
>> +
>> + // B(cs,cb) = cb ??? (1 ??? 2*cs)*cb*(1-cb), if (cs <= 0.5)
>> +
>> + // = cb + (2*cs ??? 1)*(D(cb) ??? cb), otherwise
>> +
>> +
>> +
>> + float3 blendResult;
>> +
>> +
>> +
>> + // red
>> +
>> + if (cs.r <= 0.5) {
>> +
>> + blendResult.r = cb.r - (1.0 -
>> clamp(2.0*cs.r,0.0,1.0))*cb.r*(1.0-cb.r);
>> +
>> + } else {
>> +
>> + // this could be a helper function, but bytecode doesn't
>> support this
>> +
>> + // = ((16*x ??? 12)*x +4)*x, if x <= 0.25
>> +
>> + // = x**0.5, otherwise
>> +
>> + float dcb;
>> +
>> + if (cb.r <= 0.25) {
>> +
>> + dcb = ((16.0*cb.r - 12.0) *4.0)*cb.r;
>> +
>> + } else {
>> +
>> + dcb = sqrt(cb.r);
>> +
>> + }
>> +
>> +
>> +
>> + blendResult.r = cb.r + (2.0*cs.r - 1.0)*(dcb - cb.r);
>> +
>> + }
>> +
>> +
>> +
>> + // green
>> +
>> + if (cs.g <= 0.5) {
>> +
>> + blendResult.g = cb.g - (1.0 - 2.0*cs.g)*cb.g*(1.0-cb.g);
>> +
>> + } else {
>> +
>> + // = ((16*x ??? 12)*x +4)*x, if x <= 0.25
>> +
>> + // = x**0.5, otherwise
>> +
>> + float dcb;
>> +
>> + if (cb.g <= 0.25) {
>> +
>> + dcb = ((16.0*cb.g - 12.0) *4.0)*cb.g;
>> +
>> + } else {
>> +
>> + dcb = sqrt(cb.g);
>> +
>> + }
>> +
>> +
>> +
>> + blendResult.g = cb.g + (2.0*cs.g - 1.0)*(dcb - cb.g);
>> +
>> + }
>> +
>> +
>> +
>> + // blue
>> +
>> + if (cs.b <= 0.5) {
>> +
>> + blendResult.b = cb.b - (1.0 - 2.0*cs.b)*cb.b*(1.0-cb.b);
>> +
>> + } else {
>> +
>> + // = ((16*x ??? 12)*x +4)*x, if x <= 0.25
>> +
>> + // = x**0.5, otherwise
>> +
>> + float dcb;
>> +
>> + if (cb.b <= 0.25) {
>> +
>> + dcb = ((16.0*cb.b - 12.0) *4.0)*cb.b;
>> +
>> + } else {
>> +
>> + dcb = sqrt(cb.b);
>> +
>> + }
>> +
>> +
>> +
>> + blendResult.b = cb.b + (2.0*cs.b - 1.0)*(dcb - cb.b);
>> +
>> + }
>> +
>> +
>> +
>> +
>> +
>> + // dstCP' = (1-srcA)*dstCP + (1-dstA)*srcCP +
>> srcA*dstA*Blend(srcCP/srcA, dstCP/dstA)
>> +
>> + result.rgb = (1.0-b.a)*a.rgb + (1.0-a.a)*b.rgb +
>> b.a*a.a*blendResult.rgb;
>> +
>> + }
>> +
>> +}
>> +
>>
>> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/281c7786/frameworks/
>> projects/Graphics/src/main/flex/org/apache/flex/graphics/utils/shaderClass
>> es/SoftLightShader.as
>> ----------------------------------------------------------------------
>> diff --git
>> a/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/util
>> s/shaderClasses/SoftLightShader.as
>> b/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/util
>> s/shaderClasses/SoftLightShader.as
>> new file mode 100644
>> index 0000000..3958cba
>> --- /dev/null
>> +++
>> b/frameworks/projects/Graphics/src/main/flex/org/apache/flex/graphics/util
>> s/shaderClasses/SoftLightShader.as
>> @@ -0,0 +1,60 @@
>> +/////////////////////////////////////////////////////////////////////////
>> ///////
>> +//
>> +// Licensed to the Apache Software Foundation (ASF) under one or more
>> +// contributor license agreements. See the NOTICE file distributed with
>> +// this work for additional information regarding copyright ownership.
>> +// The ASF licenses this file to You under the Apache License, Version
>> 2.0
>> +// (the "License"); you may not use this file except in compliance with
>> +// the License. You may obtain a copy of the License at
>> +//
>> +// http://www.apache.org/licenses/LICENSE-2.0
>> +//
>> +// Unless required by applicable law or agreed to in writing, software
>> +// distributed under the License is distributed on an "AS IS" BASIS,
>> +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
>> implied.
>> +// See the License for the specific language governing permissions and
>> +// limitations under the License.
>> +//
>> +/////////////////////////////////////////////////////////////////////////
>> ///////
>> +
>> +package org.apache.flex.graphics.utils.shaderClasses
>> +{
>> +import flash.display.Shader;
>> +import org.apache.flex.core.ByteArrayAsset;
>> +
>> +/**
>> + * Creates a blend shader that is equivalent to
>> + * the 'Soft Light' blend mode for RGB premultiplied colors available
>> + * in Adobe Creative Suite tools. This blend mode is not native to
>> Flash,
>> + * but is available in tools like Adobe Illustrator and Adobe
>> Photoshop.
>> + *
>> + * <p>The 'softlight' blend mode can be set on Flex groups and graphic
>> + * elements. The visual appearance in tools like Adobe Illustrator and
>> + * Adobe Photoshop will be mimicked through this blend shader.</p>
>> + *
>> + * @langversion 3.0
>> + * @playerversion Flash 10
>> + * @playerversion AIR 1.5
>> + * @productversion Flex 4
>> + *
>> + * @includeExample examples/SoftLightShaderExample.mxml
>> + */
>> +public class SoftLightShader extends flash.display.Shader
>> +{
>> + [Embed(source="SoftLight.pbj", mimeType="application/octet-stream")]
>> + private static var ShaderClass:Class;
>> +
>> + /**
>> + * Constructor.
>> + *
>> + * @langversion 3.0
>> + * @playerversion Flash 10
>> + * @playerversion AIR 1.5
>> + * @productversion Flex 4
>> + */
>> + public function SoftLightShader()
>> + {
>> + super(new ShaderClass());
>> + }
>> +}
>> +}