Packagede.popforge.imageprocessing.geom
Classpublic final class Curve

The Curve class represents a curve that can be used to transform colors.

By default the image uses a linear function f(x) = x to render the colors. This class represents such a function which is based on interpolation between given fix points.

By default the curve will act as such a linear function. In this example has a curve been created with no parameters:

Another example for a curve. Two points (0x40|0xc0) and (0xc0|0x40) have been added:



Public Properties
 PropertyDefined by
  mode : int
The mode of the curve.
Curve
  points : Array
An array consisting of Point objects which describe the curve.
Curve
Public Methods
 MethodDefined by
  
Curve(addDefaultPoints:Boolean = true, mode:int = 4)
Creates a new Curve object.
Curve
  
addPoint(point:Point):void
Adds a point to the curve.
Curve
  
getBitmapData(bgColor:int = 0x333333, pointColor:int = 0xff00ff, lineColor:int = 0x666666, gridColor:int = 0x3a3a3a):BitmapData
Renders the curve to a BitmapData object.
Curve
  
getTable():Array
Calulates the new color values based on the current mode.
Curve
  
removePoint(point:Point):void
Removes a point from the curve.
Curve
Property detail
modeproperty
mode:int  [read-write]

The mode of the curve. Can be any value of CurveMode.

Implementation
    public function get mode():int
    public function set mode(value:int):void
pointsproperty 
public var points:Array

An array consisting of Point objects which describe the curve.

Constructor detail
Curve()constructor
public function Curve(addDefaultPoints:Boolean = true, mode:int = 4)

Creates a new Curve object.

Parameters
addDefaultPoints:Boolean (default = true) — If set to true the points (0|0) and (255|255) will be added automatically.
 
mode:int (default = 4) — The mode of the curve which may be any value of CurveMode.
Method detail
addPoint()method
public function addPoint(point:Point):void

Adds a point to the curve. The point will be only added to the curve if an existing one with same coordinates could not be found.

Parameters
point:Point — The point that should be added. x and y have to be >= 0 and <= 255.
getBitmapData()method 
public function getBitmapData(bgColor:int = 0x333333, pointColor:int = 0xff00ff, lineColor:int = 0x666666, gridColor:int = 0x3a3a3a):BitmapData

Renders the curve to a BitmapData object.

Parameters
bgColor:int (default = 0x333333) — Background color of the BitmapData.
 
pointColor:int (default = 0xff00ff) — Color to use for points.
 
lineColor:int (default = 0x666666) — The line color.
 
gridColor:int (default = 0x3a3a3a) — Color for the grid.

Returns
BitmapData — A BitmapData object containing the visual representation of the Curve object.
getTable()method 
public function getTable():Array

Calulates the new color values based on the current mode. If no points have been set this function will return an array that has been filled with zeros. Otherwise two more points will be added dynamically. They will always be at position (0|p0.y) and (255|pN.y).

The interpolation between the automatically added points and the first and last point is always linear.

Returns
Array — An array that can be used in combination with BitmapData.paletteMap() for instance.
removePoint()method 
public function removePoint(point:Point):void

Removes a point from the curve.

Parameters
point:Point — A point that should be removed.