working on it ...

Filters

Explore Public Snippets

Sort by

Found 2,084 snippets matching: colors

    public by johansonkatherine  4893  0  6  3

    Java code for Changing Color Space of PDF Document

    This code shows how java developers can change color space of PDF document from RGB color to CMYK and vice versa by using Aspose.PDF for Java Library. The following methods have been implemented in the Operator class for changing colors. Use it to change some specific RGB/CMYK colors to CMYK/RGB color space, keeping the remaining PDF document as it
    Document doc = new Document(myDir + "input_color.pdf");
    OperatorCollection contents = doc.getPages().get_Item(1).getContents();
    System.out.println("Values of RGB color operators in the pdf document");
    for (int j = 1; j <= contents.size(); j++)
        {
    	Operator oper = contents.get_Item(j);
    	if (oper instanceof Operator.SetRGBColor || oper instanceof Operator.SetRGBColorStroke)
    	try {
    	    //Converting RGB to CMYK color
    	    System.out.println(oper.toString());
    
    	    double[] rgbFloatArray = new double[]
    	        {
    		    	Double.valueOf(oper.getParameters().get(0).toString()),
    		    	Double.valueOf(oper.getParameters().get(1).toString()),
    		    	Double.valueOf(oper.getParameters().get(2).toString()),
    	        };
    	    double[] cmyk = new double[4];
    	    if (oper instanceof Operator.SetRGBColor)
    	    {
    		((Operator.SetRGBColor)oper).getCMYKColor(rgbFloatArray, cmyk);
    		contents.set_Item(j, new Operator.SetCMYKColor(cmyk[0], cmyk[1], cmyk[2], cmyk[3]));
    		}
    		else if (oper instanceof Operator.SetRGBColorStroke)
    		{
    		    ((Operator.SetRGBColorStroke)oper).getCMYKColor(rgbFloatArray, cmyk);
    		   contents.set_Item(j, new Operator.SetCMYKColorStroke(cmyk[0], cmyk[1], cmyk[2], cmyk[3]));
    		}
    		    else
    throw new java.lang.Throwable("Unsupported command");
    
    	} catch (Throwable e) {
    	    e.printStackTrace();
    	}
    		        }
    doc.save(myDir + "input_colorout.pdf");
    
    //Testing the result
    System.out.println("Values of converted CMYK color operators in the result pdf document");
    doc = new Document(myDir + "input_colorout.pdf");
    contents = doc.getPages().get_Item(1).getContents();
    for (int j = 1; j <= contents.size(); j++)
        {
    	Operator oper = contents.get_Item(j);
    	if (oper instanceof Operator.SetCMYKColor || oper instanceof Operator.SetCMYKColorStroke)
    	{
    	   System.out.println(oper.toString());
    	}
       }
    

    public by FrancoFolini  4233  1  7  5

    TypeScript Module to define CSS color names

    module CssColors {
    
        export const AliceBlue = '#F0F8FF';
        export const AntiqueWhite = '#FAEBD7';
        export const Aqua = '#00FFFF';
        export const Aquamarine = '#7FFFD4';
        export const Azure = '#F0FFFF';
        export const Beige = '#F5F5DC';
        export const Bisque = '#FFE4C4';
        export const Black = '#000000';
        export const BlanchedAlmond = '#FFEBCD';
        export const Blue = '#0000FF';
        export const BlueViolet = '#8A2BE2';
        export const Brown = '#A52A2A';
        export const BurlyWood = '#DEB887';
        export const CadetBlue = '#5F9EA0';
        export const Chartreuse = '#7FFF00';
        export const Chocolate = '#D2691E';
        export const Coral = '#FF7F50';
        export const CornflowerBlue = '#6495ED';
        export const Cornsilk = '#FFF8DC';
        export const Crimson = '#DC143C';
        export const Cyan = '#00FFFF';
        export const DarkBlue = '#00008B';
        export const DarkCyan = '#008B8B';
        export const DarkGoldenRod = '#B8860B';
        export const DarkGray = '#A9A9A9';
        export const DarkGrey = '#A9A9A9';
        export const DarkGreen = '#006400';
        export const DarkKhaki = '#BDB76B';
        export const DarkMagenta = '#8B008B';
        export const DarkOliveGreen = '#556B2F';
        export const DarkOrange = '#FF8C00';
        export const DarkOrchid = '#9932CC';
        export const DarkRed = '#8B0000';
        export const DarkSalmon = '#E9967A';
        export const DarkSeaGreen = '#8FBC8F';
        export const DarkSlateBlue = '#483D8B';
        export const DarkSlateGray = '#2F4F4F';
        export const DarkSlateGrey = '#2F4F4F';
        export const DarkTurquoise = '#00CED1';
        export const DarkViolet = '#9400D3';
        export const DeepPink = '#FF1493';
        export const DeepSkyBlue = '#00BFFF';
        export const DimGray = '#696969';
        export const DimGrey = '#696969';
        export const DodgerBlue = '#1E90FF';
        export const FireBrick = '#B22222';
        export const FloralWhite = '#FFFAF0';
        export const ForestGreen = '#228B22';
        export const Fuchsia = '#FF00FF';
        export const Gainsboro = '#DCDCDC';
        export const GhostWhite = '#F8F8FF';
        export const Gold = '#FFD700';
        export const GoldenRod = '#DAA520';
        export const Gray = '#808080';
        export const Grey = '#808080';
        export const Green = '#008000';
        export const GreenYellow = '#ADFF2F';
        export const HoneyDew = '#F0FFF0';
        export const HotPink = '#FF69B4';
        export const IndianRed = '#CD5C5C';
        export const Indigo = '#4B0082';
        export const Ivory = '#FFFFF0';
        export const Khaki = '#F0E68C';
        export const Lavender = '#E6E6FA';
        export const LavenderBlush = '#FFF0F5';
        export const LawnGreen = '#7CFC00';
        export const LemonChiffon = '#FFFACD';
        export const LightBlue = '#ADD8E6';
        export const LightCoral = '#F08080';
        export const LightCyan = '#E0FFFF';
        export const LightGoldenRodYellow = '#FAFAD2';
        export const LightGray = '#D3D3D3';
        export const LightGrey = '#D3D3D3';
        export const LightGreen = '#90EE90';
        export const LightPink = '#FFB6C1';
        export const LightSalmon = '#FFA07A';
        export const LightSeaGreen = '#20B2AA';
        export const LightSkyBlue = '#87CEFA';
        export const LightSlateGray = '#778899';
        export const LightSlateGrey = '#778899';
        export const LightSteelBlue = '#B0C4DE';
        export const LightYellow = '#FFFFE0';
        export const Lime = '#00FF00';
        export const LimeGreen = '#32CD32';
        export const Linen = '#FAF0E6';
        export const Magenta = '#FF00FF';
        export const Maroon = '#800000';
        export const MediumAquaMarine = '#66CDAA';
        export const MediumBlue = '#0000CD';
        export const MediumOrchid = '#BA55D3';
        export const MediumPurple = '#9370DB';
        export const MediumSeaGreen = '#3CB371';
        export const MediumSlateBlue = '#7B68EE';
        export const MediumSpringGreen = '#00FA9A';
        export const MediumTurquoise = '#48D1CC';
        export const MediumVioletRed = '#C71585';
        export const MidnightBlue = '#191970';
        export const MintCream = '#F5FFFA';
        export const MistyRose = '#FFE4E1';
        export const Moccasin = '#FFE4B5';
        export const NavajoWhite = '#FFDEAD';
        export const Navy = '#000080';
        export const OldLace = '#FDF5E6';
        export const Olive = '#808000';
        export const OliveDrab = '#6B8E23';
        export const Orange = '#FFA500';
        export const OrangeRed = '#FF4500';
        export const Orchid = '#DA70D6';
        export const PaleGoldenRod = '#EEE8AA';
        export const PaleGreen = '#98FB98';
        export const PaleTurquoise = '#AFEEEE';
        export const PaleVioletRed = '#DB7093';
        export const PapayaWhip = '#FFEFD5';
        export const PeachPuff = '#FFDAB9';
        export const Peru = '#CD853F';
        export const Pink = '#FFC0CB';
        export const Plum = '#DDA0DD';
        export const PowderBlue = '#B0E0E6';
        export const Purple = '#800080';
        export const RebeccaPurple = '#663399';
        export const Red = '#FF0000';
        export const RosyBrown = '#BC8F8F';
        export const RoyalBlue = '#4169E1';
        export const SaddleBrown = '#8B4513';
        export const Salmon = '#FA8072';
        export const SandyBrown = '#F4A460';
        export const SeaGreen = '#2E8B57';
        export const SeaShell = '#FFF5EE';
        export const Sienna = '#A0522D';
        export const Silver = '#C0C0C0';
        export const SkyBlue = '#87CEEB';
        export const SlateBlue = '#6A5ACD';
        export const SlateGray = '#708090';
        export const SlateGrey = '#708090';
        export const Snow = '#FFFAFA';
        export const SpringGreen = '#00FF7F';
        export const SteelBlue = '#4682B4';
        export const Tan = '#D2B48C';
        export const Teal = '#008080';
        export const Thistle = '#D8BFD8';
        export const Tomato = '#FF6347';
        export const Turquoise = '#40E0D0';
        export const Violet = '#EE82EE';
        export const Wheat = '#F5DEB3';
        export const White = '#FFFFFF';
        export const WhiteSmoke = '#F5F5F5';
        export const Yellow = '#FFFF00';
        export const YellowGreen = '#9ACD32';
    
    }
    
    // Example (Tested on TypeScript Playground)
    var e = document.createElement('div');
    e.style.backgroundColor = CssColors.BlanchedAlmond;
    e.style.color = CssColors.Red;
    e.innerText = 'Example';
    document.body.appendChild(e);                        

    public by Shambles  2634  1  6  1

    Invert a hex color

    	invertColor:function(inputColor){
                var color = inputColor;
                color = color.substring(1);           // remove #
                color = parseInt(color, 16);          // convert to integer
                color = 0xFFFFFF ^ color;             // invert three bytes
                color = color.toString(16);           // convert to hex
                color = ("000000" + color).slice(-6); // pad with leading zeros
                color = "#" + color;                  // prepend #
                return color;
    	}

    public by rfornal  2437  1  6  1

    Simple: Alternate Row Colors (cn be used for ordered list [li], unordered list[li], or tables [using tr]). More correct than nth-of-type which can get dicey when selecting DOM elements. The LI and TR can be switched to almost any HTML tag.

    li:nth-child(even) {
      background-color: red;
    }
    li:nth-child(odd) {
      background-color: white;
    }
    
    tr:nth-child(even) {
      background-color: red;
    }
    tr:nth-child(odd) {
      background-color: white;
    }
    

    public by tomsim  1304  1  6  0

    Barplot R

    # This is a simple example to look at survival rate of Titanic passenger by ticket class
    #
    # Load data - note that read.csv can only read http NOT https
    # so change any url with https to http and hope that the web site support it
    tn = read.csv('http://vincentarelbundock.github.io/Rdatasets/csv/datasets/Titanic.csv')
    # list table column names
    names(tn)
    # list first few rows of data
    cat("first few rows:","\n")
    head(tn)
    # This table has data already summarized by Class, Sex, Age, Survived
    # Let's summarize it by passenger class and whether they survived
    fs = aggregate(tn$Freq, by=list(tn$Class, tn$Survived), FUN=sum)
    cat("Display variable freq summarized by passenger class and live/die:","\n")
    # the variable name by itself is a command to show what's in it
    fs
    # rename the summarized table columns so that they make more sense
    names(fs) = c("Class","Survived","Sum")
    fs
    # Transpose the data into a matrix to make it easier to bargraph
    # This is done in 2 steps
    # 1. order the data by the variable that will become the column and row names of the matrix
    # 2. use the reshape function to do the transpose
    # 3. set empty space in matrix with 0 so we don't get error when using them (this happen when row*col != total data row)
    rowOrder = order(fs$Class,fs$Survived,fs$Sum)
    fs = fs[rowOrder,]
    tfs = reshape( fs, v.name='Sum', idvar='Survived', timevar='Class', direction='wide')
    tfs[is.na(tfs)] = 0
    # set the matrix row name to make it looks nice :)
    row.names(tfs) = tfs$Survived
    tfs
    # create the matrix of the number part (don't need first column of yes/no)
    # the notation [,-1] means all row, all column minus 1st one
    m = as.matrix(tfs[,-1])
    # set the column names of the matrix to the passenger class
    colnames(m) = levels(fs$Class)
    m
    # Setup color to plot (see http://www.r-bloggers.com/color-palettes-in-r/ for example color palettes)
    colorSet = rainbow(length(row.names(m)))
    # Finally, we get to plot the data!
    barplot(m, col=colorSet)
    # And set the legend text
    legend('topleft', legend=row.names(m), col=colorSet, title='Survived', fill=colorSet)

    public by stevereich  1417  0  3  0

    This Coldfusion function takes an array of hex colors and sorts them from light to dark.

    This Coldfusion function takes an array of hex colors and sorts them from light to dark.: sortHexColors.cfm
    <cfscript>
    	private Array function sortHexColors(required Array colorArray) {
    		var valArray = [];
    		var sortArray = [];
    		for(var i=1;i<=arraylen(arguments.colorArray);i++) {
    			var color = replacenocase(arguments.colorArray[i], '##', '', 'ALL');
    			if(len(color) == 6) {
    				var strRed = mid(color, 1, 2);
    				var strGreen = mid(color, 3, 2);
    				var strBlue = mid(color, 5, 2);
    				// this formula comes from https://en.wikipedia.org/wiki/HSL_and_HSV
    				var retVal = (0.21 * inputbaseN(strRed, 16)) + (0.72 * inputbaseN(strGreen, 16)) + (0.07 * inputbaseN(strBlue, 16));
    				var tempObj = {};
    					tempObj['###color#'] = retVal;
    					arrayappend(sortArray,tempObj);
    					arrayappend(valArray,retVal);
    			}
    		}
    		arraysort(valArray,'numeric','desc');
    		var returnArray = [];
    		for(var ii=1;ii<=arraylen(valArray);ii++){
    			for(var j=1;j<=arraylen(sortArray);j++){
    				for(key in sortArray[j]){
    					if(sortArray[j][key] == valArray[ii]){
    						arrayappend(returnArray,key);
    						continue;
    					}
    				}
    			}
    		
    		}
    		return returnArray;
    	}
    	variables.unsortedColors = ['##2A2A2A','##777777','##373737','##b7b7b7','##333333','##505050','##3C3C3C','##d0d0d0','##7f7f7f','##323232'];
    	variables.sortedColors = sortHexColors(variables.unsortedColors);
    	
    	writeoutput("<div style='padding:0;margin:0;width:"&arraylen(variables.unsortedColors)*100&"px;height:100px'>");
    		for(i=1;i<=arraylen(variables.unsortedColors);i++){		
    			writeoutput("<div class='colorBox' style='padding:0;margin:0;height:100px;width:100px;display:inline-block;position:relative;background-color:#variables.unsortedColors[i]#'></div>");
    		};
    		for(ii=1;ii<=arraylen(variables.sortedColors);ii++){
    			writeoutput("<div class='colorBox' style='padding:0;margin:0;height:100px;width:100px;display:inline-block;position:relative;background-color:#variables.sortedColors[ii]#'></div>");
    		};
    	writeoutput("</div>");
    </cfscript>	
    
    

    public by Derek  253  0  3  0

    my dark background friendly dir colors

    my dark background friendly dir colors: dircolors
    #############################################################################
    # Below are the color init strings for the basic file types. A color init
    # string consists of one or more of the following numeric codes:
    #
    # -------------- [ ATTRIBUTES ] -------------- 
    #   00=none 01=bold 04=underscore 05=blink 07=reverse 08=concealed
    # Text color codes:
    #   30=black 31=red 32=green 33=yellow 34=blue 35=magenta 36=cyan 37=white
    # Background color codes:
    #   40=black 41=red 42=green 43=yellow 44=blue 45=magenta 46=cyan 47=white
    #
    # -------------- [  MORE INFO  ] -------------- 
    # - See http://www.oreilly.com/catalog/wdnut/excerpt/color_names.html
    #
    # -------------- [ COLOR CODES ] -------------- 
    # 0 = Default Colour
    # 1 = Bold
    # 4 = Underlined
    # 5 = Flashing Text
    # 7 = Reverse Field
    # 31 =    Red
    # 32 =    Green
    # 33 =    Orange
    # 34 =    Blue
    # 35 =    Purple
    # 36 =    Cyan
    # 37 =    Grey
    # 40 =    Black Background
    # 41 =    Red Background
    # 42 =    Green Background
    # 43 =    Orange Background
    # 44 =    Blue Background
    # 45 =    Purple Background
    # 46 =    Cyan Background
    # 47 =    Grey Background
    # 90 =    Dark Grey
    # 91 =    Light Red
    # 92 =    Light Green
    # 93 =    Yellow
    # 94 =    Light Blue
    # 95 =    Light Purple
    # 96 =    Turquoise
    # 100 =   Dark Grey Background
    # 101 =   Light Red Background
    # 102 =   Light Green Background
    # 103 =   Yellow Background
    # 104 =   Light Blue Background
    # 105 =   Light Purple Background
    # 106 =   Turquoise Background
    #
    # -------------- [ EXAMPLES ] -------------- 
    #
    #   01;32 bright green 
    #   01;34 bright blue
    #   01;37 bright white 
    # 
    #   05;37;41 flashing white text on red background
    #
    
    # ------------- [ INSTALATION ] -------------- 
    # This file goes in the /etc directory, and must be world readable.
    # You can copy this file to .dir_colors in your $HOME directory to override
    # the system defaults.
    #
    # COLOR needs one of these arguments: 'tty' colorizes output to ttys, but not
    # pipes. 'all' adds color characters to all output. 'none' shuts colorization
    # off.
    COLOR tty
    
    # Below, there should be one TERM entry for each termtype that is colorizable
    TERM ansi
    TERM color_xterm
    TERM color-xterm
    TERM con132x25
    TERM con132x30
    TERM con132x43
    TERM con132x60
    TERM con80x25
    TERM con80x28
    TERM con80x30
    TERM con80x43
    TERM con80x50
    TERM con80x60
    TERM cons25
    TERM console
    TERM cygwin
    TERM dtterm
    TERM Eterm
    TERM eterm-color
    TERM gnome
    TERM gnome-256color
    TERM jfbterm
    TERM konsole
    TERM kterm
    TERM linux
    TERM linux-c
    TERM mach-color
    TERM mlterm
    TERM nxterm
    TERM putty
    TERM rxvt
    TERM rxvt-256color
    TERM rxvt-cygwin
    TERM rxvt-cygwin-native
    TERM rxvt-unicode
    TERM rxvt-unicode256
    TERM rxvt-unicode-256color
    TERM screen
    TERM screen-256color
    TERM screen-256color-bce
    TERM screen-bce
    TERM screen.linux
    TERM screen-w
    TERM vt100
    TERM xterm
    TERM xterm-16color
    TERM xterm-256color
    TERM xterm-88color
    TERM xterm-color
    TERM xterm-debian
    
    # EIGHTBIT, followed by '1' for on, '0' for off. (8-bit output)
    EIGHTBIT 1
    
    # File type 
    
    # global default
    NORMAL 00
    # normal file
    FILE 00
    # directory
    DIR 36
    # symbolic link
    LINK 35
    
    # pipe, socket, block device, character device (blue bg)
    FIFO 37;44
    SOCK 37;44
    DOOR 37;44 # Solaris 2.5 and later
    BLK  37;44
    CHR  37;44
    
    
    # File attributes 
    
    # Orphaned symlinks (blinking white on red)
    # Blink may or may not work (works on iTerm dark or light, and Putty dark)
    ORPHAN  05;37;45
    # ... and the files that orphaned symlinks point to (blinking white on red)
    MISSING 05;37;45
    # dir that is sticky and other-writable (+t,o+w)
    STICKY_OTHER_WRITABLE 30;46
    # dir that is other-writable (o+w) and not sticky
    OTHER_WRITABLE 30;46
    
    # files with execute permission
    EXEC 01;31  # Unix
    .cmd 01;31  # Win
    .exe 01;31  # Win
    .com 01;31  # Win
    .bat 01;31  # Win
    .reg 01;31  # Win
    .app 01;31  # OSX
    
    
    # File extension 
    
    # List any file extensions like '.gz' or '.tar' that you would like ls
    # to colorize below. Put the extension, a space, and the color init string.
    # (and any comments you want to add after a '#')
    
    # Text 
    
    .txt 33
    .org 33
    .md 33
    .mkd 33
    
    
    # Source 
    
    .C 32
    .c 32
    .cc 32
    .csh 32
    .css 32
    .cxx 32
    .el 32
    .h 32
    .hs 32
    .htm 32
    .html 32
    .java 32
    .js 32
    .man 32
    .objc 32
    .php 32
    .pl 32
    .pm 32
    .pod 32
    .py 32
    .rb 32
    .rdf 32
    .sh 32
    .shtml 32
    .tex 32
    .vim 32
    .xml 32
    .zsh 32
    
    
    # Image 
    .bmp 01;35
    .cgm 01;35
    .dl 01;35
    .dvi 01;35
    .emf 01;35
    .eps 01;35
    .gif 01;35
    .jpeg 01;35
    .jpg 01;35
    .JPG 01;35
    .mng 01;35
    .pbm 01;35
    .pcx 01;35
    .pdf 01;35
    .pgm 01;35
    .png 01;35
    .ppm 01;35
    .pps 01;35
    .ppsx 01;35
    .ps 01;35
    .svg 01;35
    .svgz 01;35
    .tga 01;35
    .tif 01;35
    .tiff 01;35
    .xbm 01;35
    .xcf 01;35
    .xpm 01;35
    .xwd 01;35
    .xwd 01;35
    .yuv 01;35
    
    
    # Audio 
    
    .aac 01;35
    .au  01;35
    .flac 01;35
    .mid 01;35
    .midi 01;35
    .mka 01;35
    .mp3 01;35
    .mpa 01;35
    .mpeg 01;35
    .mpg 01;35
    .ogg  01;35
    .ra 01;35
    .wav 01;35
    
    
    # Video 
    
    .anx 01;35
    .asf 01;35
    .avi 01;35
    .axv 01;35
    .flc 01;35
    .fli 01;35
    .flv 01;35
    .gl 01;35
    .m2v 01;35
    .m4v 01;35
    .mkv 01;35
    .mov 01;35
    .mp4 01;35
    .mp4v 01;35
    .mpeg 01;35
    .mpg 01;35
    .nuv 01;35
    .ogm 01;35
    .ogv 01;35
    .ogx 01;35
    .qt 01;35
    .rm 01;35
    .rmvb 01;35
    .swf 01;35
    .vob 01;35
    .wmv 01;35
    
    
    # Documents 
    
    .doc 33
    .docx 33
    .rtf 33
    .dot 33
    .dotx 33
    .xls 33
    .xlsx 33
    .ppt 33
    .pptx 33
    .fla 33
    .psd 33
    
    
    # Archives 
    
    .7z   1;35
    .apk  1;35
    .arj  1;35
    .bin  1;35
    .bz   1;35
    .bz2  1;35
    .cab  1;35  # Win
    .deb  1;35
    .dmg  1;35  # OSX
    .gem  1;35
    .gz   1;35
    .iso  1;35
    .jar  1;35
    .msi  1;35  # Win
    .rar  1;35
    .rpm  1;35
    .tar  1;35
    .tbz  1;35
    .tbz2 1;35
    .tgz  1;35
    .tx   1;35
    .war  1;35
    .xpi  1;35
    .xz   1;35
    .z    1;35
    .Z    1;35
    .zip  1;35
    
    
    # Testing 
    
    .ANSI-black 30
    .ANSI-black-bright 01;30
    .ANSI-red 31
    .ANSI-red-bright 01;31
    .ANSI-green 32
    .ANSI-green-bright 01;32
    .ANSI-yellow 33
    .ANSI-yellow-bright 01;33
    .ANSI-blue 34
    .ANSI-blue-bright 01;34
    .ANSI-magenta 35
    .ANSI-magenta-bright 01;35
    .ANSI-cyan 36
    .ANSI-cyan-bright 01;36
    .ANSI-white 37
    .ANSI-white-bright 01;37
    
    
    # Custom 
    
    # Unimportant text files
    *# 32
    *~ 32
    .log 32
    
    # Unimportant non-text files
    *,v 01;30
    .BAK 01;30
    .DIST 01;30
    .OFF 01;30
    .OLD 01;30
    .ORIG 01;30
    .bak 01;30
    .dist 01;30
    .off 01;30
    .old 01;30
    .org_archive 01;30
    .orig 01;30
    .swo 01;30
    .swp 01;30
    
    
    

    public by NightHowl  69  0  3  0

    Batch ESC (ANSI escape sequence)

    This snippet is useful for escape characters. It can be used to, for example, color your screen/certain words/letters. An example: ----------------- echo %ESC%[93mHello![0m ----------------- The above will print out 'Hello!' in a yellowish color and then RESET the color, meaning any words after Hello! won't be yellow. For more information on
    for /f "delims=" %%E in (
        'forfiles /p "%~dp0." /m "%~nx0" /c "cmd /c echo(0x1B"'
    ) do (
        set "ESC=%%E"
    )

    public by msdn  2651  0  7  0

    ColorShade

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Drawing;
    using System.Drawing.Imaging;
    using System.Runtime.InteropServices;
    using System.Drawing.Drawing2D;
    
    public static Bitmap ColorShade(this Bitmap sourceBitmap, float blueShade, 
                                    float greenShade, float redShade)
    {
        BitmapData sourceData = sourceBitmap.LockBits(new Rectangle(0, 0,
                                sourceBitmap.Width, sourceBitmap.Height),
                                ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
    
        byte[] pixelBuffer = new byte[sourceData.Stride * sourceData.Height];
    
        Marshal.Copy(sourceData.Scan0, pixelBuffer, 0, pixelBuffer.Length);
    
        sourceBitmap.UnlockBits(sourceData);
    
        float blue = 0;
        float green = 0;
        float red = 0;
    
        for (int k = 0; k + 4 < pixelBuffer.Length; k += 4)
        {
            blue =  pixelBuffer[k] * blueShade;
            green = pixelBuffer[k + 1] * greenShade;
            red = pixelBuffer[k + 2] * redShade;
    
            if (blue < 0)
            { blue = 0; }
    
            if (green < 0)
            { green = 0; }
    
            if (red < 0)
            { red = 0; }
    
            pixelBuffer[k] = (byte)blue;
            pixelBuffer[k + 1] = (byte)green;
            pixelBuffer[k + 2] = (byte)red;
    
        }
    
        Bitmap resultBitmap = new Bitmap(sourceBitmap.Width, sourceBitmap.Height);
    
        BitmapData resultData = resultBitmap.LockBits(new Rectangle(0, 0,
                                resultBitmap.Width, resultBitmap.Height),
                                ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
    
        Marshal.Copy(pixelBuffer, 0, resultData.Scan0, pixelBuffer.Length);
        resultBitmap.UnlockBits(resultData);
    
        return resultBitmap;
    }

    public by msdn  1833  0  7  0

    ColorSubstitution

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Drawing;
    using System.Drawing.Imaging;
    using System.Runtime.InteropServices;
    using System.IO;
    
    public static Bitmap ColorSubstitution(this Bitmap sourceBitmap, ColorSubstitutionFilter filterData)
    {
        Bitmap resultBitmap = new Bitmap(sourceBitmap.Width, sourceBitmap.Height, PixelFormat.Format32bppArgb);
    
        BitmapData sourceData = sourceBitmap.LockBits(new Rectangle(0, 0, sourceBitmap.Width, sourceBitmap.Height), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
        BitmapData resultData = resultBitmap.LockBits(new Rectangle(0, 0, resultBitmap.Width, resultBitmap.Height), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
    
        byte[] resultBuffer = new byte[resultData.Stride * resultData.Height];
        Marshal.Copy(sourceData.Scan0, resultBuffer, 0, resultBuffer.Length);
    
        sourceBitmap.UnlockBits(sourceData);
    
        byte sourceRed = 0, sourceGreen = 0, sourceBlue = 0, sourceAlpha = 0;
        int resultRed = 0, resultGreen = 0, resultBlue = 0;
    
        byte newRedValue = filterData.NewColor.R;
        byte newGreenValue = filterData.NewColor.G;
        byte newBlueValue = filterData.NewColor.B;
    
        byte redFilter = filterData.SourceColor.R;
        byte greenFilter = filterData.SourceColor.G;
        byte blueFilter = filterData.SourceColor.B;
    
        byte minValue = 0;
        byte maxValue = 255;
    
        for (int k = 0; k < resultBuffer.Length; k += 4)
        {
            sourceAlpha = resultBuffer[k + 3];
    
            if (sourceAlpha != 0)
            {
                sourceBlue = resultBuffer[k];
                sourceGreen = resultBuffer[k + 1];
                sourceRed = resultBuffer[k + 2];
    
                if ((sourceBlue < blueFilter + filterData.ThresholdValue &&
                        sourceBlue > blueFilter - filterData.ThresholdValue) &&
    
                    (sourceGreen < greenFilter + filterData.ThresholdValue &&
                        sourceGreen > greenFilter - filterData.ThresholdValue) &&
    
                    (sourceRed < redFilter + filterData.ThresholdValue &&
                        sourceRed > redFilter - filterData.ThresholdValue))
                {
                    resultBlue = blueFilter - sourceBlue + newBlueValue;
    
                    if (resultBlue > maxValue)
                    { resultBlue = maxValue; }
                    else if (resultBlue < minValue)
                    { resultBlue = minValue; }
    
                    resultGreen = greenFilter - sourceGreen + newGreenValue;
    
                    if (resultGreen > maxValue)
                    { resultGreen = maxValue; }
                    else if (resultGreen < minValue)
                    { resultGreen = minValue; }
    
                    resultRed = redFilter - sourceRed + newRedValue;
    
                    if (resultRed > maxValue)
                    { resultRed = maxValue; }
                    else if (resultRed < minValue)
                    { resultRed = minValue; }
    
                    resultBuffer[k] = (byte)resultBlue;
                    resultBuffer[k + 1] = (byte)resultGreen;
                    resultBuffer[k + 2] = (byte)resultRed;
                    resultBuffer[k + 3] = sourceAlpha;
                }
            }
        }
    
        Marshal.Copy(resultBuffer, 0, resultData.Scan0, resultBuffer.Length);
        resultBitmap.UnlockBits(resultData);
    
        return resultBitmap;
    }
    • Public Snippets
    • Channels Snippets