1 | <?php |
---|
2 | $pngmode = isset($_REQUEST['png']) ? ($_REQUEST['png'] != '') : false; |
---|
3 | |
---|
4 | if ($pngmode) |
---|
5 | header('Content-Type: image/png'); |
---|
6 | else |
---|
7 | header('Content-Type: text/html; charset=UTF-8'); |
---|
8 | |
---|
9 | if (! $pngmode) |
---|
10 | { |
---|
11 | ?> |
---|
12 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" |
---|
13 | "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
---|
14 | |
---|
15 | <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> |
---|
16 | <head> |
---|
17 | <title>Я люблю Либкаку</title> |
---|
18 | <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> |
---|
19 | <link rel="StyleSheet" href="caca-php.css" type="text/css" /> |
---|
20 | </head> |
---|
21 | <body text="silver" bgcolor="black"> |
---|
22 | <?php |
---|
23 | ; |
---|
24 | } |
---|
25 | $pig_str = <<<EOT |
---|
26 | |
---|
27 | _._ _..._ .-', _.._(`)) |
---|
28 | '-. ` ' /-._.-' ',/ |
---|
29 | ) \ '. |
---|
30 | / _ _ | \ |
---|
31 | | a a / PHP | |
---|
32 | \ .-. ; |
---|
33 | '-('' ).-' ,' ; |
---|
34 | '-; | .' |
---|
35 | \ \ / |
---|
36 | | 7 .__ _.-\ \ |
---|
37 | | | | ``/ /` / |
---|
38 | jgs /,_| | /,_/ / |
---|
39 | /,_/ '`-' |
---|
40 | EOT; |
---|
41 | |
---|
42 | $canvas = caca_create_canvas(0, 0); |
---|
43 | caca_set_color_ansi($canvas, CACA_RED, CACA_WHITE); |
---|
44 | caca_import_string($canvas, $pig_str, "text"); |
---|
45 | caca_set_color_ansi($canvas, CACA_BLUE, CACA_LIGHTGRAY); |
---|
46 | caca_put_str($canvas, 0, 0, "Я люблю Либкаку"); |
---|
47 | if (! $pngmode) |
---|
48 | echo caca_export_string($canvas, "html3"); |
---|
49 | |
---|
50 | $font = caca_load_builtin_font("Monospace Bold 12"); |
---|
51 | |
---|
52 | $width = caca_get_canvas_width($canvas) * caca_get_font_width($font); |
---|
53 | $height = caca_get_canvas_height($canvas) * caca_get_font_height($font); |
---|
54 | |
---|
55 | $img = imagecreatetruecolor($width, $height); |
---|
56 | |
---|
57 | caca_render_canvas($canvas, $font, $img); |
---|
58 | |
---|
59 | if ($pngmode) |
---|
60 | imagepng($img); |
---|
61 | else |
---|
62 | { |
---|
63 | ?> |
---|
64 | <form action="#"> |
---|
65 | <label for="png">Please, open new created png file:</label> |
---|
66 | <input type="submit" id="png" name="png" value="Display" /> |
---|
67 | </form> |
---|
68 | </body> |
---|
69 | </html> |
---|
70 | <?php |
---|
71 | ; |
---|
72 | } |
---|