Results 1 to 2 of 2

Thread: Ext.util.Color

  1. #1
    Sencha User demon222's Avatar
    Join Date
    Jan 2008
    Location
    Poland, Warsaw
    Posts
    134
    Vote Rating
    4
      0  

    Default Ext.util.Color

    simple color invert function

    use: Ext.util.Color.invertHex('ffffff') - > 000000

    PHP Code:
    Ext.util.Color = function() {
        return {
                    
    decToHex: function( ) {
                            var 
    HCHARS '0123456789ABCDEF';
                            
    parseInt(n10);
                            
    = ( !isNaN)) ? 0;
                            
    = (255 || 0) ? n;
                            return 
    HCHARS.charAt( ( 16 ) / 16 ) + HCHARS.charAt16 );
                    },
            
    getHCharPos: function( ) {
                var 
    HCHARS '0123456789ABCDEF';
                return 
    HCHARS.indexOfc.toUpperCase() );
            },
            
    hexToDec: function( hex ) {
                var 
    hex.split('');
                return ( ( 
    Ext.util.Color.getHCharPoss[0] ) * 16 ) + Ext.util.Color.getHCharPoss[1] ) );
            },
                    
    rgbToHex: function( rg) {
                            if( 
    instanceof Array ) { return Ext.util.Color.rgbToHex.callthisr[0], r[1], r[2] ); }
                            return 
    Ext.util.Color.decToHex) + Ext.util.Color.decToHex) + Ext.util.Color.decToHex);
                    },               
            
    hexToRgb: function( hex ) {
                return [ 
    Ext.util.Color.hexToDechex.substr(02) ), Ext.util.Color.hexToDechex.substr(22) ), Ext.util.Color.hexToDechex.substr(42) ) ];
            },
            
    invertRgb: function( rg) {
                if( 
    instanceof Array ) { return Ext.util.Color.invertRgb.callthisr[0], r[1], r[2] ); }
                return [
    255-r,255-g,255-b];
            },
                    
    invertHex: function( hex ) {
                        var 
    rgb Ext.util.Color.hexToRgb(hex),
                        
    invert =  Ext.util.Color.invertRgb(rgb[0], rgb[1], rgb[2]);
                        return 
    Ext.util.Color.rgbToHex(invert[0], invert[1], invert[2]);
                    }
        }
    }(); 

  2. #2
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,556
    Vote Rating
    1272
      0  

    Default

    Nice!
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it! Checkout the CODE tag!

    Check out my GitHub, lots of nice things for Ext JS and Sencha Touch
    https://github.com/mitchellsimoens

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •