Jump to content

Ascii Art Generator (really basic)


orange
 Share

Recommended Posts

post-12752-1186610761_thumb.jpg post-12752-1186610293_thumb.jpg

He said that I couldn't program an Ascii Art generator in 10 minutes. Well - I have a new $20.00 to my name. Word. (Pun?)

Anyway, here it is. Its REALLY basic, and REALLY low resolution, and frankly embarassing, but its kinda cool. Someone please create a better one. Anyone beat 8 minutes 35 seconds?

There is no chance in hell that I can program faster than anyone.

_________________

Edit:

Instructions: Run, Click upper left corner of image, then click lower right corner.

#include<array.au3>
#include<string.au3>

$string = " |.|||'|,||||||||:|;|!|*|-|~|+|<|=|>|{|}|/|(|)||||?||%|#|&|$|@|"
$SymbolArray = stringsplit($string,"|")
_ArrayDelete($SymbolArray,0)

While _ispressed(01) = 0 
    sleep (10)
WEnd

ToolTip("This is the upper left corner. Move the mouse to the lower right corner.")
$Pos1 = MouseGetPos()
sleep(250)

While _ispressed(01) = 0 
    sleep (10)
WEnd

$Pos2 = MouseGetPos()
ToolTip("")
$xdiff = abs($Pos1[0] - $Pos2[0])
$ydiff = abs($Pos1[1] - $Pos2[1])
$string = ""
progresson("","")
for $y = 0 to $ydiff step 1
    progressset($y/$ydiff *100)
    for $x = 0 to $xdiff step 1
        $color = PixelGetColor($Pos1[0] + $x, $Pos1[1] + $y)
        if hex($color) = "00FFFFFF" then 
            $letter = " "
        Else
            $percent1 = dec(Hex(stringright($color,2)))/256 
            if $percent1 < 0.01 then $percent1 = $percent1 * 10                 
            $percent2 = dec(Hex(stringmid($color,3,2)))/256 
            if $percent2 < 0.01 then $percent2 = $percent2 * 10             
            $percent3 = dec(Hex(stringmid($color,5,2)))/256 
            if $percent3 < 0.01 then $percent3 = $percent3 * 10                 
            $percent =( $percent1 + $percent2 + $percent3) / 3          
            $number = int($percent * 41)            
            $letter = $SymbolArray[$number]
        EndIf       
        $string = $string & $letter
    Next
    $string = $string & @crlf
Next
clipput($string)
progressoff()
msgbox(0,0,"Your ASCII Art Pic is on the Clipboard...")
Edited by orange
Link to comment
Share on other sites

post-12752-1186613078_thumb.jpg post-12752-1186612721_thumb.jpg

Improved:

#include<array.au3>
#include<string.au3>

$string = " |.|||'|,||||||||:|;|!|*|-|~|+|<|=|>|{|}|/|(|)||||?||%|#|&|$|@|"
$SymbolArray = stringsplit($string,"|")
_ArrayDelete($SymbolArray,0)

While _ispressed(01) = 0 
    sleep (10)
WEnd

ToolTip("This is the upper left corner. Move the mouse to the lower right corner.")
$Pos1 = MouseGetPos()
sleep(250)

While _ispressed(01) = 0 
    sleep (10)
WEnd

$Pos2 = MouseGetPos()
ToolTip("")
$xdiff = abs($Pos1[0] - $Pos2[0])
$ydiff = abs($Pos1[1] - $Pos2[1])
$string = ""
$COlorString = ""
progresson("","")

dim $pixeldump [$ydiff*2][$xdiff*2]

for $y = 0 to $ydiff-1 step 0.5
    progressset($y/$ydiff *100)
    for $x = 0 to $xdiff-1 step 0.5
        $color = PixelGetColor($Pos1[0] + $x, $Pos1[1] + $y)
        
        if stringinstr($ColorString,$color) = 0 then 
            $ColorString = $ColorString & "|" &$color
        EndIf   
        $pixeldump[$y*2][$x*2] = $color
    Next
Next





$colorsarray = stringsplit($ColorString,"|")
_ArrayDelete($colorsarray,0)


for $y = 0 to $ydiff*2-1 step 1
    progressset($y/$ydiff *100)
    for $x = 0 to $xdiff*2-1 step 1
        $W_color = $pixeldump [$y][$x]
        $index = 0
        for $var = 0 to ubound($colorsarray) -1 
            if $colorsarray[$var]  = $W_color then
                $index = $var
                ExitLoop
            EndIf
        Next
        $percent = abs($index/(ubound($colorsarray)-1))
        $index = abs($percent * (ubound($SymbolArray)-1))
        consolewrite($index & @crlf)
        $string = $string & $SymbolArray[$index]        
    Next
    $string = $string & @crlf 
Next

clipput($string)
progressoff()
msgbox(0,0,"Your ASCII Art Pic is on the Clipboard...")
Edited by orange
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...