///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2008 Vincent Petithory - http://blog.lunar-dev.net/
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
///////////////////////////////////////////////////////////////////////////////
package net.lunar.filters
{
import flash.display.Shader;
import flash.display.ShaderData;
import flash.display.ShaderParameter;
import flash.filters.ShaderFilter;
/**
* The ContrastLightnessFilter class allows
* filtering display objects by adjusting their lightness and contrast.
* It behaves like Photoshop's Lightness/Contrast adjustement.
*
*
You may use this class as an usual filter class :
** var filter:ContrastLightnessFilter = new ContrastLightnessFilter(-20, 10); * * // with a DisplayObject or a subclass * myDisplayObject.filters = [filter]; * * // or with a BitmapData object * myBitmapData.applyFilter(myBitmapData, myBitmapData.rect, * new Point(), filter); ** */ public class ContrastLightnessFilter extends ShaderFilter { /** * @private * The bytecode of the shader. */ [Embed( source="contrastLightnessFilter/ContrastLightnessFilter.pbj", mimeType="application/octet-stream")] private static var ShaderByteCode:Class; /** * The description of the shader, as it is defined in the shader source. */ public static var description:String; /** * The minimum lightness defined in the shader source. * *
You may change it to allow lesser values to all
* ContrastLightnessFilter objects
You may change it to allow higher values to all
* ContrastLightnessFilter objects
It is not automatically applied as default values of this
* ContrastLightnessFilter filter.
* If this value is passed, it will remain the input image unchanged.
You may change it to allow lesser values to all
* ContrastLightnessFilter objects
You may change it to allow higher values to all
* ContrastLightnessFilter objects
It is not automatically applied as default values of this
* ContrastLightnessFilter filter.
* If this value is passed, it will remain the input image unchanged.
-100 and
* 100.
* @param contrast increases or decreases the filtered image contrast.
* Between -100 and
* 100
*/
public function ContrastLightnessFilter(
contrast:int = 0,
lightness:int = 0
)
{
super();
_shader = new Shader(new ShaderByteCode());
this.contrast = contrast;
this.lightness = lightness;
}
/**
* Increases or decreases the filtered image lightness.
* Valid values ar between -100
* and 100.
Valid values ar between -100
* and 100.