Moodle APIs  3.8
Moodle 3.8.6 (Build: 20201109)
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
qtype_ddmarker_shape_polygon Class Reference

Class to represent a polygon. More...

Inheritance diagram for qtype_ddmarker_shape_polygon:
qtype_ddmarker_shape

Public Member Functions

 __construct ($coordsstring)
 
 center_point ()
 Returns the center location of the shape. More...
 
 get_coords_interpreter_error ()
 Gets any coordinate error. More...
 
 inside_width_height ($widthheight)
 
 is_point_in_shape ($xy)
 Check if the location is within the shape. More...
 

Static Public Member Functions

static create ($shape, $coordsstring)
 Creates a new shape of the specified type. More...
 
static exists ($shape)
 Checks if the passed shape exists. More...
 
static human_readable_coords_format ()
 
static human_readable_name ($lowercase=false)
 Return a human readable name of the shape. More...
 
static name ()
 Returns the name of the shape. More...
 
static shape_options ()
 

Public Attributes

array $coords
 Arrary of xy coords where xy coords are also in a two element array [x,y].
 

Protected Member Functions

 is_left (qtype_ddmarker_point $start, qtype_ddmarker_point $end, qtype_ddmarker_point $point)
 Tests if a point is left / on / right of an infinite line. More...
 
 is_only_numbers ()
 Test if all passed parameters consist of only numbers. More...
 
 is_point_in_bounding_box ($pointxy, $xleftytop, $xrightybottom)
 Checks if the point is within the bounding box made by top left and bottom right. More...
 
 outlying_coords_to_test ()
 

Protected Attributes

bool $error = false
 Indicates if there is an error.
 
array $maxxy
 max x and y coords in a two element array [x,y].
 
array $minxy
 min x and y coords in a two element array [x,y].
 

Static Protected Attributes

static string $classnameprefix = 'qtype_ddmarker_shape_'
 The shape class prefix.
 

Detailed Description

Class to represent a polygon.

License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

Member Function Documentation

◆ center_point()

qtype_ddmarker_shape_polygon::center_point ( )

Returns the center location of the shape.

Return values
arrayX and Y location

Reimplemented from qtype_ddmarker_shape.

◆ create()

static qtype_ddmarker_shape::create (   $shape,
  $coordsstring 
)
staticinherited

Creates a new shape of the specified type.

Parameters
string$shapeThe shape to create
string$coordsstringThe string describing the coordinates
Return values
object

◆ exists()

static qtype_ddmarker_shape::exists (   $shape)
staticinherited

Checks if the passed shape exists.

Parameters
string$shapeThe shape name
Return values
bool

◆ get_coords_interpreter_error()

qtype_ddmarker_shape::get_coords_interpreter_error ( )
inherited

Gets any coordinate error.

Return values
string|boolString of the error or false if there is no error

◆ human_readable_name()

static qtype_ddmarker_shape::human_readable_name (   $lowercase = false)
staticinherited

Return a human readable name of the shape.

Parameters
bool$lowercaseTrue if it should be lowercase.
Return values
string

◆ is_left()

qtype_ddmarker_shape_polygon::is_left ( qtype_ddmarker_point  $start,
qtype_ddmarker_point  $end,
qtype_ddmarker_point  $point 
)
protected

Tests if a point is left / on / right of an infinite line.

Parameters
qtype_ddmarker_point$startfirst of two points on the infinite line.
qtype_ddmarker_point$endsecond of two points on the infinite line.
qtype_ddmarker_point$pointthe oint to test.
Return values
number> 0 if the point is left of the line. = 0 if the point is on the line. < 0 if the point is right of the line.

◆ is_only_numbers()

qtype_ddmarker_shape::is_only_numbers ( )
protectedinherited

Test if all passed parameters consist of only numbers.

Return values
boolTrue if only numbers

◆ is_point_in_bounding_box()

qtype_ddmarker_shape::is_point_in_bounding_box (   $pointxy,
  $xleftytop,
  $xrightybottom 
)
protectedinherited

Checks if the point is within the bounding box made by top left and bottom right.

Parameters
array$pointxyArray of the point (x, y)
array$xleftytopTop left point of bounding box
array$xrightybottomBottom left point of bounding box
Return values
bool

◆ is_point_in_shape()

qtype_ddmarker_shape_polygon::is_point_in_shape (   $xy)

Check if the location is within the shape.

Parameters
array$xy$xy[0] is x, $xy[1] is y
Return values
booleanis point inside shape

Reimplemented from qtype_ddmarker_shape.

◆ name()

static qtype_ddmarker_shape::name ( )
staticinherited

Returns the name of the shape.

Return values
string

The documentation for this class was generated from the following file: