source: libcaca/trunk/caca-php/examples/render.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:executable set to *
File size: 1.2 KB
Line 
1#!/usr/bin/php5
2<?
3
4if (php_sapi_name() != "cli") {
5    die("You have to run this program with php-cli!\n");
6}
7
8$pig_str = <<<EOT
9
10    _._ _..._ .-',     _.._(`))
11   '-. `     '  /-._.-'    ',/
12      )         \            '.
13     / _    _    |             \
14    |  a    a    /   PHP        |
15    \   .-.                     ;
16     '-('' ).-'       ,'       ;
17        '-;           |      .'
18           \           \    /
19           | 7  .__  _.-\   \
20           | |  |  ``/  /`  /
21      jgs /,_|  |   /,_/   /
22             /,_/      '`-'
23EOT;
24
25$canvas = caca_create_canvas(0, 0);
26caca_set_color_ansi($canvas, CACA_RED, CACA_WHITE);
27caca_import_string($canvas, $pig_str, "text");
28caca_set_color_ansi($canvas, CACA_BLUE, CACA_LIGHTGRAY);
29caca_put_str($canvas, 0, 0, "Я люблю Либкаку");
30echo caca_export_string($canvas, "utf8");
31
32$font = caca_load_builtin_font("Monospace Bold 12");
33
34$width = caca_get_canvas_width($canvas) * caca_get_font_width($font);
35$height = caca_get_canvas_height($canvas) * caca_get_font_height($font);
36
37$img = imagecreatetruecolor($width, $height);
38
39caca_render_canvas($canvas, $font, $img);
40
41imagepng($img, "out.png");
42echo "Please, open new created png file: out.png\n";
43
44?>
Note: See TracBrowser for help on using the repository browser.