/** Test drawing functions */ static function draw_lines_and_shapes() { $img = new AnewtImage(40, 40); $img->fill($img->color_from_rgb(83, 17, 43)); $ctx1 = $img->create_drawing_context(); $ctx2 = $img->create_drawing_context(); /* First context */ $ctx1->set('color', $img->color_from_string('#ff0')); $ctx1->draw_line(18, 18, 21, 18); $ctx1->set('color', $img->color_from_rgb(203, 143, 107)); $ctx1->draw_string(0, 26, 'Anewt'); /* Other context */ $ctx2->set('color', $img->color_from_string('#933')); $ctx2->set('line-width', 5); $ctx2->draw_line(23, 23, 27, 27); $ctx2->draw_point(2, 20); $ctx2->draw_point(2, 22); $ctx2->draw_point(2, 24); /* Back to first context */ $ctx1->draw_line(13, 13, 8, 17); $ctx1->draw_filled_rectangle_size(2, 2, 6, 6); $ctx1->set('color', $img->color_from_string('#3c3')); $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(); }