[API Suggestion] Colors

#1 - June 1, 2013, 12:35 a.m.
Blizzard Post

I think having this return an array of colours, with an explicit ID property, thus mimicking the events API, would make more sense. It’s currently useful as a map but we don’t have easy access to the keys. It’s easier to construct a map from an array on the client side than extracting all the IDs as keys.

#2 - June 1, 2013, 8:01 a.m.
Blizzard Post

We made the color API an associative array as a result of this thread: https://forum-en.guildwars2.com/forum/community/api/API-Request-Results-as-map-id-details/first

What programming language do you have trouble accessing the keys? In javascript it should be as simple as “for(var key in obj) {}”

#5 - June 1, 2013, 4:49 p.m.
Blizzard Post

Question #1: How should we be interpreting the color numbers (i.e., hue might be a value in degrees out of 360?)

Edit: I really, really tried to find this all out on the web, but the inconsistency with the number just didn’t make sense. thanks for any info you can provide.

Sorry about the confusion! The API was showing color values that had been partially transformed. I updated the API to show their original values. The colors are in HSL color space.

I also added localized text names so that it’s easier to identify colors.

Does this clear things up for you?

#7 - June 2, 2013, 1:14 a.m.
Blizzard Post

OK, here’s a more detailed breakdown:

Hue – degrees between 0-360
Saturation & Lightness – 0-255, 0 is 0%, 255 is 100%

Brightness & Contrast – I’ll get back to you about these

HSL should give you everything you need to get going. If you go to http://yuilibrary.com/yui/docs/color/hsl-picker.html and type in 45, 78%, 50.7% in the HSL textbox, you should see a color that matches Harvest Gold in-game (one of the guild emblem dyes).

#8 - June 2, 2013, 3:48 a.m.
Blizzard Post

I believe the following information is correct, but I’m going to have to check with other people to be sure:

The data for each color in the API represents a color shift from a base color to a new color. The base color for many dyes, including all guild emblem dyes, is RGB 128,26,26.

For guild emblems themselves, there are a few color masks such as the one here that can be used to define where the color gets applied on the emblem, and slight variances in the color that gets applied (by varying the base color).

Brightness should be added to or subtracted from each component of the color
Contrast should used as a multiplier for each component of the color ((color – 128) * contrast + 128)

Hue is a value from 0-360 degrees. Saturation and Lightness are both multipliers of the original S & L values.

The order of operations is:
1) Take the base (RGB) color
2) Apply brightness and contrast
3) Convert color to HSL space
4) Apply HSL shift
5) Convert color back to RGB space (this is the final color value)

http://dragonwatch.net/fancyemblemexperiment/ does most of this math already, using pixastic. The only thing it’s missing is brightness/contrast, which seem to be something that pixastic also supports.

I’ll make another update tomorrow to the API to make the values in the API match the values in this post.

#17 - June 2, 2013, 11:20 a.m.
Blizzard Post

I somehow get the feeling that “default” refers to the base color Cliff mentioned above since these are the same values for a lot of colors.

Default is the default material. There is not necessarily a material-specific color defined for a dye. In this case, the default is used.

In the quoted dye, the color is actually not black, only the actual material colors are black. I’m still working on more detailed information on how to convert the colors to RGB.

#19 - June 2, 2013, 11:34 a.m.
Blizzard Post

Default is the default material. There is not necessarily a material-specific color defined for a dye. In this case, the default is used.

Does that also mean that the default color is not always specified? That would explain this:

126: {
  name: "Hot Pink",
    default: {
    brightness: "128",
    contrast: "128",
    hue: "0",
    saturation: "128",
    lightness: "128"
  },
...

…or did i get you completely wrong?

Yes, that’s right. I’m going to update the API to only show the materials that are actually defined.

#23 - June 2, 2013, 12:34 p.m.
Blizzard Post

I believe the following information is correct, but I’m going to have to check with other people to be sure:

The data for each color in the API represents a color shift from a base color to a new color. The base color for many dyes, including all guild emblem dyes, is RGB 128,26,26.

For guild emblems themselves, there are a few color masks such as the one here that can be used to define where the color gets applied on the emblem, and slight variances in the color that gets applied (by varying the base color).

Brightness should be added to or subtracted from each component of the color
Contrast should used as a multiplier for each component of the color ((color – 128) * contrast + 128)

Hue is a value from 0-360 degrees. Saturation and Lightness are both multipliers of the original S & L values.

The order of operations is:
1) Take the base (RGB) color
2) Apply brightness and contrast
3) Convert color to HSL space
4) Apply HSL shift
5) Convert color back to RGB space (this is the final color value)

http://dragonwatch.net/fancyemblemexperiment/ does most of this math already, using pixastic. The only thing it’s missing is brightness/contrast, which seem to be something that pixastic also supports.

I’ll make another update tomorrow to the API to make the values in the API match the values in this post.

OK – the API has been updated so that their values match the ones in this guide.

#28 - June 2, 2013, 3:35 p.m.
Blizzard Post

How exactly are you supposed to do the HSL shift in step 4?
Say I have 0.75 Saturation after applying brightness and contrast, and the API says I need to shift by 0.41? What should the results be?

Just clarified and fixed the API values a bit. S and L are actually multipliers. If you have a 0.75 saturation, multiply that by the saturation value. Add the H value to the base H value (normally 0 if no brightness or contrast has been applied).

#35 - June 2, 2013, 10:32 p.m.
Blizzard Post

Wow, who knew that a simple color API would turn out to be so complicated!

Thanks a lot for helping me reverse-engineer our color math, and Killer Rhino, thanks for writing a great guide!

I’m going to keep looking into it on my end and see if there’s a better way for us to provide the API for you. It seems like we’re at least 95% of the way there though.

Let’s switch over to the “how-to” thread for any more discussion about implementation issues. ( https://forum-en.guildwars2.com/forum/community/api/How-To-Colors-API/first )

#40 - June 3, 2013, 1:33 a.m.
Blizzard Post

Let’s say I develop a web app that shows all of the dye colors accessible in the game. In the future when OAuth support is implemented, will a logged-in player be able to see their favorites and unlocked dye colors for each of their characters?

That’s the idea. Any references to colors in other APIs would be able to be resolved using this API.

#46 - June 3, 2013, 1:52 p.m.
Blizzard Post

Looking at smiley’s listing, it appears that colors 1222-1230 are the hair colors exclusive to the Self-Style Hair Kit, and colors 1231-1242 are the dyes from the Flame and Frost Dye Kits. The hair colors only have a default material, while the dyes all have cloth/leather/metal. This definitely supports Rhino’s hypothesis.

Yes, that’s right. I just updated the API to remove those colors for now, since you can’t really do much with them. So now it’ll only return dye colors. In the future, we could re-add those if there’s an interesting use-case, but I think for now it’s confusing.

#48 - June 3, 2013, 2:01 p.m.
Blizzard Post

ERMAHGERD! You added RGB values and made all our efforts obsolete! Q.Q
(thanks, was fun to find out anyway )

You still need the more detailed information if you want to apply dyes against textures yourself, such as for guild emblem compositing.