Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder
    Join Date
    Feb 2005
    Posts
    663
    Thanks
    5
    Thanked 14 Times in 14 Posts

    Changing Image Color

    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

  • #2
    Senior Coder
    Join Date
    Nov 2006
    Posts
    1,000
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #3
    Senior Coder NancyJ's Avatar
    Join Date
    Feb 2005
    Location
    Bradford, UK
    Posts
    3,172
    Thanks
    19
    Thanked 65 Times in 64 Posts
    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
    Last edited by NancyJ; 04-28-2007 at 01:13 AM.

  • #4
    Senior Coder
    Join Date
    Nov 2006
    Posts
    1,000
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #5
    Senior Coder NancyJ's Avatar
    Join Date
    Feb 2005
    Location
    Bradford, UK
    Posts
    3,172
    Thanks
    19
    Thanked 65 Times in 64 Posts
    Quote Originally Posted by david_kw View Post
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •