Ok, on the top of the page i’ve written that it was working in all browsers. After the last reports i tried it again, first in chrome – and the page is broken again… this is so ridiculous.
I’d say that thing is completely broken and has to be rewritten from scratch.
btw. https://hom.guildwars2.com/ doesn’t work at all for me.
You may give this a try:
https://github.com/codemasher/gw2api-tools/blob/master/examples/gw2wvw.php
It could be called via ajax, e.g. prototype or jquery or just as pure html which is generated via php. Anyway, you’ll need to be able to execute php in both cases.
demo:
http://gw2.chillerlan.net/examples/gw2wvw.php (the example script)
https://chillerlan.net/gw2/wvw (full implementation)
(edited by smiley.1438)
I just found this one:
https://api.guildwars2.com/v1/recipe_details.json?recipe_id=2968 (Beetletun Omelette)
Disciplines: armorsmith and chef. Is this intended or a bug?
Thats pretty much what i’ve already suggested in post #3, isn’t it?
Is that sane?
insane :P
Ok, i took Moturdrn’s script and added some fancy resizing and caching and got this:
(i should’ve added antialiasing or so…)
https://github.com/codemasher/gw2api-tools/blob/master/examples/gw2emblems.php
Ok, i’ve pulled together all my gists and put them into a repo. This is not “Yet-Another-API-Wrapper”, more a collection of “How-To” examples (more to come)
gw2api-tools
- Language: PHP (5.4+)
- Admin: smiley.1438
- URL: https://github.com/codemasher/gw2api-tools
- Demo: http://gw2.chillerlan.net/
(edited by smiley.1438)
There is already a huge list providing implementations for several languages where you can read through over here: https://forum-en.gw2archive.eu/forum/community/api/API-implementation-library-master-list/2068146
Anyway, the most common steps are:
- send a HTTP GET request to the url of the desired API
- recieve the response
- parse the response JSON
- use the data
Milage may vary between programming languages. You may also want to cache the data which you receive from several requests like e.g. the world names to reduce the amount of requests you send since they’re static anyway.
(edited by smiley.1438)
Hey, 2 more notes on your code
- You don’t need the objectToArray function – json_decode() can handle that for you – just add true as second parameter in my gw2apiRequest function
- Theres no need to provide 2 versions of getColorMatrix and applyColorTransform, just drop the php 5.4+ part. php 5.4+ just supports the shorthand syntax for arrays aside from the regular syntax.
The performance increase was huge after splitting the functions, now we just need to find out how to process the images further, so that we get the same result like ingame. After stumbling across that imagefilter stunt i mentioned above, i think there’s some information missing.
(edited by smiley.1438)
Yeah, checking for the alpha value improves performance significant. Anyway, the other script is twice as fast (or even faster) without that check – about 2 seconds with checking alpha. One more reason to get that working.
I did a funny stunt now: i played around with imagefilter() just to check the difference it makes. Anyway, while playing around, i’ve forgot to comment a line of code, which surprisingly returned a not-so-bad result. This is what i did:
imagehue($imagebk, $bg);
imagefilter($imagebk, IMG_FILTER_CONTRAST, $bg['contrast']);
#imagefilter($imagebk, IMG_FILTER_BRIGHTNESS, $bg['brightness']);
imagefilter($imagebk, IMG_FILTER_COLORIZE, $bg['rgb'][0], $bg['rgb'][1],$bg['rgb'][2]);
So i applied that to the processing for all parts and it returned this:
Ah, ok, forget everything i’ve said before
(double post to repair the broken pagination… see also: https://forum-en.gw2archive.eu/forum/support/forum/Thread-loaded-as-Empty )
Hmm, yeah, theres a little difference
How long does it take to render the image?
And btw. which material type do you use to calculate? (mine above was metal)
(edited by smiley.1438)
Hey, thanks for posting this
Just a little note on your code: you call compositeColorShiftRgb within the 65536 run loop, which isn’t nessecary. Actually, don’t ever do that – it will melt you CPU (the unchanged script took ~20s on my machine)
Both parameters, $hslbc and $base are given through the API call. In fact, you don’t even need to calculate the RGB values anymore, since Cliff added them to the API yesterday.
Attachment:
First try with the Logo of my Guild:
https://api.guildwars2.com/v1/guild_details.json?guild_id=75FD83CF-0C45-4834-BC4C-097F93A487AF
(edited by smiley.1438)
I’m more interested, how i get this working without Imagemagick, since it’s not supported on my webspace >.<
Ah, thanks Dr Ishmael, that helped!
Updated and cleaned up that gist, you may take it as php example then:
https://gist.github.com/codemasher/b869faa7603e1934c28d
Also updated my color list: https://chillerlan.net/gw2color.php
Anyway, theres still the other conversion approach - i’d still like to know where the flaw is in there…
(edited by smiley.1438)
Yep, converting this new algorithm to PHP was not too hard, also using arrays for vectors and some algebra functions. Thanks for the precalculated values, too.
=)
Mind to share? I’m still getting incorrect values with this:
https://gist.github.com/codemasher/b869faa7603e1934c28d
(my brain melts >.<)
The pagination of the forum is broken since day1 → first post of the new page = last post of the old page, so the new page apperars to be empty and the pagination links don’t show up… time for a reliable pagination, eh?
ERMAHGERD! You added RGB values and made all our efforts obsolete! Q.Q
(thanks, was fun to find out anyway )
*Notice: i don’t claim that these results are correct, they only match Killer Rhino’s results. I’m still waiting for Cliff to clear things up and tell us if we’re on the right track.
I’ve already posted an example, have a look over here: https://chillerlan.net/gw2color.php
(i’ve added title-attributes, so that you can see the RGB values when you hover over a color)
I’m still unsure if these are right, but: https://chillerlan.net/gw2color.php
Nailed it!
Edit: added the link to the How-To guide for reference
I’ve updated my gist to reflect the changes: https://gist.github.com/codemasher/fb407de5587fdbd3e7c5
€: i’ve forgot to “correct” the final RGB values earlier.
(edited by smiley.1438)
I’m still unsure if these are right, but: https://chillerlan.net/gw2color.php
You may have noticed that theres a system behind the server ids:
digit 0: 1 = NA, 2 = EU
digit 1: 0 = undefined, 1 = french, 2 = german, 3 = spanish
digit 3+4= id
“name” is the name of the world like it’s used everywhere ingame.
I had it wrong when I said S & L are between 0 – 1 (saturation is; lightness is not).
Actually, they seem both to be between 0 and 2 (or at least >1) :
7: {
name: "Ocean",
cloth: {
brightness: -21,
contrast: 1,
hue: 188,
saturation: 1.32813, <--
lightness: 0.976563
},
leather: {
brightness: -18,
contrast: 1,
hue: 188,
saturation: 1.13281, <--
lightness: 1.05469
},
metal: {
brightness: -18,
contrast: 1,
hue: 188,
saturation: 0.78125,
lightness: 1.01563
}
}
Thats where the error in my example is. I assumed that the S/L values are already normalized to 0-1, i didn’t check that before. (Hot pink has already a l>1, so i should have noticed, but it was like 4am when i wrote that…)
(edited by smiley.1438)
I’ve set this up in my Perl module, and I’m running into cases where the saturation transform results in a value greater than 1, which in turn results in negative RGB values. I know that hue can just wrap-around (i.e. if hue > 360 {hue = hue – 360} ), but what do you do for saturation?
Do you have some specific examples so i can check that?
Hm, annoying. I was going off this SO post
btw. the answer to this post refers to the [url=‘https://github.com/mjijackson/mjijackson.github.com/blob/master/2008/02/rgb-to-hsl-and-rgb-to-hsv-color-model-conversion-algorithms-in-javascript.txt’
]javascript[/url] i mentioned above – this code works great!
€: kitten bbcode? :o
(edited by smiley.1438)
EDIT: Yeah, you have to disable AdBlock in your add-ons. You can’t add hom.guildwars2.com as an exception. You can, but it won’t work.
It only works for me if I completely disable AdBlock and do a hard reload. Looks like an AdBlock false positive more then anything on Anet’s end.
Hmm, when you’re using Adblock+, there is a Button where you can disable it for the current site. In Chrome it’s on the right side in the adress bar, in Firefox its on the bottom left side. Just click and select “disable for this site”.
Anyway, i have ABP installed and active in said browsers and it still works.
Ok, i’ve thrown together an example in php:
https://gist.github.com/codemasher/fb407de5587fdbd3e7c5
conversion functions:
https://gist.github.com/codemasher/741f30e68c6e9c7921c7
Have a look at this: https://github.com/mjijackson/mjijackson.github.com/blob/master/2008/02/rgb-to-hsl-and-rgb-to-hsv-color-model-conversion-algorithms-in-javascript.txt
oh, and this one:
http://www.rapidtables.com/convert/color/hsl-to-rgb.htm
(edited by smiley.1438)
- Convert back to RGB: 189,45,141
- Hex = #BD2D8D
Any obvious mistakes?
Hmm, i don’t know if you’re or i’m wrong…
I get RGB 193, 46, 95 with the same input values… and i don’t know where the error is. It’s pink anyway ^.^
I’ve uninstalled Java and reinstalled it.
java → javascript
ham → hamster
(conclusion: reinstalling java doesn’t help at all)
Did you clear your browser cache? (CTRL+F5 or CTRL+SHIFT+R does a hard reload for the current page)
Anyway, this ist crazy – it was broken that way for me for over half a year now (even disabling AdBlock+ and ScriptSafe didn’t help), but since a few days it works again in all browsers i checked. (Chrome, FF, IE9+10, Opera 12.x and Opera Next)
(edited by smiley.1438)
Thanks for the quick update
btw. it’s sunday afternoon and you’re at work :o now go and enjoy your sunday and let us do the maths
Did you read the last 4 postings in this thread? O.o
Great, thanks!
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?
could you please explain how to get to rgb #000 from these values? It think this is the easiest example that we can find:
“name”: “Black”,
“default”: {
“brightness”: “128”,
“contrast”: “128”,
“hue”: “0”,
“saturation”: “128”,
“lightness”: “128”
},
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.
Cliff,
We’re getting closer. Thanks for the names; however, some values are still not consistent with what to expect.
For instance, Abyss has values greater than 255
473: { name: "Abyss" -cloth: { brightness: "110" contrast: "128" hue: "275" saturation: "3" lightness: "140" } }
As far as i understand HSL, it’s a cylindrical color model where hue represents the angle around the vertical axis (0-360 degrees) while saturation and lightness are values between 0 and 1.
Still work in progress but:
WvW monitor: https://chillerlan.net/gw2/wvw.html
Fulltext item/event/guild search (aka. Interwiki helper): https://chillerlan.net/gw2/search.html
(edited by smiley.1438)
Ok, hows that: https://chillerlan.net/gw2/wvw.html (still WIP)
This only thing that really bugs me is the too small editing box, but that has something to do with the css styles and not the board software.
If it’s just that: get Chrome and pull that box as big as you want
Speaking of serious issues in php… ruby isn’t really better: http://heise.de/-1872394 it seems…
That’s because ANet isn’t using php (most likely) as their server language. Some users told me it was ruby, so yeah php is out of the question.
If i had the coice between user friendly and programmer friendly web hosting, what would i choose if i was Anet?
This board software is a pain in the kitten to work with. Sorry Anet bad choice, very bad choice.
+1 for this.
Y U NO USE VBULLETIN OR INVISION POWER BOARD ANET?
(actually even phpbb3 is worlds better)
(edited by smiley.1438)
This is ridiculous :o
Ok, i checked again in 4 browsers, Chrome 28beta, Opera beta (webkit, same engine as Chrome), Firefox 21 and IE10 – works fine in all now. Whatever anyone has done… it helped, thanks. Please don’t break it again!
Would be nice if Arenanet would release an official asset kit containing all those icons for use with the API or some sort of tool to pull the data from the gw2.dat. People have already started to pull the data in some ways from the AH which i believe wasn’t intended. Official sources would also help the wikis
Thanks for that information, very interesting read!