<?php error_reporting(E_ALL | E_STRICT); require_once dirname(__FILE__) . '/../anewt.lib.php'; anewt_include('xml/dom'); anewt_include('gpc'); $doc = new AnewtXMLDomDocument(); if (AnewtGPC::get_bool('debug')) { $doc->set_content_type('text/plain'); } $root = $doc->create_element('Toplevel', array('foo' => 'bar', 'bar' => '&baz')); $root->set_attribute('foo', null); // remove attribute $doc->append_child($root); $element1 = $root->append_child($doc->create_element('SomeElement')); $element1->append_child($doc->create_text_node('Some & text.')); $element1->append_child($doc->create_raw_node(' Some <b>previously marked up</b> text.')); $element1->append_child_raw(' Some more text with <b>markup</b>.'); $element1->append_child($doc->create_comment('This is a comment -- containing << strange characters >>.')); $element1->append_child($doc->create_text_node(' Even more text.')); $element2 = $root->append_child($doc->create_element('SomeElement')); $frag = $doc->create_document_fragment(); $frag->append_child($doc->create_text_node('AAA.')); $frag->append_child($doc->create_text_node('BBB.')); $frag->append_child($doc->create_text_node('CCC.')); $element2->append_child($frag); $sub1 = $element2->append_child($doc->create_element('Sub1')); $sub1->append_child($doc->create_element('Sub2')); $sub2 = $sub1->append_child($doc->create_element('Sub2')); $sub3 = $sub2->append_child($doc->create_element('Sub3')); $sub3->append_child($doc->create_text_node('First content in sub 3'));
$ctx1->draw_filled_rectangle_size(3, 3, 4, 3); $ctx1->set('color', $img->color_from_string('#969')); $ctx1->draw_rectangle(3, 3, 6, 7); $ctx1->draw_filled_rectangle_size(15, 2, 2, 2); $ctx1->draw_filled_rectangle_size(15, 2, -1, -1); $col = $img->color_from_string('#36c'); $ctx1->set('color', $col); $ctx1->draw_filled_rectangle(20, 2, 18, 3); assert('$ctx1->color_at(19, 2) == $col'); /* Blow up so we can count the pixels in the result */ $img->resize_relative(10, false); $img->flush_png(); $img->destroy(); } } $test = AnewtGPC::get_string('test'); if (is_null($test)) { /* Show test chooser */ anewt_include('page'); $p = new AnewtPage(); $p->set('title', 'Choose a test'); $p->append(ax_h1('Choose a test')); foreach (get_class_methods('AnewtImageTestCases') as $name) { $url = URL::unparse(Request::relative_url(), array('test' => $name)); $p->append(ax_p(ax_a_href(sprintf('Test: %s', $name), $url))); } $p->flush(); } else { /* Invoke test function */ AnewtImageTestCases::$test(); }