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

Last change on this file since 4333 was 4333, checked in by Sam Hocevar, 10 years ago

Large source code cleanup, getting rid of spaces, tabs, and svn keywords.

  • 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@hocevar.net>
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://sam.zoy.org/wtfpl/COPYING 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);
48if(! $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
57caca_set_color_ansi($sprite, CACA_LIGHTMAGENTA, CACA_BLACK);
58caca_import_string($sprite, $pig, "text");
59caca_blit($image, 55, 0, $sprite);
60
61caca_set_color_ansi($sprite, CACA_LIGHTGREEN, CACA_BLACK);
62caca_import_string($sprite, $duck, "text");
63caca_blit($image, 30, 1, $sprite);
64
65caca_set_color_ansi($image, CACA_LIGHTCYAN, CACA_BLACK);
66caca_put_str($image, 1, 1, "hahaha mais vieux porc immonde !! [⽼ ⾗]");
67caca_set_color_ansi($image, CACA_LIGHTRED, CACA_BLACK);
68caca_put_char($image, 38, 1, ord('|'));
69
70caca_set_color_ansi($image, CACA_YELLOW, CACA_BLACK);
71caca_put_str($image, 4, 2, "\\o\\ \\o| _o/ \\o_ |o/ /o/");
72
73caca_set_color_ansi($image, CACA_WHITE, CACA_LIGHTRED);
74caca_put_str($image, 7, 3, "▙▘▌▙▘▞▖▞▖▌ ▞▖▌ ▌▌");
75caca_put_str($image, 7, 4, "▛▖▌▛▖▚▘▚▘▚▖▚▘▚▖▖▖");
76caca_set_color_ansi($image, CACA_BLACK, CACA_LIGHTRED);
77caca_put_str($image, 4, 3, "▓▒░");
78caca_put_str($image, 4, 4, "▓▒░");
79caca_put_str($image, 24, 3, "░▒▓");
80caca_put_str($image, 24, 4, "░▒▓");
81
82/* Blit the transformed canvas onto the main canvas */
83caca_set_color_ansi($cv, CACA_WHITE, CACA_BLUE);
84caca_put_str($cv, 0, 0, "normal");
85caca_blit($cv, 10, 0, $image);
86
87caca_put_str($cv, 0, 6, "flip");
88caca_blit($tmp, 0, 0, $image);
89caca_flip($tmp);
90caca_blit($cv, 10, 6, $tmp);
91
92caca_put_str($cv, 0, 12, "flop");
93caca_blit($tmp, 0, 0, $image);
94caca_flop($tmp);
95caca_blit($cv, 10, 12, $tmp);
96
97caca_put_str($cv, 0, 18, "rotate");
98caca_blit($tmp, 0, 0, $image);
99caca_rotate_180($tmp);
100caca_blit($cv, 10, 18, $tmp);
101
102echo caca_export_string($cv, "html3");
103
104?>
105</body>
106</html>
Note: See TracBrowser for help on using the repository browser.