Debian Codegraph @

caca-php/examples/www/transform.php

raw
1 <?php
2 header('Content-Type: text/html; charset=UTF-8');
3 ?>
4 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
5 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
6
7 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
8 <?php
9 /*
10 * transform transformation test program
11 * Copyright (c) 2008 Benjamin C. Wiley Sittler <[email protected]>
12 *
13 * This file is a Php port of "examples/transform.c"
14 * which is:
15 * Copyright (c) 2006 Sam Hocevar <[email protected]>
16 * All Rights Reserved
17 *
18 * This program is free software. It comes without any warranty, to
19 * the extent permitted by applicable law. You can redistribute it
20 * and/or modify it under the terms of the Do What the Fuck You Want
21 * to Public License, Version 2, as published by Sam Hocevar. See
22 * http://www.wtfpl.net/ for more details.
23 */
24 ?>
25 <head>
26 <title>transformation test program</title>
27 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
28 </head>
29 <body text="silver" bgcolor="black">
30 <?php
31
32 $pig = (
33 ",--. ,--.\n" .
34 "\\ /-~-\\ /\n" .
35 " )' o O `(\n" .
36 "( ,---. )\n" .
37 " `(_o_o_)'\n" .
38 " )`-'(\n");
39
40 $duck = (
41 " ,~~.\n" .
42 " __ , ( O )>\n" .
43 "___( o)> )`~~' (\n" .
44 "\\ <_. ) ( .__) )\n" .
45 " `---' `-.____,'\n");
46
47 $cv = caca_create_canvas(80, 25);
48 if(! $cv)
49 {
50 die("Can't created canvas\n");
51 }
52
53 $image = caca_create_canvas(70, 6);
54 $tmp = caca_create_canvas(70, 6);
55 $sprite = caca_create_canvas(0, 0);
56
57 caca_set_color_ansi($sprite, CACA_LIGHTMAGENTA, CACA_BLACK);
58 caca_import_string($sprite, $pig, "text");
59 caca_blit($image, 55, 0, $sprite);
60
61 caca_set_color_ansi($sprite, CACA_LIGHTGREEN, CACA_BLACK);
62 caca_import_string($sprite, $duck, "text");
63 caca_blit($image, 30, 1, $sprite);
64
65 caca_set_color_ansi($image, CACA_LIGHTCYAN, CACA_BLACK);
66 caca_put_str($image, 1, 1, "hahaha mais vieux porc immonde !! [⽼ ⾗]");
67 caca_set_color_ansi($image, CACA_LIGHTRED, CACA_BLACK);
68 caca_put_char($image, 38, 1, ord('|'));
69
70 caca_set_color_ansi($image, CACA_YELLOW, CACA_BLACK);
71 caca_put_str($image, 4, 2, "\\o\\ \\o| _o/ \\o_ |o/ /o/");
72
73 caca_set_color_ansi($image, CACA_WHITE, CACA_LIGHTRED);
74 caca_put_str($image, 7, 3, "▙▘▌▙▘▞▖▞▖▌ ▞▖▌ ▌▌");
75 caca_put_str($image, 7, 4, "▛▖▌▛▖▚▘▚▘▚▖▚▘▚▖▖▖");
76 caca_set_color_ansi($image, CACA_BLACK, CACA_LIGHTRED);
77 caca_put_str($image, 4, 3, "▓▒░");
78 caca_put_str($image, 4, 4, "▓▒░");
79 caca_put_str($image, 24, 3, "░▒▓");
80 caca_put_str($image, 24, 4, "░▒▓");
81
82 /* Blit the transformed canvas onto the main canvas */
83 caca_set_color_ansi($cv, CACA_WHITE, CACA_BLUE);
84 caca_put_str($cv, 0, 0, "normal");
85 caca_blit($cv, 10, 0, $image);
86
87 caca_put_str($cv, 0, 6, "flip");
88 caca_blit($tmp, 0, 0, $image);
89 caca_flip($tmp);
90 caca_blit($cv, 10, 6, $tmp);
91
92 caca_put_str($cv, 0, 12, "flop");
93 caca_blit($tmp, 0, 0, $image);
94 caca_flop($tmp);
95 caca_blit($cv, 10, 12, $tmp);
96
97 caca_put_str($cv, 0, 18, "rotate");
98 caca_blit($tmp, 0, 0, $image);
99 caca_rotate_180($tmp);
100 caca_blit($cv, 10, 18, $tmp);
101
102 echo caca_export_string($cv, "html3");
103
104 ?>
105 </body>
106 </html>