Browse Source

* Add web sample program: dithering.php

tags/v0.99.beta17
Nicolas Vion nico 16 years ago
parent
commit
bff86e8b8f
3 changed files with 49 additions and 2 deletions
  1. +42
    -0
      caca-php/examples/www/dithering.php
  2. +7
    -2
      caca-php/examples/www/figlet.php
  3. BIN
      caca-php/examples/www/logo-caca.png

+ 42
- 0
caca-php/examples/www/dithering.php View File

@@ -0,0 +1,42 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>Caca power!</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<style type="text/css">
</style>
</head>
<body>
<?php
/*
* dithering.php sample program for libcaca php binding
* Copyright (c) 2008 Nicolas Vion <nico@yojik.eu>
*
* 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 "<img src='./$src' alt=''/>";

?>
</body>
</html>


+ 7
- 2
caca-php/examples/www/figlet.php View File

@@ -8,7 +8,7 @@
<body>
<?php
/*
* figfont.php sample program for libcaca php binding
* figlet.php sample program for libcaca php binding
* Copyright (c) 2008 Nicolas Vion <nico@yojik.eu>
*
* 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 "<b>font : $it</b>\n<pre>";


BIN
caca-php/examples/www/logo-caca.png View File

Before After
Width: 128  |  Height: 128  |  Size: 7.3 KiB

Loading…
Cancel
Save