コード例 #1
0
 public function test_circle_hit_test()
 {
     $shape = new qtype_ddmarker_shape_circle('10,10;10');
     $this->assertTrue($shape->is_point_in_shape(array(19, 10)));
     $this->assertFalse($shape->is_point_in_shape(array(20, 10)));
     $this->assertTrue($shape->is_point_in_shape(array(10, 1)));
     $this->assertFalse($shape->is_point_in_shape(array(15, 25)));
     $this->assertFalse($shape->is_point_in_shape(array(25, 15)));
     $this->assertTrue($shape->is_point_in_shape(array(11, 11)));
     $this->assertTrue($shape->is_point_in_shape(array(1, 10)));
     $this->assertTrue($shape->is_point_in_shape(array(17, 17)));
     $this->assertTrue($shape->is_point_in_shape(array(3, 3)));
     $this->assertFalse($shape->is_point_in_shape(array(2, 2)));
 }
コード例 #2
0
ファイル: shapes_test.php プロジェクト: evltuma/moodle
 public function test_circle_hit_test()
 {
     $shape = new qtype_ddmarker_shape_circle('10, 10; 10');
     $this->assertTrue($shape->is_point_in_shape(array(19, 10)));
     $this->assertTrue($shape->is_point_in_shape(array(20, 10)));
     $this->assertFalse($shape->is_point_in_shape(array(21, 10)));
     $this->assertTrue($shape->is_point_in_shape(array(10, 1)));
     $this->assertTrue($shape->is_point_in_shape(array(10, 0)));
     $this->assertFalse($shape->is_point_in_shape(array(10, -1)));
     $this->assertFalse($shape->is_point_in_shape(array(15, 25)));
     $this->assertFalse($shape->is_point_in_shape(array(25, 15)));
     $this->assertTrue($shape->is_point_in_shape(array(11, 11)));
     $this->assertTrue($shape->is_point_in_shape(array(1, 10)));
     $this->assertTrue($shape->is_point_in_shape(array(17, 17)));
     $this->assertTrue($shape->is_point_in_shape(array(3, 3)));
     $this->assertFalse($shape->is_point_in_shape(array(2, 2)));
     // Should be exactly on the boundary - 3, 4, 5 right-angled triangle.
     $this->assertTrue($shape->is_point_in_shape(array(16, 18)));
 }