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
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>

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.