|
changing color options in php.
I think this will be the last question for this site. Although I wouldn't make a bet on this.
The problem lies on this page. At the bottom there is an option to "select your color". Since this was done, the client has asked to change some of the colors and add some new ones.
I'm at a loss for how to do this since each time I've messed with it, I've had nothing on the page left except for graphics and css styling.
Not sure what files you will need to see to get this to work. I have a page called test2. php that has all the colors and their rgb numbers. Each time I change the colors in the test2. php things do not end up well.
I think I'll give you the code for the test2. php:
- Code: Select all
<?php
if(isset($_GET['phrase'])) {
// Set the content-type
header("Content-type: image/png");
// Create the image
$im = imagecreatetruecolor(750, 150);
//create canvas colour
$canvas = imagecolorallocate($im, 255, 223, 251);
// define the path to the selected font
$font = stripslashes($_GET['font']);
//get the phrase and calculate its width for centering
$phrase = stripslashes($_GET['phrase']);
//calculate the x and y co-ordinates and set the default font size = 24
$canvas_wid = 375;
$canvas_hgt = 90;
$bbox = imagettfbbox(24, 0, $font, $phrase);
$width = abs($bbox[2] - $bbox[0])/2;
$height = abs($bbox[7]) - abs($bbox[1]);
$x1 = $canvas_wid - $width;
$y1 = $canvas_hgt - $height;
// Initialise the colors and select the correct one
$colour = $_GET['colour'];
if ($colour == 'hotpink') {
$col = imagecolorallocate($im, 255, 105, 180);
}
elseif ($colour == 'lightpink') {
$col = imagecolorallocate($im, 255, 182, 193);
}
elseif ($colour == 'deeppink') {
$col = imagecolorallocate($im, 255, 020, 147);
}
elseif ($colour == 'snow1') {
$col = imagecolorallocate($im, 255, 250, 250);
}
elseif ($colour == 'royalblue4') {
$col = imagecolorallocate($im, 039, 064, 139);
}
elseif ($colour == 'blue4') {
$col = imagecolorallocate($im, 000, 000, 139);
}
elseif ($colour == 'red3') {
$col = imagecolorallocate($im, 205, 000, 000);
}
elseif ($colour == 'red4') {
$col = imagecolorallocate($im, 139, 000, 000);
}
elseif ($colour == 'grey36') {
$col = imagecolorallocate($im, 092, 092, 092);
}
elseif ($colour == 'grey61') {
$col = imagecolorallocate($im, 156, 156, 156);
}
elseif ($colour == 'orangered1') {
$col = imagecolorallocate($im, 255, 069, 000);
}
elseif ($colour == 'goldenrod1') {
$col = imagecolorallocate($im, 255, 193, 137);
}
elseif ($colour == 'honeydew1') {
$col = imagecolorallocate($im, 240, 255, 240);
}
elseif ($colour == 'ghostwhitematt') {
$col = imagecolorallocate($im, 248, 248, 255);
}
elseif ($colour == 'ghostwhiteshiny') {
$col = imagecolorallocate($im, 248, 248, 255);
}
elseif ($colour == 'blackmatt') {
$col = imagecolorallocate($im, 000, 000, 000);
}
elseif ($colour == 'blackshiny') {
$col = imagecolorallocate($im, 000, 000, 000);
}
elseif ($colour == 'darkturquoise') {
$col = imagecolorallocate($im, 000, 206, 209);
}
elseif ($colour == 'limegreen') {
$col = imagecolorallocate($im, 050, 205, 050);
}
elseif ($colour == 'saddlebrown') {
$col = imagecolorallocate($im, 139, 069, 019);
}
elseif ($colour == 'tan') {
$col = imagecolorallocate($im, 210, 180, 140);
}
elseif ($colour == 'beige') {
$col = imagecolorallocate($im, 245, 245, 220);
}
else {
$col = imagecolorallocate($im, 0, 0, 0);
}
//select a suitible font size and center it in the canvas -- This is guesswork as all phrases are different sizes
if(($width*2) > 760) {
$size = 15;
$bbox = imagettfbbox($size, 0, $font, $phrase);
$width = abs($bbox[2] - $bbox[0])/2;
$height = abs($bbox[7]) - abs($bbox[1]);
$x1 = $canvas_wid - $width;
$y1 = $canvas_hgt - $height;
}
else {
$size = 24;
}
//create a border
imagefilledrectangle($im, 1, 1, 748, 148, $canvas);
// Add the text
imagettftext($im, $size, 0, $x1, $y1, $col, $font, $phrase);
// Using imagepng() results in clearer text compared with imagejpeg()
imagepng($im);
imagedestroy($im);
}
?>
Honestly I'm not even sure that's the file you'll need to direct me.
If not, I have another php that I can post the code for.
In case your view source is disabled, here is the code for the preview. php page.
- Code: Select all
<?php
if(isset($_GET["font"])) {
$val = stripslashes($_GET['font']);
echo "<option value=\"$val\" selected=\"selected\">$val</option>";
}
?>
<option value="fonts/Adorable.ttf">Adorable</option>
<option value="fonts/AMAZR___.TTF">AMAZR</option>
<option value="fonts/angelina.TTF">angelina</option>
<option value="fonts/Antique Type.ttf">Antique Type</option>
<option value="fonts/Ashley.ttf">Ashley</option>
<option value="fonts/BLACKJAR.TTF">BLACKJAR</option>
<option value="fonts/BOYZRGRO.TTF">BOYZRGRO</option>
<option value="fonts/BradhITC.TTF">BradhITC</option>
<option value="fonts/CHAMPGNE.TTF">CHAMPAGNE</option>
<option value="fonts/Charlesworth Bold.ttf">Charlesworth Bold</option>
<option value="fonts/ChocolateBox.ttf">Chocolate Box</option>
<option value="fonts/CHOPS___.TTF">CHOPS</option>
<option value="fonts/circus.ttf">Circus</option>
<option value="fonts/comic.ttf">Comic</option>
<option value="fonts/Curlz___.TTF">Curlz</option>
<option value="fonts/ENGAN___.TTF">ENGAN</option>
<option value="fonts/fontdine.ttf">Fontdine</option>
<option value="fonts/FREEBSC_.ttf">FREEBSC</option>
<option value="fonts/Frscript.TTF">Frascript</option>
<option value="fonts/georgia.ttf">Georgia</option>
<option value="fonts/GILLIGAN.TTF">GILLIGAN</option>
<option value="fonts/GIRLW___.TTF">GIRLW</option>
<option value="fonts/ITCEdscr.TTF">ITCEdscr</option>
<option value="fonts/ITCKrist.TTF">ITCKrist</option>
<option value="fonts/Kayleigh.TTF">Kayleigh</option>
<option value="fonts/Laine.TTF">Laine</option>
<option value="fonts/LARIAT.TTF">LARIAT</option>
<option value="fonts/LaurenScript.ttf">LaurenScript</option>
<option value="fonts/LemonChicken.ttf">Lemon Chicken</option>
<option value="fonts/MA Sexy.ttf">MA Sexy</option>
<option value="fonts/Majestic.ttf">Majestic</option>
<option value="fonts/MTCORSVA.TTF">MTCORSVA</option>
<option value="fonts/MURIEL.TTF">MURIEL</option>
<option value="fonts/NASHVILL.TTF">NASHVILL</option>
<option value="fonts/Papyrus.TTF">Papyrus</option>
<option value="fonts/PegsannaHMK.ttf">PegsannaHMK</option>
<option value="fonts/RINGM___.TTF">RINGM</option>
<option value="fonts/Santa's Sleigh.ttf">Santas Sleigh</option>
<option value="fonts/Scriptina.ttf">Scriptina</option>
<option value="fonts/Splendid ES.ttf">Splendid ES</option>
<option value="fonts/SuzanneQuillSH.ttf">SuzanneQuillSH</option>
<option value="fonts/TempsITC.TTF">TempsITC</option>
<option value="fonts/TINKT___.TTF">TINKT</option>
<option value="fonts/UPCJL.TTF">UPCJL</option>
<option value="fonts/Vivaldii.TTF">Vivaldii</option>
<option value="fonts/wds052801.ttf">wds052801</option>
<option value="fonts/Whackadoo.ttf">Whackadoo</option>
<option value="fonts/Witched.TTF">Witched</option>
</select>
<a href=colors_fonts.php>Click here to view our Fonts and Colors page</a> <br />
<br /><br />
<h2>Select Your Color</h2><select name="colour">
<?php
if(isset($_GET["colour"])) {
$val = $_GET['colour'];
echo "<option value=\"$val\" selected=\"selected\">$val</option>";
}
?>
<option value="purple" class="purple">Purple</option>
<option value="hotpink" class="hotpink">Hot Pink</option>
<option value="lightpink" class="lightpink">Light Pink</option>
<option value="red" class="red">Red</option>
<option value="dkred" class="dkred">Burgundy</option>
<option value="orangered1" class="orangered1">Orange</option>
<option value="orangered1" class="orangered1">Orange Red 1</option>
<option value="royalblue4" class="royalblue4">Royal Blue 4</option>
<option value="blue4" class="blue4">Blue 4</option>
<option value="grey36" class="grey36">Grey 36</option>
<option value="grey 61" class="grey 61">Grey 61</option>
<option value="goldenrod1" class="goldenrod1">Golden Rod 1</option>
<option value="honeydew1" class="honeydew1">Honey Dew 1</option>
<option value="ghostwhitematt" class="gostwhitematt">Ghost White Matt</option>
<option value="ghostwhiteshiny" class="ghostwhiteshiny">Ghost White Shiny</option>
<option value="blackmatt" class="blackmatt">Black Matt</option>
<option value="blackshiny" class="blackshiny">Black Shiny</option>
<option value="darkturquoise" class="darkturquoise">Dark Turquoise</option>
<option value="limegreen" class="limegreen">Lime Green</option>
<option value="saddlebrown" class="saddlebrown">Saddle Brown</option>
<option value="tan" class="tan">Tan</option>
<option value="beige" class="biege">Biege</option>
</select>
<br />
<input name="submit" type="submit" value="Update Preview" /><br />
</form> <br />
<br /></div>
<?php
$default = "Your text will appear here";
if(isset($_GET["phrase"])) {
$p = stripslashes($_GET["phrase"]);
$f = stripslashes($_GET["font"]);
$c = $_GET['colour'];
echo "<img src=\"test2.php?phrase=$p&font=$f&colour=$c\" alt=\"\" />";
}
else {
echo "<img src=\"test2.php?phrase=$default&font=fonts/Charlesworth%20Bold.ttf&colour=black\" alt=\"\" />";
}
?>
The code in red is the part that I need to update at this time.
Thanks for your help!!
Linda
|