[Library] Colors

Tyrulan

Ultra Cool Member
Reaction score
37
I wrote this a long time ago.. figured it was worth posting. If you have comments, questions, or suggestions post below. Thanks!

JASS:
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~ Colors ~~ By Tyrulan ~~ Version 1.1.0 ~~
//
// The following code should be pretty self explanatory. 
// The functions would be used as follows:
// Color_RED("Hello World!")
// Color_BLUE("Hello World!")
// etc.
//
// OR
//
// Clr_RED("Hello World!")
// Clr_BLUE("Hello World!")
// etc.
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
library Colors

    globals

        private constant string C_RED =          "|cffff0000"
        private constant string C_BLUE =         "|cff0000ff"
        private constant string C_TEAL =         "|cff00ffff"
        private constant string C_PURPLE =       "|cff400080"
        private constant string C_YELLOW =       "|cffffff00"
        private constant string C_ORANGE =       "|cffff8000"
        private constant string C_GREEN =        "|cff00ff00"
        private constant string C_PINK =         "|cffff0080"
        private constant string C_GRAY =         "|cffc0c0c0"                
        private constant string C_GREY =         "|cffc0c0c0"   
        private constant string C_LIGHTBLUE =    "|cff0080c0"
        private constant string C_DARKGREEN =    "|cff008000"        
        private constant string C_BROWN =        "|cff400000"

//     ************************************

        private constant string C_HINT =         "|cff32cd32"
        private constant string C_WARNING =      "cffff0000"
        private constant string C_NOTICE =       "|cff995500"
        private constant string C_CLOSE =        "|R" 
        
    endglobals
    
    //! textmacro COLOR takes TYPEWORD
    function Color_$TYPEWORD$ takes string s returns string
        return C_$TYPEWORD$ + s + C_CLOSE
    endfunction

    function Clr_$TYPEWORD$ takes string s returns string
        return C_$TYPEWORD$ + s + C_CLOSE
    endfunction
    //! endtextmacro
    
    //! runtextmacro COLOR("RED")
    //! runtextmacro COLOR("BLUE")
    //! runtextmacro COLOR("TEAL")
    //! runtextmacro COLOR("PURPLE")
    //! runtextmacro COLOR("YELLOW")
    //! runtextmacro COLOR("ORANGE")
    //! runtextmacro COLOR("GREEN")
    //! runtextmacro COLOR("PINK")
    //! runtextmacro COLOR("GRAY")    
    //! runtextmacro COLOR("GREY")    
    //! runtextmacro COLOR("LIGHTBLUE")    
    //! runtextmacro COLOR("DARKGREEN")
    //! runtextmacro COLOR("BROWN")
    //! runtextmacro COLOR("HINT")
    //! runtextmacro COLOR("WARNING")    
    //! runtextmacro COLOR("NOTICE")   
    
endlibrary



EDIT: Updated library name and added TESH highlighting .j file.
EDIT: Updated TESH file and added shorter function reference.
 

Attachments

  • Colors.txt
    4.7 KB · Views: 143

tooltiperror

Super Moderator
Reaction score
231
I remember you showing this to me a long time ago.

But, it looks pretty good, I'd vote for approval.
 

tooltiperror

Super Moderator
Reaction score
231
Just a comment, Komaqtion's library is much more complete, so you may want to check his out for ideas.
 

Tyrulan

Ultra Cool Member
Reaction score
37
I looked at both.

Darthfett's may have more colours but requires the user to use constants to encapsulate colours around text. ie) CLR_RED + "HELLO" + CLR_END which to me is annoying, hence the purpose of making an easily expandible library with a simple returning function.

Komaqtion's looks pretty tight and very complete, however (for the purposes of defending my own) is complex to mose users. The purpose of this was to be simple.
 

cleeezzz

The Undead Ranger.
Reaction score
268
add support for people who spell it "grey"

>Komaqtion's looks pretty tight and very complete, however (for the purposes of defending my own) is complex to mose users. The purpose of this was to be simple.

function calls are slower, besides, both ways would require the DisplayTextToPlayer (or one of the JASS string natives) and there is no way to use either komaqtion's or yours in GUI. which probably means the user knows enough JASS that both ways are "easy"
 

Tyrulan

Ultra Cool Member
Reaction score
37
Done.


You make a good point... don't have a good argument for that.
Aren't they both using function calls?
 

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
Cohadar's(although he's gone, but his libraries are still useful) :
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
 

tooltiperror

Super Moderator
Reaction score
231
What would be cool would be if we could make code arrays, but, :(
 

Tyrulan

Ultra Cool Member
Reaction score
37
Haha, this wasn't meant to be used to player colours. Everyone seems to think it is. It's just simple colour encapsulation for returning coloured text. :p
 

SanKakU

Member
Reaction score
21
i think your examples are too simple. but i think i got what it is and what it can do for me.
edit: wasn't sure if you noticed or not, but the attachment isn't the library that you posted. it's like your tesh file...
 

PurgeandFire

zxcvmkgdfg
Reaction score
509
i think your examples are too simple. but i think i got what it is and what it can do for me.
edit: wasn't sure if you noticed or not, but the attachment isn't the library that you posted. it's like your tesh file...

Yeah, that is for TESH highlighting. Just paste it in the includes folder for TESH and it will highlight the functions. The library is just meant to be copied directly.
 

tooltiperror

Super Moderator
Reaction score
231
Why not shorten to [ljass]clr[/ljass]?
 

tooltiperror

Super Moderator
Reaction score
231
You could make it optional, or make two versions.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top