]>
git.r.bdr.sh - rbdr/r.bdr.sh/blob - jekyll/gaby/nyawnyawnyaw.php
d196098171d9ade67016ed4ff23827fd3aa181c4
3 $db = mysql_connect("localhost","nsovocal_main","GimmehDB!!");
4 mysql_set_charset ( 'utf8', $db );
5 mysql_select_db("nsovocal_main");
8 mysql_query('SELECT @count := COUNT(*) FROM `gab_ascii`');
9 mysql_query('SET @offset = CONVERT(FLOOR(RAND() * @count), SIGNED)');
10 mysql_query('PREPARE `randquery` FROM "SELECT * FROM `gab_ascii` LIMIT ?, 1"');
14 for($i = 0; $i < 20; $i++
){
15 mysql_query('SET @offset = CONVERT(FLOOR(RAND() * @count), SIGNED)');
16 $res = mysql_query('EXECUTE `randquery` USING @offset');
17 $rows[$i] = mysql_fetch_assoc($res);
24 for($i = 0; $i < 25; $i++
){
25 for ($j = 0; $j < 80; $j++
){
30 function getCharArray ($jstring)
32 if (mb_strlen ($jstring, 'UTF-8') == 0)
36 $alen = strlen ($jstring);
38 for ($i = 0; $i < $alen; $i++
) {
39 $char .= $jstring[$i];
40 if (mb_check_encoding ($char, 'UTF-8')) {
41 array_push ($ret, $char);
49 function can_place($w,$h,$x,$y){
51 for($i = $y; $i < $y+
$h; $i++
){
52 for ($j = $x; $j < $x+
$w; $j++
){
53 if($area[$i][$j] != 0){
61 function do_place($row,$x,$y){
62 global $area, $chars, $counter;
63 for($i = $y,$ch = 0; $i < $y+
$row['height']; $i++
,$ch++
){
64 for ($j = $x,$cw = 0; $j < $x+
$row['width']; $j++
,$cw++
){
65 if($ch == 0 && $cw == 0){ $area
[$i
][$j
] = 2; }else{ $area
[$i
][$j
] = 1;}
66 $text = getCharArray($row['text']);
67 $chars[$i][$j] = $text[($row['width']*$ch)+
$cw];
73 foreach($rows as $row){
74 if($counter < 660){ //try to keep it at 33% fill.
75 $tries = 0; //lets do only 10 tries.
77 while(!$placed && $tries < 10){ //while it isn't placed and we still have tries
78 $x = rand (0, 80-$row['width'] ); //get a valid root point
79 $y = rand (0, 25-$row['height'] );
81 if(can_place($row['width'],$row['height'],$x,$y)){
92 <!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
93 <html xmlns
="http://www.w3.org/1999/xhtml" xml
:lang
="en" lang
="en" dir
="ltr">
95 <title
>nyaw nyaw nyaw
:3</title
>
96 <style type
="text/css">
100 src
: url('mona.ttf') format('truetype');
114 background
-color
: #fff;
126 font
-family
: Mona
,'MS PGothic', monospace
;
145 background
-color
: #c00;
150 <meta http
-equiv
="Content-Type" content
="text/html; charset=utf-8"/>
151 <script src
="http://www.google.com/jsapi" type
="text/javascript"></script
>
152 <script type
="text/javascript">
154 google
.load("jquery", "1.4.0");
160 for($i = 0; $i < 25; $i++
){
161 for ($j = 0; $j < 80; $j++
){
162 if($area[$i][$j] != 0){
163 echo "<span class=\"letter test\" id=\"letter-".((80*$i)+
$j)."\">".htmlspecialchars($chars[$i][$j])."</span>";
165 echo "<span class=\"letter\" id=\"letter-".((80*$i)+
$j)."\">".htmlspecialchars(chr(rand(33,126)))."</span>";
168 echo "<div id=\"clear\"/> </div>\n";