Jump to content

Change Text Color


brandedmugs

Recommended Posts

I have a web page that generates font images so viewers can preview different fonts. I now want to add the feature of letting the viewer change the color of the font by selecting from a menu of colors. I have the first part of the code (GET color.....), but I do not know how to call the variables using a menu in the HTML. Any help is very much appreciated. Here is what I have for the PHP part:

 

if ($_GET['color'] == 'red')

$textcolor = ImageColorAllocate ($im, 255, 0, 0);

else if ($_GET['color'] == 'blue')

$textcolor = ImageColorAllocate ($im, 0, 0, 255);

else if ($_GET['color'] == 'green')

$textcolor = ImageColorAllocate ($im, 0, 255, 0);

else

$textcolor = ImageColorAllocate ($im, 0, 0, 0);

 

ImageTTFText ($im, $size, 0, 0, -$textdims[5], $textcolor, $fonturl, $text);

ImagePng ($im);

ImageDestroy ($im);

die();

} else {

?>

Link to comment
https://forums.phpfreaks.com/topic/48546-change-text-color/
Share on other sites

<form action="show_me_font_images.php" method="get">
Choose font color: <select name="color">
<option value="red">Red</option>
<option value="blue">Blue</option>
<option value="green">Green</option>
<input type="submit" value="Choose Color"/>
</form>

 

Like that?

Link to comment
https://forums.phpfreaks.com/topic/48546-change-text-color/#findComment-237677
Share on other sites

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.