source: libcaca/trunk/caca-php/examples/www/text.php @ 3204

Last change on this file since 3204 was 3204, checked in by bsittler, 11 years ago

send correct content-type; add a missing doctype (although technically the table is not allowed inside pre, but that we will need to find another fix for)

File size: 2.2 KB
Line 
1<?php
2header('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 *  demo.php      demo for libcaca php binding
11 *  Copyright (c) 2008 Nicolas Vion <nico@yojik.eu>
12 *
13 *  This file is a Php port of the official libcaca's sample program "demo.c"
14 *  which is:
15 *  Copyright (c) 2003 Sam Hocevar <sam@zoy.org>
16 *
17 *  This program is free software. It comes without any warranty, to
18 *  the extent permitted by applicable law. You can redistribute it
19 *  and/or modify it under the terms of the Do What The Fuck You Want
20 *  To Public License, Version 2, as published by Sam Hocevar. See
21 *  http://sam.zoy.org/wtfpl/COPYING for more details.
22 */
23?>
24<head>
25<title>demo for libcaca php binding</title>
26<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
27<link rel="StyleSheet" href="caca-php.css" type="text/css" />
28</head>
29<body text="silver" bgcolor="black">
30<?php
31
32$string =  <<<EOT
33              |_|
34   _,----._   | |
35  (/ @  @ \)   __
36   |  OO  |   |_ 
37   \ `--' /   |__
38    `----'       
39              |_|
40 Hello world!  | 
41EOT;
42       
43$pig = caca_create_canvas(0, 0);
44caca_import_string($pig, $string, "text");
45
46$cv = caca_create_canvas(caca_get_canvas_width($pig) * 2, caca_get_canvas_height($pig) * 2);
47
48if (!$cv or !$pig) {
49        die("Can't created canvas\n");
50}
51
52caca_blit($cv, 0, 0, $pig);
53caca_flip($pig);
54caca_blit($cv, caca_get_canvas_width($pig), 0, $pig);
55caca_flip($pig);
56caca_flop($pig);
57caca_blit($cv, 0, caca_get_canvas_height($pig), $pig);
58caca_flop($pig);
59caca_rotate_180($pig);
60caca_blit($cv, caca_get_canvas_width($pig), caca_get_canvas_height($pig), $pig);
61
62for($j = 0; $j < caca_get_canvas_height($cv); $j++) {
63        for($i = 0; $i < caca_get_canvas_width($cv); $i += 2) {
64                caca_set_color_ansi($cv, CACA_LIGHTBLUE + ($i + $j) % 6, CACA_DEFAULT);
65                $a = caca_get_attr($cv, -1, -1);
66                caca_put_attr($cv, $i, $j, $a);
67                caca_put_attr($cv, $i + 1, $j, $a);
68        }
69}
70
71echo caca_export_string($cv, "html3");
72caca_rotate_left($cv);
73echo caca_export_string($cv, "html3");
74
75?>
76</body>
77</html>
Note: See TracBrowser for help on using the repository browser.