filling colors on a map - PHP

Posted by jeremy on Stack Overflow See other posts from Stack Overflow or by jeremy
Published on 2012-06-08T21:47:22Z Indexed on 2012/06/08 22:40 UTC
Read the original article Hit count: 191

Filed under:
|

I am trying to determine how to fill colors onto a map - such as the "Risk" board game map.

I've done this before with HTML tables, by pulling an HTML color code from a SQL table and then just using it to fill the cell the color I want it.

But for a non-square map, I'm not sure where to look.

I have created a very simple two color map - its white with black borders. My desired result is having the 'regions' on the map shaded with a color, based on data in a sql table (just like the "fill" button in Paint).

This looks like what I need: http://php.net/manual/en/function.imagefilltoborder.php and now.. how to define the borders...

At the moment I have tried nothing, because the question was: how do I have PHP fill parts of an image? I have tried making an image in Paint, and then scratching my head wondering how to fill parts of it.

Having stumbled upon a link, let me focus this a bit more:

It appears that with imagefilltoborder that I can put an image on my server, perhaps one that looks like a black and white version of the RISK map - black borders and white everything else. Some questions:

  1. Is it correct that the 'border' variable should use the color of my border (whatever value black is) so that the code can "see" where the border is?
  2. Is it correct that I'll just need to figure out X,Y coords to begin the fill?
  3. Does this work if I have 10 different spots to fill on the map? Can I use varying colors from code or pulled from SQL to assign different colors to those 10 spots, and use 10 different X,Y coords to get them all?

© Stack Overflow or respective owner

Related posts about php

Related posts about mysql