JavaScript Burns or dodges the colors

// hex color rgb color transfer 
function HexToRgb (STR) {
     var R & lt = / ^ \ # [0-9A-F.]. 6} {$ /? ;
     // Test method checks whether there is a pattern in the string, if present returns true, otherwise returns false 
    IF (R.TEST (str)!) return window.alert ( "input error of hex" );
     // to find a replacement string replace 
    str = str.replace ( "#", "" );
     // match query array obtained 
    var HXS = str.match (/../ G);
     // Alert ( 'BF:' HXS +) 
    for ( var I = 0; I <. 3; I ++) HXS [ I] = the parseInt (HXS [I], 16 );
     // Alert (the parseInt (80, 16)) 
    // the console.log (HXS);
    return HXS; 
} 

// GRB color Color Hex turn 
function RgbToHex (A, B, C) {
     var R & lt = / ^ \ $ D {l, 3} / ;
     IF !! (R.TEST (A) R & lt ||. ! Test (B) || R.TEST (C)) return window.alert ( "rgb color value of the input error" );
     var hexs = [a.toString (16), b.toString (16), c.toString (16 )];
     for ( var I = 0; I <. 3; I ++) IF (hexs [I] == .length. 1) hexs [I] = "0" + [I] hexs;
     return "#" + hexs .join ( "" ); 
} 

// between 0-1 to obtain color values hex color deepening color value, level of deeper level, the limit 
function getDarkColor (color, level) {
    var R & lt = / ^ \ # [0-9A-F.]. 6} {$ /? ;
     IF (R.TEST (Color)!) return window.alert ( "hex color value of the input error" );
     var RGBC = the this .HexToRgb (Color);
     // Floor rounded down 
    for ( var I = 0; I <. 3; I ++) RGBC [I] = Math.floor (RGBC [I] * (. 1 - Level));
     return  the this . RgbToHex (RGBC [0], RGBC [. 1], RGBC [2 ]); 
} 

// get lighten the color values of the color hex color values, level of deeper level, the margin between 0-1 
function getLightColor (color, Level) {
     var R & lt = / ^ \ # [0-9A-F.]. 6} {$ /? ;
     IF ) (R.TEST (Color!) returnwindow.alert ( "hex color value of the input error" );
     var RGBC = the this .HexToRgb (Color);
     for ( var I = 0; I <. 3; I ++) RGBC [I] Math.floor = ((255 - RGBC [I]) + * Level RGBC [I]);
     return  the this .RgbToHex (RGBC [0], RGBC [. 1], RGBC [2 ]); 
}

Transfer from https://blog.csdn.net/zhh0310235/article/details/99985866

Guess you like

Origin www.cnblogs.com/wxxwjef/p/11419202.html