#!/usr/bin/php5 * * This file is a Php port of "cxx/cxxtest.cpp" * which is: * Copyright (c) 2006 Jean-Yves Lamoureux * All Rights Reserved * * 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://www.wtfpl.net/ for more details. */ if (php_sapi_name() != "cli") { die("You have to run this program with php-cli!\n"); } include dirname($argv[0]) . '/../caca.php'; $pig_str = <<setColorANSI(AnsiColor::LIGHTMAGENTA, AnsiColor::TRANSPARENT); $pig->importString($pig_str, "text"); $display->setDisplayTime(20000); $x = $y = 0; $ix = $iy = 1; while (! $display->getEvent(EventType::KEY_PRESS)) { // In case of resize ... if ($x + $pig->getWidth() - 1 >= $canvas->getWidth() || $x < 0 ) $x = 0; if ($y + $pig->getHeight() - 1 >= $canvas->getHeight() || $y < 0 ) $y = 0; $canvas->Clear(); // Draw $canvas->Blit($x, $y, $pig, NULL); $canvas->setColorANSI(AnsiColor::LIGHTBLUE, AnsiColor::BLACK); $canvas->putStr($canvas->getWidth() / 2 - 10, $canvas->getHeight() / 2, "Powered by libcaca ".Libcaca::getVersion()); $display->refresh(); // Move cursor $x += $ix; $y += $iy; if ($x + $pig->getWidth() >= $canvas->getWidth() || $x < 0 ) $ix = -$ix; if ($y + $pig->getHeight() >= $canvas->getHeight() || $y < 0 ) $iy = -$iy; } ?>