• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

ColorUtils

Level 29
Joined
Mar 10, 2009
Messages
5,016
Well, this is just a collection of colors for your texts...


JASS:
/*
ColorUtils
Created by Mckill2009

Applies 50 colors to your texts

Source site:
[url]www.computerhope.com/htmcolor.htm[/url] (credits to ALONE for providing this site)
*/

library ColorUtils initializer init

globals
    private string array Color
    private integer MaxColor = 50
endglobals

private function ColorSetup takes nothing returns nothing
    set Color[0] = "|cffff0000"    //red
    set Color[1] = "|cff0000ff"    //blue
    set Color[2] = "|cff00f5ff"    //Teal
    set Color[3] = "|cff551A8B"    //Purple
    set Color[4] = "|cffffff00"    //Yellow
    set Color[5] = "|cffEE9A00"    //Orange
    set Color[6] = "|cff00CD00"    //Green
    set Color[7] = "|cffFF69B4"    //Pink
    set Color[8] = "|cffC0C0C0"    //Gray
    set Color[9] = "|cffB0E2FF"    //Light Blue
    set Color[10] = "|cff006400"   //Dark Green
    set Color[12] = "|cff342D7E"   //State Blue
    set Color[13] = "|cff2B60DE"   //Royal Blue
    set Color[14] = "|cff3BB9FF"   //Deep Sky Blue
    set Color[15] = "|cff25587E"   //Deep Sky Blue 4
    set Color[16] = "|cff8D38C9"   //Violet
    set Color[17] = "|cffF52887"   //Deep Pink
    set Color[18] = "|cff437C17"   //Chartreuse4
    set Color[19] = "|cff800517"   //Firebrick
    set Color[20] = "|cff810541"   //Maroon
    set Color[21] = "|cffFF00FF"   //Magenta
    set Color[22] = "|cffB048B5"   //Medium Orchid
    set Color[23] = "|cff6A287E"   //Medium Orchid 4
    set Color[24] = "|cff8E35EF"   //Purple
    set Color[25] = "|cffB93B8F"   //Plum
    set Color[26] = "|cffC3FDB8"   //Dark Sea Green1
    set Color[27] = "|cffE3E4FA"   //Lavender
    set Color[28] = "|cffAF7817"   //Dark Goldenrod
    set Color[29] = "|cff00FFFF"   //Cryan
    set Color[30] = "|cff43C6DB"   //Turquoise
    set Color[31] = "|cff82CAFF"   //Sky Blue
    set Color[32] = "|cff4E8975"   //Sea Green
    set Color[33] = "|cff254117"   //Dark Green
    set Color[34] = "|cffA52A2A"   //Brown
    set Color[35] = "|cffC0C0C0"   //Silver
    set Color[36] = "|cff808000"   //Olive
    set Color[37] = "|cffFF00FF"   //Fuchsia
    set Color[38] = "|cff00FF00"   //Lime
    set Color[39] = "|cffF76541"   //Coral
    set Color[40] = "|cffFFF8C6"   //Lemon Chiffon
    set Color[41] = "|cffB38481"   //Rosy Brown
    set Color[42] = "|cff7D2252"   //Hot Pink4
    set Color[43] = "|cffF660AB"   //Hot Pink
    set Color[44] = "|cffC85A17"   //Chocolate
    set Color[45] = "|cffD4A017"   //Gold
    set Color[46] = "|cffE18B6B"   //Dark Salmon
    set Color[47] = "|cff8A4117"   //Sienna
    set Color[48] = "|cffADA96E"   //Khaki
    set Color[49] = "|cff8AFB17"   //Chartreuse
    set Color[50] = "|cffADDFFF"   //Light Blue
    //set Color[51] = "|cff"   //
endfunction

function RandomColor takes string s returns string
    return Color[GetRandomInt(0, MaxColor)] + s +"|r"
endfunction

function FixedColor takes integer colorindex, string s returns string
    return Color[colorindex] + s +"|r"
endfunction

private function init takes nothing returns nothing
    call ColorSetup()
endfunction

endlibrary

Demo:
JASS:
scope ColorU initializer init

globals
    private integer I = 0
endglobals

function TestColors takes nothing returns nothing
    call BJDebugMsg(FixedColor(I,"COLOR OF = "+I2S(I)))
    set I = I+1
    if I >= 51 then
        call DestroyTrigger(GetTriggeringTrigger())
    endif
endfunction

function init takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterTimerEvent(t, 1, true)
    call TriggerAddAction(t, function TestColors)
endfunction

endscope
 
Level 6
Joined
Jun 20, 2011
Messages
249
Why is the code inside a spoiler?
What's better about having a list of colors i constantly need to check to know which is the color index for my desired color over just looking for the RGB code somewhere else?
You should make a list of globals.
JASS:
private function init takes nothing returns nothing
    call ColorSetup()
endfunction
Why not just merge both functions?
ColorUtils is not an appropriate name
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
It's a good practice to have the configuration part in the top of the library, ColorSetUp doesn't need to be merged with the initializer.
And really that doesn't matter anyway, it's just an initializer.

I'm agree on other points.

Also, instead of functions i think it's worth it to make the string array Color not private, and add constants integers :

constant integer RED = 0
constant integer BLUE = 1 ...
 
Also, instead of functions i think it's worth it to make the string array Color not private, and add constants integers :

constant integer RED = 0
constant integer BLUE = 1 ...

This.

As a first attempt to make a Jass section resource, I'd like to tell you: Not bad ;)

Those 12 colors most of us stick to are pretty damn lame :eek:
Can you make it so that there are 256 colors? ^-^

This should generate them:

JASS:
library ColorGen

    globals
        private string array colors
        private string array ints
        private integer number = -1
    endglobals
    
    function display takes nothing returns nothing
        call DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, 60, colors[number])
        set number = number - 1
        if colors[number] == "" then
            call PauseTimer(GetExpiredTimer())
        endif
    endfunction
    
    private struct Inits extends array
        private static method onInit takes nothing returns nothing
            local integer index1 = 0
            local integer index2 = 0
            local integer index3 = 0
            local trigger t = CreateTrigger()
            
            set ints[0] = "00"
            set ints[1] = "33"
            set ints[2] = "66"
            set ints[3] = "99"
            set ints[4] = "cc"
            set ints[5] = "ff"
            
            loop
                loop
                    loop
                        set number = number + 1
                        set colors[number] = ints[index3] + ints[index2] + ints[index1]
                        exitwhen index1 == 5
                        set index1 = index1 + 1
                    endloop
                    exitwhen index2 == 5
                    set index2 = index2 + 1
                    set index1 = 0
                endloop
                exitwhen index3 == 5
                set index3 = index3 + 1
                set index2 = 0
                set index1 = 0
            endloop
            
            call TimerStart(CreateTimer(), 0.5, true, function display)
        endmethod
    endstruct
    
endlibrary

It generates all the colors; You can copy them and put them into globals ;)
 
Well, this isn't so much to allow colors, but rather intended to make color coding easier for those who don't know hex codes. However, it may end up being more trouble looking through a list opposed to just googling a hex converter to get the colors you need.

What you should do instead is include only the 12 player colors, black, white, and gold and lumber colors. (you can find the rgb codes in miscdata.txt)
 
Level 29
Joined
Mar 10, 2009
Messages
5,016
Who needs 256 colors anyway?...:p..., I dont even need 20, the thing is, I post
it for people who dont know hex codes and color blind...

You know for sure that this can support systems such as Messages, Multiaboards, Quests, text tags, very easy to implement...

And like Purge said...
...but rather intended to make color coding easier...

Why is the code inside a spoiler?
My taste XD...

What's better about having a list of colors i constantly need to check to know which is the color index for my desired color over just looking for the RGB code somewhere else?

None, see Purge's comment & my comment above this...
 
Top