From bff86e8b8f8127046ab72c43320ce6565009ea47 Mon Sep 17 00:00:00 2001 From: Nicolas Vion Date: Sat, 1 Nov 2008 18:42:16 +0000 Subject: [PATCH] * Add web sample program: dithering.php --- caca-php/examples/www/dithering.php | 42 ++++++++++++++++++++++++++++ caca-php/examples/www/figlet.php | 9 ++++-- caca-php/examples/www/logo-caca.png | Bin 0 -> 7526 bytes 3 files changed, 49 insertions(+), 2 deletions(-) create mode 100755 caca-php/examples/www/dithering.php create mode 100755 caca-php/examples/www/logo-caca.png diff --git a/caca-php/examples/www/dithering.php b/caca-php/examples/www/dithering.php new file mode 100755 index 0000000..327f98b --- /dev/null +++ b/caca-php/examples/www/dithering.php @@ -0,0 +1,42 @@ + + +Caca power! + + + + + + * + * 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 Fuck You Want + * To Public License, Version 2, as published by Sam Hocevar. See + * http://sam.zoy.org/wtfpl/COPYING for more details. + */ + +$src = "logo-caca.png"; +$img = imagecreatefrompng(dirname(__FILE__)."/".$src); +if (!$img) { + die("Can not open image.\n"); +} + +$dither = caca_create_dither($img); +if (!$dither) { + die("Can not create dither. Maybe you compiled caca-php without gd support.\n"); +} + +$canvas = caca_create_canvas(100, 40); + +caca_dither_bitmap($canvas, 0, 0, caca_get_canvas_width($canvas), caca_get_canvas_height($canvas), $dither, $img); + +echo caca_export_string($canvas, "html3"); +echo ""; + +?> + + + diff --git a/caca-php/examples/www/figlet.php b/caca-php/examples/www/figlet.php index 5e896f8..756c7c8 100755 --- a/caca-php/examples/www/figlet.php +++ b/caca-php/examples/www/figlet.php @@ -8,7 +8,7 @@ * * This program is free software. It comes without any warranty, to @@ -47,7 +47,12 @@ function show_figlet($str, $font) { echo caca_export_string($cv, "html3"); } -$dir = opendir($path = "/usr/share/figlet/"); +$path = "/usr/share/figlet/"; +if (!is_dir($path)) { + die("can not open directory $path.\n"); +} + +$dir = opendir($path); while (($it = readdir($dir)) != false) { if (is_file($path.$it) and ereg("\.[tf]lf$", $it)) { echo "font : $it\n
";
diff --git a/caca-php/examples/www/logo-caca.png b/caca-php/examples/www/logo-caca.png
new file mode 100755
index 0000000000000000000000000000000000000000..859e27ab6e800a90f37f5fabb6adebc9c1415475
GIT binary patch
literal 7526
zcmV-s9hu^ZP)#;
zK~#9!?Ok_VQ|J1BPbMJ~NSGl31Q`OdG@>X{D54g$2(?~qe{HXAuU)piy>0EdZT;L1
zwXLnAt-aOS>*#f$9U@`{Q4j$~2(tHHVTF*8o!=j!;czlYLIUXJ`{9q|<(xO?JkNQb
z_t^(htJPo*GY8Zh3Fa6u$ACG^F<_1XbC_em90ML~^!4@i_4Um$UKP0Gr_NfB(BFbimyvt_ki~Hc2f?M$z*HRtl7GC>oi~911^Gc
zb90lElf`1OcEpSBx;c846Pa4x-gv33sB;LZ7y0}9-@A7Yi^a|{zzTY2LP7$M$J36W
zA=C>Asoo5C%~!cnkzd2RT6ISxmB3Gojg38d@}#@F`y2zNgw?B8U%GS&J`(80el~6$
z;;=5kz{$ewjzKVy0H&-Xc
zoMV6`=7(})G#dTP%4Bz%6MXRV&p$tV_UxPpG7q|PZJk>ICP5$&95`@b{rdH~)Mq*}
zw#BC!r#=9{nc}dK6AvG0Yis-Bi!bI@z~nf8{`_mNz1GswqWdofnfCY9n{XJD)Jl~~
z_0x^4du>Hk&=S0u0(&AAImZT3VW3>SIvo&C#n&q&@%ug+e{KG>J+e!Uqcr
z3+F_TekaP8Uw*lC>C&A$cdAq>-2*%v7+Y5+v*<2nO^ZgOUrN{jA8BlCwB21`?nlzM
zw6qiz6@Bu_CuL=2y8oT;>dBcG#By|XB2z7!pGKn4?8!r7q2}wIJ9p+7Fh+=@M~|L4
zbH<1(fAg|ck!=4d{ty~Mc{nh%3=j&1YPA}Ip#M1r)YjJWcsz+j^84?<=jG+``FtY>
zvz=U1B4V^|1}oyql`9H`!baYqS;T<+{QU0j?v|F8l9CbtKv`Ltu0p97vHszqta;WY
zy^phdMaQ`4K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