...

View Full Version : Changing Image Color



ptmuldoon
04-27-2007, 12:56 PM
As I attempt to learn with my map experiment, and perhaps this is not a javascript question, but is it possible to do the following?

I have images where all of the land mass areas are a default white color, as they are considered the 'base' images. Is it possible to have the white land mass areas filled with a specific color when specific actions occur? I'm hoping to avoid having to create 50+ images for each color needed.

Thanks

david_kw
04-27-2007, 04:29 PM
I believe that can be done in PHP (although I'm not positive about that functionality specifically). As I recall it has a pretty comprehensive graphical manipulation package.

I'm not aware of any way to do that in javascript unless you tried to do something tricky like make it an invisible color in the gif/png and set the background color of the image to what you want.

david_kw

NancyJ
04-28-2007, 01:05 AM
This is a pretty hefty site http://tkfashion.swgentertainer.com/ but it does basically what you want... maybe - The javascript was just a bit too hardcore for me. But maybe someone who understands these things better than me can take a look and tell us all how its done ;) In simple terms ofcourse

It could ofcourse be that there really is 1 image for every single colour combination but that seems unlikely

david_kw
04-28-2007, 02:11 AM
I'm not sure exactly how it is working but I am pretty sure it is server side. The JS code points to a directory

var imgname = '/clothespics/' + document.TK_Item;

and creates an image

var newImg = document.TK_TargetImg.ownerDocument.createElement ("IMG");

then sets the src of the image

document.TK_TargetImg.src = imgname + ".png";

So I think it is all done serverside. I didn't look hard enough to see if it was done in a serverside language or by having many different versions of the graphic. I'm not sure I could necessarily tell anyway if I looked harder.

One thing I'm pretty sure is the recoloring isn't done in javascript.

david_kw

NancyJ
04-28-2007, 10:21 AM
I'm not sure exactly how it is working but I am pretty sure it is server side. The JS code points to a directory

var imgname = '/clothespics/' + document.TK_Item;

and creates an image

var newImg = document.TK_TargetImg.ownerDocument.createElement ("IMG");

then sets the src of the image

document.TK_TargetImg.src = imgname + ".png";

So I think it is all done serverside. I didn't look hard enough to see if it was done in a serverside language or by having many different versions of the graphic. I'm not sure I could necessarily tell anyway if I looked harder.

One thing I'm pretty sure is the recoloring isn't done in javascript.

david_kw

Theres a lot of scripting just to basically load an already existing graphic in from the server but maybe it really is that simple.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum