function test_existing($paths, $are_dirs) { foreach ($paths as $path) { if ($are_dirs) { $res = @mkdir($path); if ($res == true) { test_path($path); rmdir($path); } } else { $h = @fopen($path, "w"); if ($h !== false) { fclose($h); test_path($path); unlink($path); } } } }
function testConfig($name = '') { $filename = test_path(CONFIG); if (test_isFile(CONFIG) == false) { $config = array(CONFIG_Client_Key => array(CONFIG_name => "My Web Helpdesk", CONFIG_base => "https://localhost/helpdesk/WebObjects/Helpdesk.woa", CONFIG_user => "client", CONFIG_password => "password"), CONFIG_Tech_Key => array(CONFIG_name => "My Web Helpdesk", CONFIG_base => "https://localhost/helpdesk/WebObjects/Helpdesk.woa", CONFIG_user => "technician", CONFIG_password => "password", CONFIG_apikey => "apikey")); $returnValue = file_put_contents($filename, json_encode($config, JSON_PRETTY_PRINT)); if (json_last_error() != 0) { throw new \Exception(jsonErrorString(json_last_error())); } echo "Created new configuration at {$filename}, please update with your parameters" . PHP_EOL . PHP_EOL; exit(1); } $config = json_decode(file_get_contents($filename), true); if (json_last_error() != 0) { throw new \Exception(jsonErrorString(json_last_error())); } if (is_array($config) && isset($config[$name])) { return $config[$name]; } return null; }
$draw->translate(200, 100); $draw->ellipse(0, 0, 100, 80, 0, 360); $draw->skewX(-30); $draw->translate(200, 100); $draw->circle(0, 0, 50, 50); $canvas->drawImage($draw); } $canvas = new Imagick(); $canvas->newImage(640, 480, 'white'); draw_pie($canvas, 200, 200, 100, 0, 45, 'red'); draw_pie($canvas, 200, 200, 100, 45, 125, 'green'); draw_pie($canvas, 200, 200, 100, 125, 225, 'blue'); draw_pie($canvas, 200, 200, 100, 225, 300, 'cyan'); draw_pie($canvas, 200, 200, 100, 300, 360, 'orange'); test_shape($canvas); test_path($canvas); test_composite($canvas); test_annotation($canvas); // $actual_file = __DIR__.'/draw_example.out.png'; $expected_file = __DIR__ . '/draw_example.png'; // $canvas->writeImage($actual_file); $bg = new ImagickPixel('white'); $actual_iterator = new ImagickPixelIterator($canvas); $expected_iterator = new ImagickPixelIterator(new Imagick($expected_file)); list($total, $same, $similar, $diff) = array(0, 0, 0, 0); $actual_iterator->rewind(); $expected_iterator->rewind(); while ($actual_iterator->valid() && $expected_iterator->valid()) { if ($expected_iterator->key() !== $expected_iterator->key()) { var_dump(array('actual' => $expected_iterator->key(), 'expected' => $expected_iterator->key())); }