source: libcaca/trunk/caca-php/examples/www/transform.php @ 3276

Last change on this file since 3276 was 3276, checked in by bsittler, 12 years ago

htmlize

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