Units of Measure

Point Object

class cand.Point(x, y, coordinate='default')[source]

Bases: object

A point on the canvas in an arbitrary coordinate system.

A point represents a specific location on the canvas. It represents an x and y coordinate in a specific coordinate system, given by x, y, and coordinate, respectively. Coordinate systems are specified as strings, and are interpreted according to a Canvas object.

Points and vectors can be added or subtracted to produce another point. Points cannot be multiplied or divided by scalars. Points cannot be added to each other, but they can be subtracted to produce the vector connecting the two points.

__add__(other)[source]

Add together a point and a vector.

other should be a Vector, otherwise this function will throw an error.

Returns a Point

__eq__(other)[source]

Determine if two Point objects are equal.

other should be another Point object.

Returns True or False.

__lshift__(other)[source]

Take the y coordinate of this point and the x coordinate of another point.

other should be a Point, otherwise this function will throw an error.

Returns a Point.

__or__(other)[source]

Return the point in the center of the two given points

other should be a Point, otherwise this function will throw an error.

Returns a Point.

__rshift__(other)[source]

Take the x coordinate of this point and the y coordinate of another point.

other should be a Point, otherwise this function will throw an error.

Returns a Point.

__sub__(other)[source]

Find the vector which connects two points.

other should be a Point, otherwise this function will throw an error.

Returns a Vector.

__weakref__

list of weak references to the object (if defined)

Vector object

class cand.Vector(x, y, coordinate='default')[source]

Bases: object

A vector in an arbitrary coordinate system.

A Vector represents a difference in location on the canvas. It represents a width and a height in a specific coordinate system, given by x, y, and coordinate, respectively. Coordinate systems are specified as strings, and are interpreted according to a Canvas object.

Vectors can be added or subtracted to other vectors or points. They can also be multiplied and divided by scalars.

A Vector which only has an x component is automatically cast to a “Width” object, and with only a y component is a “Height” object.

__add__(other)[source]

Add a vector to a Point or another Vector.

If other is a Point, return a Point. If other is a Vector, return a Vector.

__eq__(other)[source]

Determine if two Vector objects are equal.

other should be another Vector object.

Returns True or False.

__lshift__(other)[source]

Take the y coordinate of this vector and the x coordinate of another vector.

other should be a Vector, otherwise this function will throw an error.

Returns a Vector.

__matmul__(other)[source]

Rotate the vector by some amount, specified in degrees.

other should be a scalar, in units of degrees.

Returns a Vector.

__mul__(other)[source]

Multiply a vector by a scalar.

other should be a scalar by which to multiply each component of the vector.

Return a Vector.

__neg__()[source]

Take the negative of a vector.

This is equivalent to rotating the vector by 180 degrees, or to multiplying each component by -1.

Return a Vector.

__rshift__(other)[source]

Take the x coordinate of this vector and the y coordinate of another vector.

other should be a Vector, otherwise this function will throw an error.

Returns a Vector.

__sub__(other)[source]

Vector subtraction.

other should be a Vector.

Return a Vector.

Subtracting a vector is equivalent to adding the negative of the vector.

__truediv__(other)[source]

Divide a vector by a scalar.

other should be a non-zero scalar by which to divide each component of the vector.

Return a Vector.

__weakref__

list of weak references to the object (if defined)

flipx()[source]

Returns a Vector reflected across the y-axis.

flipy()[source]

Returns a Vector reflected across the x-axis.

height()[source]

Returns a Height object representing the y component of the Vector.

width()[source]

Returns a Width object representing the x component of the Vector.

Height

cand.metrics.Height(y, coordinate='default')[source]

A vector with a 0 in the x coordinate.

Returns a Vector with 0 in the x coordinate and y in the y coordinate, within the coordinate system coordinate.

This is included for backward compatibility.

Width

cand.metrics.Width(x, coordinate='default')[source]

A vector with a 0 in the y coordinate.

Returns a Vector with x in the x coordinate and 0 in the y coordinate, within the coordinate system coordinate.

This is included for backward compatibility.