Jump to content

Creating an opaque filled polygon over existing image


Balandar

Recommended Posts

I am trying to create an opaque filled polygon over an existing image that has text. The image is a map of Indiana with counties on it along with each county name. I want to "highlight" the county when it comes up in a search. Right now I have it so the county has a border drawn around it. I'd rather have an opaque filled polygon instead. But i can't get it to work right.

 

The Code: This is just an extract of the code, but I think you get the general idea. Currently it's not opaque but just a different shade of red, like a pink almost.. and it covers the text, nothing shows through the color.

 

		$image = @imagecreatefromgif("indiana_map_files/stout18.gif"); 
	imagealphablending ( $image, true );

	// choose a color for the polygon
	$col_poly = imagecolorallocate($image, 255, 0, 0);		
	imagesetthickness($image, 3);	
	$red = imagecolorresolvealpha($image, 255, 0, 0, 100);

	foreach($all_ids as $co_id){
		// draw the polygon
		$map_cords = $map_cords_array[$co_id];
		$points = count($map_cords)/2;
		if(!empty($map_cords)){

			imagefilledpolygon($image,
					 $map_cords,
					 $points,
					 $red
					 );						
		}

	}

	imagepng($image, "search_results/$new_image_name.png"); // to file

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.