You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by ha...@apache.org on 2016/10/27 08:14:36 UTC

git commit: [flex-asjs] [refs/heads/refactor-sprite] - Added writing of rgba CSS attributes from color value

Repository: flex-asjs
Updated Branches:
  refs/heads/refactor-sprite 6e3071bce -> d5fd8e99a


Added writing of rgba CSS attributes from color value


Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/d5fd8e99
Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/d5fd8e99
Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/d5fd8e99

Branch: refs/heads/refactor-sprite
Commit: d5fd8e99ae60bf74011612f9246bfbb3ebf904f6
Parents: 6e3071b
Author: Harbs <ha...@in-tools.com>
Authored: Thu Oct 27 11:14:29 2016 +0300
Committer: Harbs <ha...@in-tools.com>
Committed: Thu Oct 27 11:14:29 2016 +0300

----------------------------------------------------------------------
 .../src/main/flex/org/apache/flex/utils/CSSUtils.as     | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d5fd8e99/frameworks/projects/Core/src/main/flex/org/apache/flex/utils/CSSUtils.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Core/src/main/flex/org/apache/flex/utils/CSSUtils.as b/frameworks/projects/Core/src/main/flex/org/apache/flex/utils/CSSUtils.as
index 977fb09..72abe6e 100644
--- a/frameworks/projects/Core/src/main/flex/org/apache/flex/utils/CSSUtils.as
+++ b/frameworks/projects/Core/src/main/flex/org/apache/flex/utils/CSSUtils.as
@@ -40,11 +40,19 @@ package org.apache.flex.utils
 		
         public static function attributeFromColor(value:uint):String
         {
+            var hexVal:String = value.toString(16);
 			if(value > 16777215)
 			{
-				//rgba -- return rgb notation
+                //rgba -- return rgba notation
+                var rgba:Array = hexVal.match(/.{2}/g);
+                for(var i:int = 0; i < 4; i++)
+                {
+                    rgba[i] = parseInt(rgba[i], 16);
+                }
+                rgba[3] = parseInt(""+(rgba[3]/255)*1000) / 1000;
+				return "rgba(" + rgba.join(",") + ")";
 			}
-            return "#" + StringPadder.pad(value.toString(16),"0",6);
+            return "#" + StringPadder.pad(hexVal,"0",6);
         }
         /**
          *  Converts a String to number.