[ Index ]

PHP Cross Reference of Moodle 310

title

Body

[close]

/question/type/ddmarker/amd/src/ -> shapes.js (summary)

Library of classes for handling simple shapes. These classes can represent shapes, let you alter them, can go to and from a string representation, and can give you an SVG representation.

Copyright: 2018 The Open University
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 845 lines (27 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 8 functions

  Point()
  Shape()
  Circle()
  Rectangle()
  Polygon()
  NullShape()
  createSvgElement()
  createSvgShapeGroup()

Functions
Functions that are not part of a class:

Point(x, y)   X-Ref
A point, with x and y coordinates.

param: {int} x centre X.
param: {int} y centre Y.

Shape(label, x, y)   X-Ref
Shape constructor. Abstract class to represent the different types of drop zone shapes.

param: {String} [label] name of this area.
param: {int} [x] centre X.
param: {int} [y] centre Y.

Circle(label, x, y, radius)   X-Ref
A shape that is a circle.

param: {String} label name of this area.
param: {int} [x] centre X.
param: {int} [y] centre Y.
param: {int} [radius] radius.

Rectangle(label, x, y, width, height)   X-Ref
A shape that is a rectangle.

param: {String} label name of this area.
param: {int} [x] top left X.
param: {int} [y] top left Y.
param: {int} [width] width.
param: {int} [height] height.

Polygon(label, points)   X-Ref
A shape that is a polygon.

param: {String} label name of this area.
param: {Point[]} [points] position of the vertices relative to (centreX, centreY).

NullShape(label)   X-Ref
Not a shape (null object pattern).

param: {String} label name of this area.

createSvgElement(svg, tagName)   X-Ref
Make a new SVG DOM element as a child of svg.

param: {SVGElement} svg the parent node.
param: {String} tagName the tag name.
return: {SVGElement} the newly created node.

createSvgShapeGroup(svg, tagName)   X-Ref
Make a group SVG DOM elements containing a shape of the given type as first child,
and a text label as the second child.

param: {SVGElement} svg the parent node.
param: {String} tagName the tag name.
return: {SVGElement} the newly created g element.



Generated: Wed Jan 22 11:59:49 2025 Cross-referenced by PHPXref 0.7.1