Jump to content

Creating a Glitter Generator


Riseykins

Recommended Posts

OK, so I'm creating a glitter generator, and I'm a little stuck.

 

I've got the BASIC idea:

 

http://unphased.org/php_post

 

As you can see, it is far from finished. This is something I did in five minutes.

 

Here's an example of what happens presently:

 

Type "hi" into the box, and get out http://www.unphased.org/php_post/hi.jpg out.

 

What I want it to do is generate a new image for each letter:

http://www.unphased.org/php_post/h.jpg http://www.unphased.org/php_post/i.jpg

 

I've not added images yet, but there we go.

 

If anyone could help, I'd appreciate it!

 

Ta!

Link to comment
https://forums.phpfreaks.com/topic/102511-creating-a-glitter-generator/
Share on other sites

First, you need GD image script to create an image of the letter passed to it

 

letter_img.php

<?php 
$im = imagecreate(32,32);
$c = $_GET['char'];
$bgd = imagecolorallocate($im, rand(1,255),rand(1,255),rand(1,255));
$white = imagecolorallocate($im, 255,255,255);
imagettftext($im, 20, 0, 5, 25, $white, 'c:/windows/fonts/arial.ttf', $c);
header("content-type: image/png");
imagepng($im);
imagedestroy($im);
?>

 

Then you need a script to place an image on the page for each letter in the word.

<?php
if (isset($_GET['btn']))
{
    $word = $_GET['word'];
    $x = strlen($word);
    for ($i=0; $i<$x; $i++)
    {
        $c = $word[$i];
        echo "<img src='letter_img.php?char=$c'>";
    }
}
?>
<form>
Word <input type="text" name="word" size="8" />
<input type="submit" name="btn" value="Submit" />
</form>

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.