Options
Menu

Class ColorTransform

The ColorTransform export class lets you adjust the color values in a display object. The color adjustment or color transformation can be applied to all four channels: red, green, blue, and alpha transparency.

When a ColorTransform object is applied to a display object, a new value for each color channel is calculated like this:

  • New red value = (old red value redMultiplier) + redOffset
  • New green value = (old green value greenMultiplier) + greenOffset
  • New blue value = (old blue value blueMultiplier) + blueOffset
  • New alpha value = (old alpha value alphaMultiplier) + alphaOffset

If any of the color channel values is greater than 255 after the calculation, it is set to 255. If it is less than 0, it is set to 0.

You can use ColorTransform objects in the following ways:

  • In the colorTransform parameter of the colorTransform() method of the BitmapData class
  • As the colorTransform property of a Transform object (which can be used as the transform property of a display object)

You must use the new ColorTransform() constructor to create a ColorTransform object before you can call the methods of the ColorTransform object.

Color transformations do not apply to the background color of a movie clip(such as a loaded SWF object). They apply only to graphics and symbols that are attached to the movie clip.

Hierarchy

  • ColorTransform

Index

Constructors

constructor

  • new ColorTransform(rawData: Float32Array): ColorTransform
  • new ColorTransform(redMultiplier?: number, greenMultiplier?: number, blueMultiplier?: number, alphaMultiplier?: number, redOffset?: number, greenOffset?: number, blueOffset?: number, alphaOffset?: number): ColorTransform
  • Creates a ColorTransform object for a display object with the specified color channel values and alpha values.

    Parameters

    • rawData: Float32Array

    Returns ColorTransform

  • Creates a ColorTransform object for a display object with the specified color channel values and alpha values.

    Parameters

    • Optional redMultiplier: number

      The value for the red multiplier, in the range from 0 to 1.

    • Optional greenMultiplier: number

      The value for the green multiplier, in the range from 0 to 1.

    • Optional blueMultiplier: number

      The value for the blue multiplier, in the range from 0 to 1.

    • Optional alphaMultiplier: number

      The value for the alpha transparency multiplier, in the range from 0 to 1.

    • Optional redOffset: number

      The offset value for the red color channel, in the range from -255 to 255.

    • Optional greenOffset: number

      The offset value for the green color channel, in the range from -255 to 255.

    • Optional blueOffset: number

      The offset for the blue color channel value, in the range from -255 to 255.

    • Optional alphaOffset: number

      The offset for alpha transparency channel value, in the range from -255 to 255.

    Returns ColorTransform

Properties

_rawData

_rawData: Float32Array

Accessors

alphaMultiplier

  • get (): number
  • set (value: number): void
  • A decimal value that is multiplied with the alpha transparency channel value.

    If you set the alpha transparency value of a display object directly by using the alpha property of the DisplayObject instance, it affects the value of the alphaMultiplier property of that display object's transform.colorTransform property.

    Returns number

  • A decimal value that is multiplied with the alpha transparency channel value.

    If you set the alpha transparency value of a display object directly by using the alpha property of the DisplayObject instance, it affects the value of the alphaMultiplier property of that display object's transform.colorTransform property.

    Parameters

    • value: number

    Returns void

alphaOffset

  • get (): number
  • set (value: number): void
  • A number from -255 to 255 that is added to the alpha transparency channel value after it has been multiplied by the alphaMultiplier value.

    Returns number

  • A number from -255 to 255 that is added to the alpha transparency channel value after it has been multiplied by the alphaMultiplier value.

    Parameters

    • value: number

    Returns void

blueMultiplier

  • get (): number
  • set (value: number): void
  • A decimal value that is multiplied with the blue channel value.

    Returns number

  • A decimal value that is multiplied with the blue channel value.

    Parameters

    • value: number

    Returns void

blueOffset

  • get (): number
  • set (value: number): void
  • A number from -255 to 255 that is added to the blue channel value after it has been multiplied by the blueMultiplier value.

    Returns number

  • A number from -255 to 255 that is added to the blue channel value after it has been multiplied by the blueMultiplier value.

    Parameters

    • value: number

    Returns void

color

  • get (): number
  • set (value: number): void
  • The RGB color value for a ColorTransform object.

    When you set this property, it changes the three color offset values (redOffset, greenOffset, and blueOffset) accordingly, and it sets the three color multiplier values(redMultiplier, greenMultiplier, and blueMultiplier) to 0. The alpha transparency multiplier and offset values do not change.

    When you pass a value for this property, use the format 0xRRGGBB. RR, GG, and BB each consist of two hexadecimal digits that specify the offset of each color component. The 0x tells the ActionScript compiler that the number is a hexadecimal value.

    Returns number

  • The RGB color value for a ColorTransform object.

    When you set this property, it changes the three color offset values (redOffset, greenOffset, and blueOffset) accordingly, and it sets the three color multiplier values(redMultiplier, greenMultiplier, and blueMultiplier) to 0. The alpha transparency multiplier and offset values do not change.

    When you pass a value for this property, use the format 0xRRGGBB. RR, GG, and BB each consist of two hexadecimal digits that specify the offset of each color component. The 0x tells the ActionScript compiler that the number is a hexadecimal value.

    Parameters

    • value: number

    Returns void

greenMultiplier

  • get (): number
  • set (value: number): void
  • A decimal value that is multiplied with the green channel value.

    Returns number

  • A decimal value that is multiplied with the green channel value.

    Parameters

    • value: number

    Returns void

greenOffset

  • get (): number
  • set (value: number): void
  • A number from -255 to 255 that is added to the green channel value after it has been multiplied by the greenMultiplier value.

    Returns number

  • A number from -255 to 255 that is added to the green channel value after it has been multiplied by the greenMultiplier value.

    Parameters

    • value: number

    Returns void

redMultiplier

  • get (): number
  • set (value: number): void
  • A decimal value that is multiplied with the red channel value.

    Returns number

  • A decimal value that is multiplied with the red channel value.

    Parameters

    • value: number

    Returns void

redOffset

  • get (): number
  • set (value: number): void
  • A number from -255 to 255 that is added to the red channel value after it has been multiplied by the redMultiplier value.

    Returns number

  • A number from -255 to 255 that is added to the red channel value after it has been multiplied by the redMultiplier value.

    Parameters

    • value: number

    Returns void

Methods

_isRenderable

  • _isRenderable(): boolean
  • Returns boolean

clear

  • clear(): void
  • Returns void

clone

copyFrom

  • Parameters

    Returns void

copyRawDataFrom

  • copyRawDataFrom(sourceData: Float32Array): void
  • Parameters

    • sourceData: Float32Array

    Returns void

copyTo

  • Parameters

    Returns void

prepend

  • Parameters

    Returns void

Generated using TypeDoc