SuperColor 0.3

转载 2004年09月15日 12:49:00
 
 
/**
 * 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()
 *   getTint()
 *   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 six characters of the string
      hexStr = 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 brightness 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




   /**
    * Produce 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 values
    */

   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 setTint(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 properties
    * @see setTint
    */

   public function getTint():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 0xFFFFFF
    * @param percent Between 0 and 100
    */

   public function setTint2(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 0xFFFFFF number) and percent properties
    * @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 setTintOffset(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 setTintOffset
    */

   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 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
    */

   public function 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();
   }
   
}

Java中 3*0.1 == 0.3 返回值 false ,1*0.3 == 0.3 返回值 true

Java中 3*0.1 == 0.3 返回值 false ,1*0.3 == 0.3 返回值 true 4*0.1 == 0.4 返回值 true
  • icecoola_
  • icecoola_
  • 2017年10月06日 01:57
  • 503

实验0.3

吉林大学 计算方法实验课
  • GJW20160612
  • GJW20160612
  • 2017年12月12日 09:37
  • 13

LCA 0.3

LCA 基本概念 LCA是求最近公共祖先问题,有在线st/RMQ和离线Tarjan/并查集两种算法,以及倍增的特殊做法.因为代码复杂度问题,通常选用dfs实现的Tarja...
  • alpha_wendy
  • alpha_wendy
  • 2017年10月22日 21:26
  • 26

Python之0.35+0.3+0.35不等于1

在Python3中,float型即为浮点型并不是以精确的形式储存在电脑中的,故而在计算中会出现小的误差。...
  • jclian91
  • jclian91
  • 2017年10月28日 15:40
  • 224

javascript 二进制浮点数的问题,0.3-0.2不等于0.1

javascript 计算:0.4-0.3=?  0.3-0.2=?  0.2-0.1=? 先来看看实际效果: 编写javascript代码: 结果依次为: 以上就...
  • cvper
  • cvper
  • 2018年01月01日 19:28
  • 39

.0.3

  • zwb7840211
  • zwb7840211
  • 2009年09月11日 13:40
  • 268

C语言之基本算法28—硬币抛投(随机数)

//硬币抛投(随机数) /* ===================================================================== 题目:抛投两枚硬币,试分...
  • LZX19901012
  • LZX19901012
  • 2015年07月12日 14:21
  • 1009

用户须知聚丙烯酰胺水溶液粘度小知识

乐邦聚丙烯酰胺厂家应用户要求多分享一些有关聚丙稀酰胺水溶液粘度的小知识,希望此内容让大家对聚丙烯酰胺产品有更清楚的认识。     聚丙烯酰胺的高分子链在水溶液中对流动的阻力较大,故其水溶液粘度高...
  • lebangshui
  • lebangshui
  • 2014年12月09日 12:28
  • 21

CSS一级导航-天蓝色(带阴影)

一款亮丽的导航,能给网站一个画龙点睛的作用。导航在指引用户搜寻内容时,还能改变用户浏览网站的心情,浏览网站也像一场旅行,有创意的导航栏让用户欣赏起来也会更加愉悦,增加对网站的兴趣。 本人不擅长美工制...
  • tangyifeng123
  • tangyifeng123
  • 2015年11月10日 14:51
  • 396

pytorch 0.3发布(0.3.0b0),更新信息以及更新步骤

pytorch 0.3发布了性能提升、新的网络层,支持ONNX,正式支持CUDA9、CuDNNv7,大量bug修复。 Performance improvements, new layers, sh...
  • IAMoldpan
  • IAMoldpan
  • 2017年12月08日 16:36
  • 1032
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:SuperColor 0.3
举报原因:
原因补充:

(最多只允许输入30个字)