Last change
on this file since 3201 was
3177,
checked in by nico, 12 years ago
|
- Change test for php-cli mode in sample programs
|
-
Property svn:executable set to
*
|
File size:
1.1 KB
|
Rev | Line | |
---|
[3120] | 1 | #!/usr/bin/php5 |
---|
[3126] | 2 | <?php |
---|
[3172] | 3 | /* |
---|
| 4 | * dithering.php sample program for libcaca php binding |
---|
| 5 | * Copyright (c) 2008 Nicolas Vion <nico@yojik.eu> |
---|
| 6 | * |
---|
| 7 | * This program is free software. It comes without any warranty, to |
---|
| 8 | * the extent permitted by applicable law. You can redistribute it |
---|
| 9 | * and/or modify it under the terms of the Do What The Fuck You Want |
---|
| 10 | * To Public License, Version 2, as published by Sam Hocevar. See |
---|
| 11 | * http://sam.zoy.org/wtfpl/COPYING for more details. |
---|
| 12 | */ |
---|
| 13 | |
---|
[3177] | 14 | if (php_sapi_name() != "cli") { |
---|
[3175] | 15 | die("You have to run this program with php-cli!\n"); |
---|
[3177] | 16 | } |
---|
[3175] | 17 | |
---|
[3120] | 18 | $img = imagecreatefrompng(dirname(__FILE__)."/logo-caca.png"); |
---|
[3177] | 19 | if (!$img) { |
---|
[3126] | 20 | die("Can not open image.\n"); |
---|
[3177] | 21 | } |
---|
[3126] | 22 | |
---|
[3148] | 23 | $dither = caca_create_dither($img); |
---|
[3177] | 24 | if (!$dither) { |
---|
[3154] | 25 | die("Can not create dither. Maybe you compiled caca-php without gd support.\n"); |
---|
[3177] | 26 | } |
---|
[3123] | 27 | |
---|
[3120] | 28 | $canvas = caca_create_canvas(0, 0); |
---|
[3122] | 29 | $display = caca_create_display($canvas); |
---|
[3177] | 30 | if (!$display) { |
---|
[3123] | 31 | die("Can not create display.\n"); |
---|
[3177] | 32 | } |
---|
[3120] | 33 | |
---|
[3148] | 34 | caca_dither_bitmap($canvas, 0, 0, caca_get_canvas_width($canvas), caca_get_canvas_height($canvas), $dither, $img); |
---|
[3122] | 35 | caca_refresh_display($display); |
---|
| 36 | |
---|
[3175] | 37 | caca_get_event($display, CACA_EVENT_KEY_PRESS, -1); |
---|
[3122] | 38 | |
---|
[3135] | 39 | ?> |
---|
Note: See
TracBrowser
for help on using the repository browser.