diff --git a/lime/math/color/RGBA.hx b/lime/math/color/RGBA.hx index 283bd030f..ae2fac972 100644 --- a/lime/math/color/RGBA.hx +++ b/lime/math/color/RGBA.hx @@ -24,11 +24,9 @@ abstract RGBA(#if flash Int #else UInt #end) from Int to Int from UInt to UInt { private static function __init__ ():Void { - __initColors(); - - } - - private static function __initColors() { + #if (js && modular) + __initColors (); + #else __alpha16 = new UInt32Array (256); for (i in 0...256) { @@ -50,9 +48,40 @@ abstract RGBA(#if flash Int #else UInt #end) from Int to Int from UInt to UInt { __clamp[i] = 0xFF; } + #end + } + #if (js && modular) + private static function __initColors () { + + __alpha16 = new UInt32Array (256); + + for (i in 0...256) { + + __alpha16[i] = Math.ceil ((i) * ((1 << 16) / 0xFF)); + + } + + __clamp = new UInt8Array (0xFF + 0xFF); + + for (i in 0...0xFF) { + + __clamp[i] = i; + + } + + for (i in 0xFF...(0xFF + 0xFF + 1)) { + + __clamp[i] = 0xFF; + + } + + } + #end + + public inline function new (rgba:Int = 0) { this = rgba;