source: libcaca/trunk/caca-php/examples/dithering.php @ 3174

Last change on this file since 3174 was 3174, checked in by bsittler, 12 years ago

change to allow use with cocoa driver; also, a keypress now stops these demos early

  • Property svn:executable set to *
File size: 1.0 KB
Line 
1#!/usr/bin/php5
2<?php
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
14$img = imagecreatefrompng(dirname(__FILE__)."/logo-caca.png");
15if (!$img)
16        die("Can not open image.\n");
17
18$dither = caca_create_dither($img);
19if (!$dither)
20        die("Can not create dither. Maybe you compiled caca-php without gd support.\n");
21
22$canvas = caca_create_canvas(0, 0);
23$display = caca_create_display($canvas);
24if (!$display)
25        die("Can not create display.\n");
26
27caca_dither_bitmap($canvas, 0, 0, caca_get_canvas_width($canvas), caca_get_canvas_height($canvas), $dither, $img);
28caca_refresh_display($display);
29
30caca_get_event($display, CACA_EVENT_KEY_PRESS, 5000000);
31
32?>
Note: See TracBrowser for help on using the repository browser.