Snippet stringColor

Discussion in 'Systems and Snippets' started by Darthfett, Jan 4, 2010.

  1. Darthfett

    Darthfett Super Mod

    Ratings:
    +614 / 0 / -0
    stringColor
    Created by Darthfett

    Description:
    A list of hex color code globals.

    The purpose of this library is to give you an idea of how to use string
    constants and colors effectively in display text. It is not a complete list
    and neither will it ever be. Instead, it is simply a list made to be added to.​

    Requirements:
    N/A​

    The rest of the documentation can be found in the system code, below:

    JASS:
    library stringColor
    /*
    __________________________________________________________________________________
    
            stringColor library, created by Darthfett - version 1.2
            http://www.thehelper.net/forums/showthread.php?t=143593
                
                                    Requirements
                                    
    -vJass compiler (such as JASSHelper)
    
                                    Documentation
                                    
    -All globals are standalone.  Feel free to copy an individual global.
    
    -Credit for this library is not necessary.  Feel free to use it in your map.
    If you feel obligated to credit me, I won't object.  I only ask that you do 
    not simply copy and paste the library as your own.
    
    -The library isn't really needed. You can get by simply by copying and pasting
    the globals block. You don't need to require the library
    in order to use this either, but 'using' the library gives more logical errors
    to the user if they do not have it in their map.
    
                                      Purpose
    
    The purpose of this library is to give you an idea of how to use string 
    constants and colors effectively in display text.  It is not a complete list
    and neither will it ever be.  Instead, it is simply a list made to be added to.
    
                                        API
    
    This library provides a few hex color strings to use to color displayed text.
    
    constant string CLR_END = "|r"
        This string is used to end the color coded string.
        (Example: CLR_RED + "This is Red" +  CLR_END + ", and this is white.")
        
    constant string CLR_LIGHTYELLOW ... CLR_DARKGRAY
        These strings are used to color text that will be displayed
        on the average WC3 background. They were chosen to be easier to read.
        (Example: call BJDebugMsg(CLR_Yellow + "Don't kill " + END + CLR_RED + "THAT!" + CLR_END)
        
    constant string PC_RED ... PC_BROWN
        These strings are used to color something in a player's colored text.
        (Example: call BJDebugMsg(PC_RED + GetPlayerName(Player(0)) + CLR_END + ": HI gUyz!")
    
    __________________________________________________________________________________
    */
    
    globals
        constant string CLR_END =        "|r"
        
        //=========================
        constant string CLR_LIGHTYELLOW = "|cffffff00"
        constant string CLR_YELLOW =      "|cffffcc00"
        constant string CLR_GREEN =       "|cff00ff00"
        constant string CLR_BLUE =        "|cff0000ff"
        constant string CLR_RED =         "|cffff0000"
        constant string CLR_BROWN =       "|cffcc9933"
        constant string CLR_ORANGE =      "|cffff6400"
        constant string CLR_DARKGREEN =   "|cff009600"
        constant string CLR_AQUA =        CLR_DARKGREEN
        constant string CLR_DARKBLUE =    "|cff000096"
        constant string CLR_DARKRED =     "|cff960000"
        constant string CLR_DARKTEAL =    "|cff009696"
        constant string CLR_DARKCYAN =    CLR_DARKTEAL
        constant string CLR_DARKORANGE =  "|cffc86400"
        constant string CLR_DARKGRAY =    "|cff666666"
        
        constant string PC_RED       = "|cffff0303"
        constant string PC_BLUE      = "|cff0042ff"
        constant string PC_TEAL      = "|cff1ce6b9"
        constant string PC_PURPLE    = "|cff540081"
        constant string PC_YELLOW    = "|cfffffc01" 
        constant string PC_ORANGE    = "|cfffeba0e"
        constant string PC_GREEN     = "|cff20c000"
        constant string PC_PINK      = "|cffr55bb0"
        constant string PC_GRAY      = "|cff959697"
        constant string PC_LIGHTBLUE = "|cff7ebff1"
        constant string PC_DARKGREEN = "|cff107246"
        constant string PC_BROWN     = "|cff4e2a04"
        constant string PC_GREY      = PC_GRAY
        
        //=========================
    endglobals
    
    endlibrary


    FAQ:
    Q: Why use this library?
    A: Simply put, the library gives some useful, standardized constants for concatenating strings.

    Q: How do I get the color code for a specific player?
    A: Since a player's color is not linked to a player's number in every map, player color and color codes are tracked in the stringPlayer library. You'll find the function you're looking for in that library.

    Q: Why the unusual name?
    A: Since the library is part of a collection of libraries (namely, the string library), I wanted the library names to stand out from others, and at the same time look unified.
     
    • Like Like x 1
  2. kingkingyyk3

    kingkingyyk3 Visitor (Welcome to the Jungle, Baby!)

    Ratings:
    +216 / 0 / -0
    JASS:
    library Colors initializer Init
    
    globals
        constant string BLACK   = "|c00000000"
        constant string WHITE   = "|c00FFFFFF"    
    	constant string GOLD    = "|c00FFCC00"
        constant string GREY    = "|c007d7d7d"  
        constant string DARKGREY= "|c00696969"
    
        constant string RED     = "|c00FF0000"
    	constant string GREEN   = "|c0000FF00"
    	constant string BLUE    = "|c000000FF"
    
        constant string YELLOW  = "|c00FFFF00"
        constant string ORANGE  = "|c00FF7F00"
        constant string PINK    = "|c00FF9696"
        constant string LIME    = "|c0096FF96"
        constant string MAGENTA = "|c00FF00FF"
        constant string NAVY    = "|c00000064"
    
        
        constant string  PC0   = "|c00FF0303"
        constant integer PC0_R = 255
        constant integer PC0_G = 3
        constant integer PC0_B = 3
        
        constant string  PC1   = "|c000042FF"    
        constant integer PC1_R = 0
        constant integer PC1_G = 66
        constant integer PC1_B = 255
    
        constant string  PC2   = "|c001CE6B9"    
        constant integer PC2_R = 28
        constant integer PC2_G = 230
        constant integer PC2_B = 185
    
        constant string  PC3   = "|c00540081"    
        constant integer PC3_R = 84
        constant integer PC3_G = 0
        constant integer PC3_B = 129
    
        constant string  PC4   = "|c00FFFC01"    
        constant integer PC4_R = 255
        constant integer PC4_G = 252
        constant integer PC4_B = 1
        
        constant string  PC5   = "|c00fEBA0E"    
        constant integer PC5_R = 254
        constant integer PC5_G = 186
        constant integer PC5_B = 14
        
        constant string  PC6   = "|c0020C000"    
        constant integer PC6_R = 32
        constant integer PC6_G = 192
        constant integer PC6_B = 0
        
        constant string  PC7   = "|c00E55BB0"    
        constant integer PC7_R = 229
        constant integer PC7_G = 91
        constant integer PC7_B = 176
        
        constant string  PC8   = "|c00959697"    
        constant integer PC8_R = 149
        constant integer PC8_G = 150
        constant integer PC8_B = 151
        
        constant string  PC9   = "|c007EBFF1"    
        constant integer PC9_R = 126
        constant integer PC9_G = 191
        constant integer PC9_B = 241
        
        constant string  PC10   = "|c00106246"    
        constant integer PC10_R = 16
        constant integer PC10_G = 92
        constant integer PC10_B = 70
        
        constant string  PC11   = "|c004E2A04"    
        constant integer PC11_R = 78
        constant integer PC11_G = 42
        constant integer PC11_B = 4
        
        string array PC
        integer array PC_R
        integer array PC_G
        integer array PC_B
    endglobals
    
    private function Init takes nothing returns nothing
        set PC[0]  = PC0
        set PC[1]  = PC1
        set PC[2]  = PC2
        set PC[3]  = PC3
        set PC[4]  = PC4
        set PC[5]  = PC5
        set PC[6]  = PC6
        set PC[7]  = PC7
        set PC[8]  = PC8
        set PC[9]  = PC9
        set PC[10] = PC10
        set PC[11] = PC11
        set PC[12] = "cerror"
        
        set PC_R[0]  = PC0_R
        set PC_R[1]  = PC1_R
        set PC_R[2]  = PC2_R
        set PC_R[3]  = PC3_R
        set PC_R[4]  = PC4_R
        set PC_R[5]  = PC5_R
        set PC_R[6]  = PC6_R
        set PC_R[7]  = PC7_R
        set PC_R[8]  = PC8_R
        set PC_R[9]  = PC9_R
        set PC_R[10] = PC10_R
        set PC_R[11] = PC11_R
        set PC_R[12] = -1
        
        set PC_G[0]  = PC0_G
        set PC_G[1]  = PC1_G
        set PC_G[2]  = PC2_G
        set PC_G[3]  = PC3_G
        set PC_G[4]  = PC4_G
        set PC_G[5]  = PC5_G
        set PC_G[6]  = PC6_G
        set PC_G[7]  = PC7_G
        set PC_G[8]  = PC8_G
        set PC_G[9]  = PC9_G
        set PC_G[10] = PC10_G
        set PC_G[11] = PC11_G
        set PC_G[12] = -1
        
        set PC_B[0]  = PC0_B
        set PC_B[1]  = PC1_B
        set PC_B[2]  = PC2_B
        set PC_B[3]  = PC3_B
        set PC_B[4]  = PC4_B
        set PC_B[5]  = PC5_B
        set PC_B[6]  = PC6_B
        set PC_B[7]  = PC7_B
        set PC_B[8]  = PC8_B
        set PC_B[9]  = PC9_B
        set PC_B[10] = PC10_B
        set PC_B[11] = PC11_B
        set PC_B[12] = -1    
    endfunction
    
    endlibrary


    Cohadar's library can beat this.
     
  3. Trollvottel

    Trollvottel never aging title

    Ratings:
    +261 / 0 / -0
    Lol PCB

    but i agree that this one is having more content and is better
     
  4. Darthfett

    Darthfett Super Mod

    Ratings:
    +614 / 0 / -0
    This system is made to give a few colors that actually show up against the dark backgrounds in Warcraft III (this is the reason that colors like navy, black, darkgr[a/e]y, etc are not listed).

    If you want player color, you can see the stringPlayer system.
     
  5. Darthfett

    Darthfett Super Mod

    Ratings:
    +614 / 0 / -0
    Update Version 1.1

    In one of the rare updates this system will receive, I have added in player hex color strings.
     
  6. Jesus4Lyf

    Jesus4Lyf Good Idea™

    Ratings:
    +394 / 0 / -0
    I think every constant should be prefixed with COLOUR_ (or "COLOR_") - I don't see why someone wouldn't have a constant named "RED" referring to player 1...
     
  7. Darthfett

    Darthfett Super Mod

    Ratings:
    +614 / 0 / -0
    I could argue that the people using "RED" to refer to a specific player should prefix theirs with "PLAYER_". :p

    While I agree with you to a certain level, I don't think that something that will be used as often as this is (at least in my own maps) should require so many extra characters. Part of my idea behind putting together a library of constants was to shorten lines with text, so as to make them readable without having to scroll. Player(0) really does not need to be referred to by a variable, and while I agree that my system should play nice by not reserving common words, I felt that this was worth it.
     
  8. Darthfett

    Darthfett Super Mod

    Ratings:
    +614 / 0 / -0
    Minor update (1.2), I gave in and decided to add the "CLR_" prefix to the Colors, and the Player Colors were changed to have the "PC_" prefix.
     
  9. Ghan

    Ghan Administrator - Servers are fun Staff Member

    Ratings:
    +773 / 0 / -0
    Approved.
     
  10. SanKakU

    SanKakU Member

    Ratings:
    +21 / 0 / -0
    i really don't undestand what cohadar's library is trying to accomplish...explanation?
     

Share This Page