vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | --[[ |
2 | |||
3 | MonkeyLibrary: |
||
4 | Common functions for the MonkeyMods |
||
5 | |||
6 | Website: http://www.toctastic.net/ |
||
7 | Author: Trentin (trentin@toctastic.net) |
||
8 | |||
9 | --]] |
||
10 | |||
11 | --[[ |
||
12 | |||
13 | This function extracts the ARGB values out of a colour encoded string. |
||
14 | |||
15 | @param strColour the string with the colour info. |
||
16 | |||
17 | @return the alpha value |
||
18 | @return the red value |
||
19 | @return the green value |
||
20 | @return the blue value |
||
21 | |||
22 | --]] |
||
23 | function MonkeyLib_ColourStrToARGB(strColour) |
||
24 | -- "|cFFFFFFFF" |
||
25 | local i = 3; |
||
26 | |||
27 | local iAlpha = tonumber(string.sub(strColour, i, i + 1), 16); |
||
28 | local iRed = tonumber(string.sub(strColour, i + 2, i + 3), 16); |
||
29 | local iGreen = tonumber(string.sub(strColour, i + 4, i + 5), 16); |
||
30 | local iBlue = tonumber(string.sub(strColour, i + 6, i + 7), 16); |
||
31 | |||
32 | iAlpha = iAlpha / 255; |
||
33 | iRed = iRed / 255; |
||
34 | iGreen = iGreen / 255; |
||
35 | iBlue = iBlue / 255; |
||
36 | |||
37 | --DEFAULT_CHAT_FRAME:AddMessage("A = "..iAlpha.." R = "..iRed.." G = "..iGreen.." B = "..iBlue); |
||
38 | |||
39 | return iAlpha, iRed, iGreen, iBlue; |
||
40 | end |
||
41 | |||
42 | --[[ |
||
43 | |||
44 | This function converts ARGB values into a colour encoded string. |
||
45 | |||
46 | @param the alpha value |
||
47 | @param the red value |
||
48 | @param the green value |
||
49 | @param the blue value |
||
50 | |||
51 | @return the string colour encoded |
||
52 | --]] |
||
53 | function MonkeyLib_ARGBToColourStr(iAlpha, iRed, iGreen, iBlue) |
||
54 | -- "|cFFFFFFFF" |
||
55 | local strColour; |
||
56 | |||
57 | |||
58 | -- floor it so it doesn't go over 255 |
||
59 | iAlpha = floor(iAlpha * 255); |
||
60 | iRed = floor(iRed * 255); |
||
61 | iGreen = floor(iGreen * 255); |
||
62 | iBlue = floor(iBlue * 255); |
||
63 | |||
64 | strColour = format("|c%2x%2x%2x%2x", iAlpha, iRed, iGreen, iBlue); |
||
65 | |||
66 | return strColour; |
||
67 | end |
||
68 | |||
69 | |||
70 | function MonkeyLib_DebugMsg(strMsg) |
||
71 | |||
72 | if (MONKEYLIB_DEBUG) then |
||
73 | if (DEFAULT_CHAT_FRAME) then |
||
74 | DEFAULT_CHAT_FRAME:AddMessage("MonkeyLib: " .. strMsg); |
||
75 | end |
||
76 | end |
||
77 | end |