source: libcaca/trunk/caca-php/examples/truecolor.php @ 4148

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

Update my e-mail address everywhere.

  • Property svn:executable set to *
  • Property svn:keywords set to Id
File size: 1.3 KB
Line 
1#!/usr/bin/php5
2<?php
3/*
4 *  truecolor     truecolor canvas features
5 *  Copyright (c) 2008 Benjamin C. Wiley Sittler <bsittler@gmail.com>
6 *
7 *  This file is a Php port of "examples/truecolor.c"
8 *  which is:
9 *  Copyright (c) 2006 Sam Hocevar <sam@hocevar.net>
10 *                All Rights Reserved
11 *
12 *  $Id: truecolor.php 4148 2009-12-19 14:38:38Z sam $
13 *
14 *  This program is free software. It comes without any warranty, to
15 *  the extent permitted by applicable law. You can redistribute it
16 *  and/or modify it under the terms of the Do What The Fuck You Want
17 *  To Public License, Version 2, as published by Sam Hocevar. See
18 *  http://sam.zoy.org/wtfpl/COPYING for more details.
19 */
20
21if (php_sapi_name() != "cli") {
22        die("You have to run this program with php-cli!\n");
23}
24
25$cv = caca_create_canvas(32, 16);
26if(!$cv) {
27        die("Failed to create canvas\n");
28}
29
30$dp = caca_create_display($cv);
31if(!$dp) {
32        die("Failed to create display\n");
33}
34
35for($y = 0; $y < 16; $y++)
36        for($x = 0; $x < 16; $x++)
37        {
38                $bgcolor = 0xff00 | ($y << 4) | $x;
39                $fgcolor = 0xf000 | ((15 - $y) << 4) | ((15 - $x) << 8);
40               
41                caca_set_color_argb($cv, $fgcolor, $bgcolor);
42                caca_put_str($cv, $x * 2, $y, "CA");
43        }
44
45caca_set_color_ansi($cv, CACA_WHITE, CACA_LIGHTBLUE);
46caca_put_str($cv, 2, 1, " truecolor libcaca ");
47
48caca_refresh_display($dp);
49
50caca_get_event($dp, CACA_EVENT_KEY_PRESS, -1);
51
52?>
Note: See TracBrowser for help on using the repository browser.