Returns all absolute coordinates for a given list of Chiplotle-HPGL commands.
Example:
>>> t = [PA((1, 2)), PR((1, 1)), ER((1, 1)), CI(100)]
>>> c = hpgltools.get_all_coordinates(t)
>>> print c
[CP(1, 2), CP(2, 3), CP(3, 4)]
Reads a text string and “inflates” it by creating Chiplotle-HPGL class instances of the found HPGL commands.
Example:
chiplotle> sp = inflate_hpgl_string('SP1;')
chiplotle> sp
[SP(1)]
Example:
chiplotle> move = inflate_hpgl_string('IN;SP1;PA10,10;', ['IN'])
chiplotle> move
[SP(1), PA((10, 10))]
Converts a given PR into PA starting at starting_position.
Export Chiplotle-HPGL objects to an image file format via hp2xx.
single Chiplotle-HPGL object.
filename the file name, including path but without extension.
Chiplotle-HPGL objects will be exported. Default is ‘eps’. Valid formats are: jpg, png, tiff and many others. Please see the hp2xx documentation for details.
Note
You must have hp2xx installed before you can export Chiplote-HPGL objects to image files.
Reads a text HPGL file and “inflates” it by creating Chiplotle-HPGL class instances of the found HPGL commands.
Example:
chiplotle> square = import_hpgl_file('examples/square.hpgl')
chiplotle> square
[SP(pen=1), PU(xy=[ 100. 100.]), PD(xy=[ 200. 100.]),
PD(xy=[ 200. 200.]), PD(xy=[ 100. 200.]),
PD(xy=[ 100. 100.]), SP(pen=0)]
Save text HPGL from Chiplotle-HPGL.
Displays Chiplotle-HPGL objects for prevewing.
expr can be an iterable (e.g., list) or a Chiplotle-HPGL object.
converted for viewing. The default is ‘eps’.
Computes Bezier interpolations from given control_points. This uses the generalized formula for bezier curves: http://en.wikipedia.org/wiki/B%C3%A9zier_curve#Generalization
Return factors of positive n in increasing order:
>>> mathtools.factors(84)
[1, 2, 2, 3, 7]
>>> for n in range(10, 20):
... print n, mathtools.factors(n)
...
10 [1, 2, 5]
11 [1, 11]
12 [1, 2, 2, 3]
13 [1, 13]
14 [1, 2, 7]
15 [1, 3, 5]
16 [1, 2, 2, 2, 2]
17 [1, 17]
18 [1, 2, 3, 3]
19 [1, 19]
Cosine interpolate y1 and y2 with mu normalized [0, 1].
Example:
>>> mathtools.interpolate_cosine(0, 1, 0.5)
0.49999999999999994
Exponential interpolate y1 and y2 with mu normalized [0, 1].
Example:
>>> mathtools.interpolate_exponential(0, 1, 0.5, 4)
0.0625
Set exp to the exponent of interpolation.
Linear interpolate y1 and y2 with mu normalized [0, 1].
Example:
>>> mathtools.interpolate_linear(0, 1, 0.5)
0.5
2D rotation.
Returns a Coordinate or a CoordinateArray.
3D rotation.
Coordinate 2D rotation.
Returns a Coordinate.
2D rotation of list of coordinate pairs (CoordinateArray).
Returns a CoordinateArray.
Converts cartesian to polar coordinates. Argument may be two coordinates x, y, a tuple (x, y), or a Coordinate(x, y).
Returns an (r, a) tuple, where r is the magnitude, a is the angle in radians.