| 1 | <h1>ASIIArt Evolution Matrix</h1> |
| 2 | <?php |
| 3 | |
| 4 | $aart=''; |
| 5 | $width=20; |
| 6 | $height=10; |
| 7 | $childs=14; |
| 8 | $chars='.*+oO '; |
| 9 | $ratio=9; //probability 1/ratio |
| 10 | |
| 11 | if(isset($_POST['aart'])) $aart=$_POST['aart']; |
| 12 | if(isset($_POST['width'])) $width=$_POST['width']; |
| 13 | if(isset($_POST['height'])) $height=$_POST['height']; |
| 14 | if(isset($_POST['childs'])) $childs=$_POST['childs']; |
| 15 | if(isset($_POST['chars'])) $chars=$_POST['chars']; |
| 16 | if(isset($_POST['ratio'])) $ratio=$_POST['ratio']; |
| 17 | |
| 18 | function mkchild($text, &$chars, $ratio) { |
| 19 | if($text == '') { |
| 20 | for($i=0;$i<$GLOBALS['height'];$i++) { |
| 21 | for($j=0;$j<$GLOBALS['width'];$j++) { |
| 22 | echo($chars[rand(0,strlen($chars)-1)]); |
| 23 | } |
| 24 | echo("\n"); |
| 25 | } |
| 26 | } else { |
| 27 | if(!rand(0,$GLOBALS['childs']*0.7)) { |
| 28 | for($i=0;$i<strlen($chars);$i++) { |
| 29 | $c=$chars[rand(0,strlen($chars)-1)]; |
| 30 | $text=str_replace($chars[rand(0,strlen($chars)-1)], $c, $text); |
| 31 | } |
| 32 | } |
| 33 | |
| 34 | if(!rand(0,$GLOBALS['childs']*0.4)) { |
| 35 | $c=''; $d=0; |
| 36 | for($i=0;$i<strlen($chars);$i++) { |
| 37 | if(substr_count($text, $chars[$i]) > $d) { |
| 38 | $c = $chars[$i]; $d = substr_count($text, $chars[$i]); |
| 39 | } |
| 40 | } |
| 41 | $text=str_replace($chars[rand(0,strlen($chars)-1)], $c, $text); |
| 42 | } |
| 43 | |
| 44 | for($i=0;$i<strlen($text);$i++){ |
| 45 | if(!rand(0,$ratio) && $text[$i]!="\n" && $text[$i]!="\r") { |
| 46 | $text[$i]=$chars[rand(0,strlen($chars)-1)]; |
| 47 | } |
| 48 | } |
| 49 | echo($text); |
| 50 | } |
| 51 | } |
| 52 | |
| 53 | srand(time(0)); |
| 54 | ?> |
| 55 | <form action="?" method="POST" style="display: inline;"> |
| 56 | <textarea name="aart" cols="<?=$width?>" rows="<?=$height?>" style="float: left; display: inline;"><?php echo($aart); ?></textarea><br /> |
| 57 | <input type="hidden" name="width" value="<?=$width ?>"> |
| 58 | <input type="hidden" name="height" value="<?=$height ?>"> |
| 59 | Childs <input type="text" name="childs" value="<?=$childs ?>"> |
| 60 | Charset <input type="text" name="chars" value="<?=$chars ?>"> |
| 61 | Replace 1/<input type="text" name="ratio" value="<?=$ratio ?>"> |
| 62 | <input type="submit" value="SET"> |
| 63 | </form> |
| 64 | <br /><br /> |
| 65 | <form action="?" method="POST" style="float: left; display: inline;"> |
| 66 | Width <input type="text" name="width" value="<?=$width ?>"> |
| 67 | Height <input type="text" name="height" value="<?=$height ?>"> |
| 68 | <input type="hidden" name="childs" value="<?=$childs ?>"> |
| 69 | <input type="hidden" name="chars" value="<?=$chars ?>"> |
| 70 | <input type="hidden" name="ratio" value="<?=$ratio ?>"> |
| 71 | <input type="submit" value="RESET"> |
| 72 | <br /><br /> |
| 73 | <a href="https://kyberia.sk/id/4339876/">Info...</a> |
| 74 | </form> |
| 75 | <form action="?" method="POST" style="float: left; display: inline;"> |
| 76 | /<input type="submit" value="RESET SETTINGS"> |
| 77 | </form> |
| 78 | |
| 79 | <hr style="clear: both;"/> |
| 80 | <?php |
| 81 | for($i=0;$i<$childs;$i++) { |
| 82 | ?> |
| 83 | <form action="?" method="POST" style="float: left; display: inline;"> |
| 84 | <textarea name="aart" cols="<?=$width?>" rows="<?=$height?>"><?php mkchild($aart, $chars, $ratio); ?></textarea><br /> |
| 85 | <input type="hidden" name="width" value="<?=$width ?>"> |
| 86 | <input type="hidden" name="height" value="<?=$height ?>"> |
| 87 | <input type="hidden" name="childs" value="<?=$childs ?>"> |
| 88 | <input type="hidden" name="chars" value="<?=$chars ?>"> |
| 89 | <input type="hidden" name="ratio" value="<?=$ratio ?>"> |
| 90 | <input type="submit" value="<?=$i?>"> |
| 91 | </form> |
| 92 | <?php |
| 93 | } |
| 94 | |
| 95 | |