Esempio n. 1
0
    caca_put_str($cv, WIDTH / 2 - 8, HEIGHT / 2 - 2, "[ドラゴン ボーレ]");
    caca_put_str($cv, WIDTH / 2 - 7, HEIGHT / 2 + 2, "äβç ░▒▓█▓▒░ ΔЗҒ");
    caca_put_str($cv, WIDTH / 2 - 5, HEIGHT / 2 + 4, "(\") \\o/ <&>");
    caca_set_attr($cv, CACA_BOLD);
    caca_put_str($cv, WIDTH / 2 - 16, HEIGHT / 2 + 3, "Bold");
    caca_set_attr($cv, CACA_BLINK);
    caca_put_str($cv, WIDTH / 2 - 9, HEIGHT / 2 + 3, "Blink");
    caca_set_attr($cv, CACA_ITALICS);
    caca_put_str($cv, WIDTH / 2 - 1, HEIGHT / 2 + 3, "Italics");
    caca_set_attr($cv, CACA_UNDERLINE);
    caca_put_str($cv, WIDTH / 2 + 8, HEIGHT / 2 + 3, "Underline");
    caca_set_attr($cv, 0);
    caca_set_color_ansi($cv, CACA_WHITE, CACA_LIGHTBLUE);
    caca_put_str($cv, WIDTH / 2 - 7, HEIGHT / 2, "    LIBCACA    ");
    for ($x = 0; $x < 16; $x++) {
        caca_set_color_argb($cv, 0xff00 | $x, 0xf00f | $x << 4);
        caca_put_char($cv, WIDTH / 2 - 7 + $x, HEIGHT / 2 + 6, ord('#'));
    }
}
$content_type_map = array('ansi' => 'text/plain; charset=CP437', 'utf8' => 'text/plain; charset=UTF-8', 'utf8cr' => 'text/plain; charset=UTF-8', 'html' => 'text/html; charset=UTF-8', 'html3' => 'text/html; charset=UTF-8', 'bbfr' => 'text/plain; charset=UTF-8', 'irc' => 'text/plain; charset=UTF-8', 'ps' => 'application/postscript', 'svg' => 'image/svg+xml', 'tga' => 'image/x-targa');
$download_extension_map = array('caca' => 'caca', 'ansi' => 'txt', 'utf8' => 'txt', 'utf8cr' => 'txt', 'irc' => 'txt', 'tga' => 'tga');
$inline_extension_map = array('bbfr' => 'txt', 'ps' => 'ps', 'svg' => 'svg');
if (!array_key_exists($format, $content_type_map)) {
    $content_type = 'application/octet-stream';
} else {
    $content_type = $content_type_map[$format];
}
header('Content-Type: ' . $content_type);
if (array_key_exists($format, $download_extension_map)) {
    header('Content-Disposition: attachment; filename=export.' . $download_extension_map[$format]);
} else {
Esempio n. 2
0
File: caca.php Progetto: dns/libcaca
 function setColorARGB($foreground, $background)
 {
     return caca_set_color_argb($this->cv, $foreground, $background);
 }
Esempio n. 3
0
 *          All Rights Reserved
 *
 *  This program is free software. It comes without any warranty, to
 *  the extent permitted by applicable law. You can redistribute it
 *  and/or modify it under the terms of the Do What the F**k You Want
 *  to Public License, Version 2, as published by Sam Hocevar. See
 *  http://www.wtfpl.net/ for more details.
 */
if (php_sapi_name() != "cli") {
    die("You have to run this program with php-cli!\n");
}
$cv = caca_create_canvas(32, 16);
if (!$cv) {
    die("Failed to create canvas\n");
}
$dp = caca_create_display($cv);
if (!$dp) {
    die("Failed to create display\n");
}
for ($y = 0; $y < 16; $y++) {
    for ($x = 0; $x < 16; $x++) {
        $bgcolor = 0xff00 | $y << 4 | $x;
        $fgcolor = 0xf000 | 15 - $y << 4 | 15 - $x << 8;
        caca_set_color_argb($cv, $fgcolor, $bgcolor);
        caca_put_str($cv, $x * 2, $y, "CA");
    }
}
caca_set_color_ansi($cv, CACA_WHITE, CACA_LIGHTBLUE);
caca_put_str($cv, 2, 1, " truecolor libcaca ");
caca_refresh_display($dp);
caca_get_event($dp, CACA_EVENT_KEY_PRESS, -1);