Jump to content

GD Colorcoded map Generator


joeshanak

Recommended Posts

Im writing a voting program to designed around how a presidential election goes about. It's for a class (U.S. Government) project.

The Idea I have is that youll be able to register and vote for a candidate. Then it will find the winning party in each state and tally up the electoral votes.

In the end I want it to generate a color coded map of the U.S. Where each state is color coded for each parties color.

How would I go about generating an Image like this in GD.

Link to comment
https://forums.phpfreaks.com/topic/133149-gd-colorcoded-map-generator/
Share on other sites

i would do it by first taking a map separating it into one image per state then making it 2 images per state one red and one blue then when the results are in get it to past the images onto a map to make a complete with different colored states.

 

Scott.

Build`100 images 2 of each state red/blue (yes square images)

 

the non state parts (the borders) needs to be a single off color like a orange or purple as this color will be a transparent color that will be colored.

 

Then use the transparent color function in the gd library to remove the outlines of the states as you build an image (placing each sub image on a larger image)

 

I don't have the exact code but once set up all you need to do is set up little controls for the source file of each state's started image.

 

You also need to carefully rebuild the whole mpa by positioning each sub unit properly.

 

To do this I suggest you build the map as 1 image and then partition off each state 1 by 1 making the transparent bg  and note its original X/Y in the whole image.

 

Then use those X/Y back into the gd positioning in php

 

 

 

Umm... I was thinking more of a way in which I could flood fill a state with a color. because I don't necessarily want just republican and democrat candidates. Each candidate is going to be assigned a color. I have a starter map that is just white and black. just basic lines.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.