浏览代码

* Add web sample program: dithering.php

tags/v0.99.beta17
Nicolas Vion nico 16 年前
父节点
当前提交
bff86e8b8f
共有 3 个文件被更改,包括 49 次插入2 次删除
  1. +42
    -0
      caca-php/examples/www/dithering.php
  2. +7
    -2
      caca-php/examples/www/figlet.php
  3. 二进制
      caca-php/examples/www/logo-caca.png

+ 42
- 0
caca-php/examples/www/dithering.php 查看文件

@@ -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 查看文件

@@ -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>";


二进制
caca-php/examples/www/logo-caca.png 查看文件

之前 之后
宽度: 128  |  高度: 128  |  大小: 7.3 KiB

正在加载...
取消
保存