Supercolor 0.3

xiaoxiao2021-03-06  56

/ ** * Super Color * Extended Color Class * * --------------------------------- * * Based on Robert PENNER Color Toolkit v1.3 * * Properties * * _brightness * _brightOffset * _contrast * _negative * * _rgb * _rgbStr * _red * _green * _blue * * _redPercent * _greenPercent * _bluePercent * * _redOffset * _greenOffset * _blueOffset * * Methods * * getTarget () * * setRGBStr () * getRGBStr () * setRGB2 () * getRGB2 () * reset () * * setBrightness () * getBrightness () * setBrightOffset () * getBrightOffset () * setContrast () * getContrast () * * GetNegative () * setnegative () * invert () * * settint () * gett () * settint2 () * gettint2 () * settintoffset () * gettintoffset () * * setred () * getred () * setgreen () * getGreen () * setBlue () * getBlue () * * setRedPercent () * getRedPercent () * setGreenPercent () * getGreenPercent () * setBluePercent () * getBluePercent () * * setRedOffset () * getRedOffset () * Setgreenoffset () * getGreenoffset () * setBlueoffset () * getBlueoffset () * * @version 0.3 * @Author lalex * @since 19/08/2004 * /

Class com.lalex.movieClip.supercolor

Extends

Color {

Private

Var_targetmc:

MovieClip;

/ ** * constructor * @Param Clip Clip to Apply the color * /

Function Supercolor (CLIP:

MovieClip) {

Super (CLIP);

_targetmc = clip;

}

/ ** * returns affected clip * @Return Targeted movieclip * /

public

Function getTARGET ():

MovieClip {

Return_targetmc;

}

// ---------- O RGB

/ ** * set an rgb value from an Hexadecimal String * @Param HexStr Hexadecimal value string * /

public

Function setRGBSTR (HEXSTR:

String) {

// grab the last saracters of the stringhexstr = hexstr.

Substr (-6, 6);

SETRGB

PARSEINT (HEXSTR, 16));

}

/ ** * get the rgb value as a string * @return Hexadecimal Value String * /

public

Function getRGBSTR ():

String {

Var HEXSTR:

String =

GetRGB ().

TOSTRING (16);

// Fill in Zeroes as needed

VAR TOFILL:

Number = 6 - HEXSTR.

Length;

While (TOFILL -) HEXSTR =

"0" hexstr;

Return HEXSTR.

TouPpercase ();

}

/ ** * SET Red, Green, And Blue with Normal NumBers * @Param R Red Value Between 0 and 255 * @Param G Greeb Value Between 0 and 255 * @Param B Blue Value Between 0 and 255 * /

public

Function setRGB2 (R:

Number, g:

Number, B:

Number) {

SetRGB (r << 16 | g << 8 | b);

}

// BRANDEN HALL - www.figleaf.com

/ ** * @Return Object with r, g, and b properties * /

public

Function getRGB2 ():

Object {

Var t =

GetTransform ();

Return {r: T.RB, G: T.GB, B: T.BB};

}

/ ** * reset the color object to normal * /

public

Function reset (): void {

Settransform ({RA: 100, GA: 100, BA: 100, RB: 0, GB: 0, BB: 0});

}

// ---------- o Brightness

/ ** * Brighten Just Like Property Inspector of movieClip * @Param Val Brightness BetWeen -100 and 100 * /

public

Function SetBrightness (VAL:

Number) {

VAR Trans:

Object =

GetTransform ();

WITH (Trans) {

Ra = Ga = ba = 100 -

Math.

ABS (VAL);

RB = GB = bb = (VAL> 0)? VAL * (256/100): 0;

}

SetTransform (Trans);

}

/ ** * @Return Brightness Set with setBrightness * @see setbrightness * /

public

Function GetBrightness ():

Number {

VAR Trans:

Object =

GetTransform ();

WITH (Trans) {

RETURN RB? 100 - RA: RA - 100;

}

/ ** * set bigtness offset * @Param Val Offset BetWeen -255 and 255 * /

public

Function setBrightoffset (VAL:

Number) {

VAR Trans:

Object =

GetTransform ();

WITH (Trans) {

RB = GB = bb = Val;

}

SetTransform (Trans);

}

/ ** * @Return Brightness Set with setBrightoffset * @see setbrightoffset * /

public

Function getBrightoffset ():

Number {

Return

GetTransform (). RB;

}

// ---------- o Contrast

/ ** * set contrast * @Param Val percent BetWeen -100 and 100 * /

public

Function SetContrast (VAL:

Number) {

VAR Trans:

Object = {};

Trans. RA = Trans.ga = Trans.ba = VAL;

Trans. rb = trans.gb = trans.bb = 128 - (128/100 * VAL);

SetTransform (Trans);

}

/ ** * @return contrast set with setContrast * @see setContrast * /

public

Function getContrast ():

Number {

Return

GetTransform (). RA;

}

// ---------- o NEGATIVE and INVERT

/ ** * Product a negative image of the Normal Appearance * @Param Percent BetWeen 0 and 100 * /

public

Function setnegative (percent:

Number) {

Var T:

Object = {};

T.RA = T.Ga = T.ba = 100 - 2 * percent;

T.RB = T.GB = T.BB = percent * (255/100);

SetTransform (T);

}

/ ** * @Return Negative percentage * @see setnegative * /

public

Function getNegative ():

Number {

Return

GetTransform (). RB * (100/255);

}

/ ** * Invert the current color value * /

public

Function inVert () {

VAR Trans:

Object =

GetTransform ();

WITH (Trans) {

Ra = -RA;

Ga = -GA;

BA = -ba;

RB = 255 - RB;

GB = 255 - GB;

BB = 255 - bb;

}

SetTransform (Trans);

}

// ---------- o Tint

/ ** * Tint with a color just like Property Inspector * @param r Red value between 0 and 255 * @param g Greeb value between 0 and 255 * @param b Blue value between 0 and 255 * @param percent Between 0 and 100 * / public

Function Sett (R:

Number, g:

Number, B:

Number, percent:

Number) {

Var ratio = percent / 100;

VAR trans = {RB: r * Ratio, GB: g * ratio, bb: b * ratio};

Trans. RA = Trans.ga = Trans.ba = 100 - percent;

SetTransform (Trans);

}

/ ** * @return Tint Object Containing r, g, b, and percent profment * @see sett * /

public

Function Gett ():

Object {

VAR Trans:

Object =

GetTransform ();

VAR TINT:

Object = {Percent: 100 - Trans.ra};

Var Ratio:

Number = 100 / tint.percent;

Tint.r = trans. rb * ratio;

Tint.g = trans.gb * ratio;

Tint.b = trans.bb * ratio;

Return Tint;

}

/ ** * Tint with a color - Alternate Approach * @Param RGB Color Number BetWeen 0 and 0xfffffff * @Param Percent Between 0 and 100 * /

public

Function sett2 (RGB:

Number, percent:

Number) {

Var r:

Number = (RGB >> 16);

Var g:

Number = (RGB >> 8) & 0xFF;

VAR B:

Number = RGB & 0xFF;

Var Ratio:

Number = percent / 100;

VAR Trans:

Object = {RB: r * Ratio, GB: G * Ratio, BB: b * ratio};

Trans. RA = Trans.ga = Trans.ba = 100 - percent;

SetTransform (Trans);

}

/ ** * @Return a Tint Object Containing RGB (a 0xfffff number) and percent property * @see settint2 * /

public

Function GettinT2 ():

Object {

VAR Trans:

Object =

GetTransform ();

VAR TINT:

Object = {Percent: 100 - Trans.ra};

Var Ratio:

Number = 100 / tint.percent;

Tint.rgb = (trans. rb * ratio) << 16 | (trans.gb * ratio) << 8 | Trans.bb * Ratio; Return Tint;

}

// ---------- o Tint offset

/ ** * @Param r red value betWeen 0 and 255 * @Param g Greeb value betWeen 0 and 255 * @Param B Blue Value Between 0 and 255 * /

public

Function SettOffset (R:

Number, g:

Number, B:

Number) {

VAR Trans:

Object =

GetTransform ();

WITH (Trans) {

RB = R;

GB = g;

BB = B;

}

SetTransform (Trans);

}

/ ** * @Return Object Containing R, G, B Properties * @see settoffset * /

public

Function GettintOffset ():

Object {

Var T:

Object =

GetTransform ();

Return {r: T.RB, G: T.GB, B: T.BB};

}

// ---------- O Color Values

/ ** * set red value * @Param Amount BetWeen 0 and 255 * /

public

Function Setred (Amount:

Number) {

Var t =

GetTransform ();

SETRGB (Amount << 16 | T.GB << 8 | T.BB);

}

/ ** * get red value * @Return Value Between 0 and 255 * @see setred * /

public

Function getRed ():

Number {

Return

GetTransform (). RB;

}

/ ** * set green value * @Param Amount BetWeen 0 and 255 * /

public

Function SetGreen (Amount:

Number) {

Var t =

GetTransform ();

SetRGB (T.RB << 16 | Amount << 8 | T.BB);

}

/ ** * get green value * @Return Value Between 0 and 255 * @see setgreen * /

public

Function getGreen ():

Number {

Return

GetTransform (). GB;

}

/ ** * set blue value * @Param Amount BetWeen 0 and 255 * /

public

Function SetBlue (Amount:

Number) {

Var t =

GetTransform ();

SetRGB (T.RB << 16 | T.GB << 8 | Amount);

}

/ ** * get blue value * @Return Value Between 0 and 255 * @see setblue * / public

Function getBlue ():

Number {

Return

GetTransform (). bb;

}

// ---------- O Color Percentages

/ ** * set red percentage * @Param percent BetWeen -100 and 100 * /

public

Function setredPercent (Percent:

Number) {

VAR Trans:

Object =

GetTransform ();

Trans. RA = percent;

SetTransform (Trans);

}

/ ** * get red percentage * @Return Value BetWeen -100 and 100 * @see setredPercent * /

public

Function getredPercent ():

Number {

Return

GetTransform (). RA;

}

/ ** * set green percentage * @Param percent BetWeen -100 and 100 * /

public

Function setGreenpercent (Percent:

Number) {

VAR Trans:

Object =

GetTransform ();

Trans.ga = percent;

SetTransform (Trans);

}

/ ** * get green percentage * @Return Value BetWeen -100 and 100 * @see setgreenpercent * /

public

Function getGreenpercent ():

Number {

Return

GetTransform (). GA;

}

/ ** * set blue percentage * @Param percent BetWeen -100 and 100 * /

public

Function setBluePercent (Percent:

Number) {

VAR Trans:

Object =

GetTransform ();

Trans.ba = percent;

SetTransform (Trans);

}

/ ** * get blue percentage * @Return Value BetWeen -100 and 100 * @see setbluePercent * /

public

Function getBluePercent ():

Number {

Return

GetTransform (). ba;

}

// ---------- O Color Offsets

/ ** * set red offset * @Param Offset BetWeen -255 and 255 * /

public

Function setRedoffset (Offset:

Number) {

VAR Trans:

Object =

GetTransform ();

TRANS.RB = OFFSet;

SetTransform (Trans);

}

/ ** * get red offset * @Return Value BetWeen -255 and 255 * @see set @ @See setRedoffset * / public

Function getRedoffset ():

Number {

Return

GetTransform (). RB;

}

/ ** * set green offset * @Param Offset BetWeen -255 and 255 * /

public

Function setGreenoffset (Offset:

Number) {

VAR Trans:

Object =

GetTransform ();

Trans.gb = OFFSET;

SetTransform (Trans);

}

/ ** * get green offset * @Return Value BetWeen -255 and 255 * @see setgreenoffset * /

public

Function getGreenoffset ():

Number {

Return

GetTransform (). GB;

}

/ ** * SET Blue Offset * @Param Offset BetWeen -255 and 255 * /

public

Function setBlueoffset (Offset:

Number) {

VAR Trans:

Object =

GetTransform ();

Trans.bb = OFFSET;

SetTransform (Trans);

}

/ ** * get blue offset * @return value betWeen -255 and 255 * @see setblueoffset * /

public

Function getBlueoffset ():

Number {

Return

GetTransform (). bb;

}

// ---------- o getter / setter

/ ** * RGB Value * @Type Number * /

FUNCTION

Set _RGB (VAL:

Number) {

SetRGB (VAL);

}

FUNCTION

GET _RGB ():

Number {

Return

GETRGB ();

}

/ ** * RGB Value * @Type string * /

FUNCTION

Set _RGBSTR (VAL:

String) {

SetRGBSTR (VAL);

}

FUNCTION

GET _RGBSTR ():

String {

Return getRGBSTR ();

}

/ ** * Brightness value * @Type Number * /

FUNCTION

Set _brightness (B:

Number) {

Setbrightness (b);

}

FUNCTION

GET _BRIGHTNESS ():

Number {

Return getbrightness ();

}

/ ** * Brightness offset * @Type Number * /

FUNCTION

Set _brightoffset (B:

Number) {

Setbrightoffset (b);

}

public

FUNCTION

GET _BRIGHTOFFSET ():

Number {

Return getBrightoffset ();

}

/ ** * Contrast * @Type Number * / Function

Set _Contrast (C:

Number) {

SetContraSt (C);

}

public

FUNCTION

GET _CONTRAST ():

Number {

Return getContrast ();

}

/ ** * negative percentage * @Type Number * /

public

FUNCTION

Set_negative (p:

Number) {

Setnegative (P);

}

public

FUNCTION

GET _NEGATIVE ():

Number {

Return getNegative ();

}

/ ** * red value * @Type Number * /

public

FUNCTION

Set_red (v:

Number) {

Setred (V);

}

public

FUNCTION

GET _RED ():

Number {

Return getred ();

}

/ ** * Green value * @Type Number * /

public

FUNCTION

Set_green (V:

Number) {

Setgreen (V);

}

public

FUNCTION

Get _Green ():

Number {

Return getGreen ();

}

/ ** * Blue value * @Type Number * /

public

FUNCTION

Set _blue (V:

Number) {

SetBlue (v);

}

public

FUNCTION

GET _BLUE ():

Number {

Return getBlue ();

}

/ ** * red percentage * @Type Number * /

public

FUNCTION

Set _redpercent (V:

Number) {

SetredPercent (V);

}

public

FUNCTION

GET _REDpercent ():

Number {

Return getredPercent ();

}

/ ** * Green percentage * @Type Number * /

public

FUNCTION

Set _Greenpercent (V:

Number) {

SetGreenpercent (V);

}

public

FUNCTION

Get _Greenpercent ():

Number {

Return getGreenpercent ();

}

/ ** * blue percentage * @Type Number * /

public

FUNCTION

Set _BluePercent (V:

Number) {

SetBluePercent (V);

}

public

FUNCTION

GET _BLUEPERCENT ():

Number {

Return getBluePercent ();

}

/ ** * red offset * @Type Number * /

public

FUNCTION

Set _redoffset (V:

Number) {

Setredoffset (V);

}

public

FUNCTION

GET _REDOFFSET ():

Number {

Return getRedoffset ();

}

/ ** * green offset * @Type Number * /

PUBLICFUNCTION

Set_greenoffset (V:

Number) {

Setgreenoffset (V);

}

public

FUNCTION

Get _Greenoffset ():

Number {

Return getGreenoffset ();

}

/ ** * Blue Offset * @Type Number * /

public

FUNCTION

Set _blueoffset (V:

Number) {

SetBlueoffset (V);

}

public

FUNCTION

GET _BLUEOFFSET ():

Number {

Return getBlueoffset ();

}

}

转载请注明原文地址:https://www.9cbs.com/read-116752.html

New Post(0)