Welcome to our forums...

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed.

Forum Statistics

  • Forum Members:
  • Total Threads:
  • Total Posts: 3
There are 1 users currently browsing forums.
Reply
  #1  
Old 03-27-2008
PHP Lover
 
Join Date: Oct 2006
Location: USA
Age: 17
Posts: 151
Rep Power: 4
bugscripts is on a distinguished road
ASCII Art Generator

This isn't a "upload image, get it converted into text" type site. Instead, you type in some text, and the script makes a larger version of the same text out of symbols.
PHP Code:
[...]
<?php
include('font.php');
@
$text $_POST['text'];
if(
$_POST['fontsize'] != ''$fontsize $_POST['fontsize']; else $fontsize 9;
if(
$_POST['spacing'] != ''$spacing $_POST['spacing']; else $spacing 9;
if(!isset(
$text))
{
    
$text 'you forgot to enter some text!';
}
if(!isset(
$fontsize))
{
    
$fontsize 9;
}
if(!isset(
$spacing))
{
    
$spacing 9;
}
$lines = array(
    
=> '',
    
=> '',
    
=> '',
    
=> '',
    
=> '',
    
=> '',
);
for(
$i 0$i strlen($text); $i++)
{
    
$char strtolower($text{$i});
    if(
array_key_exists($char$font))
    {
        
$bigchar explode("\n"$font[$char]);
        
$longestline 0;
        for(
$j 0$j 6$j++)
        {
            for(
$k 0$k strlen($bigchar[$j]); $k++)
            {
                if(
strlen($bigchar[$j]) > $longestline)
                {
                    
$longestline strlen($bigchar[$j]);
                }
            }
        }
        for(
$j 0$j 6$j++)
        {
            for(
$k 0$k strlen($bigchar[$j]); $k++)
            {
                if(
strlen($bigchar[$j]) < $longestline)
                {
                    for(
$l strlen($bigchar[$j]); $l $longestline$l++)
                    {
                        
$bigchar[$j] .= '&nbsp;';
                    }
                }
            }
            
$lines[$j] .= $bigchar[$j];
        }
    }
}
echo 
'
<h1>Your textified text</h1>
<div style="white-space: nowrap; font-family: Monaco; font-size: '
.$fontsize.'px; line-height: '.$spacing.'px; overflow: scroll; width: 100%; padding-bottom: 10px;">
'
;
for(
$i 0$i 6$i++)
{
    echo 
str_replace(' ''&nbsp;'$lines[$i])."<br/>";
}
echo 
'</div><h1>How to use it</h1>
Copy the text from the box above. If using it in HTML, make sure you replace all the spaces with &amp;nbsp; (or you can copy the source code of this page). The font should be something monospaced (here it is Monaco).
'
;
?>
[...]
It is mostly a simple script, except that when I made the font (a PHP array in a separate file) I didn't add spaces at the end of each line of the characters, so I had to write 24 extra lines of code (4 nested for loops at one point...), to fix the problem. If you want to try it out, it's at http://textify.1scripts.net/.
__________________

Reply With Quote
  #2  
Old 04-06-2009
Toddler
 
Join Date: Jan 2008
Location: In A House
Age: 13
Posts: 42
Rep Power: 0
Jacob The Coding Expert is on a distinguished road
Re: ASCII Art Generator

I like the idea, where can I get the fonts.php file?
Reply With Quote
  #3  
Old 03-11-2010
Looking#'s Avatar
Toddler
 
Join Date: Mar 2010
Location: Maryland
Posts: 24
Rep Power: 0
Looking# is on a distinguished road
Re: ASCII Art Generator

It didn't work for me either, because of the missing fonts.php file. It seems like a lot of fun, so upload it when you can.
Reply With Quote


Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
C# Code Generator cameronjones C and C++ Programming 8 12-17-2007 02:47 AM
ASCII Art Generator v2 sirjavabean Share a PHP Script 8 01-29-2007 07:32 PM
ASCII Art Generator sirjavabean PHP Scripting 31 09-29-2006 05:14 PM
Vector Art supericy Graphics and Visuals 21 07-06-2005 02:37 PM