Chiplotle Geometry / Shapes

Shapes

chiplotle.geometry.shapes.annotation(shape)

Returns informative shape annotations. Good for debugging and general info displaying.

Annotations:
max (x, y) coordinate min (x, y) coordinate width height center centroid
chiplotle.geometry.shapes.arc_circle(radius, start_angle, end_angle, segments=100, segmentation_mode='2PI')

Constructs an arc from a circle with the given radius, and number of segments. Arc goes from start_angle to end_angle, both of which are in radians.

  • segmentation_mode : ‘2PI’ or ‘arc’. The first segments
    the whole circle into the given number of segments, the second segments the arc.
chiplotle.geometry.shapes.arc_ellipse(width, height, start_angle, end_angle, segments=100, segmentation_mode='2PI')

Constructs an arc from an ellipse with the given width, height, and number of segments. Arc goes from start_angle to end_angle, both of which are in radians.

  • segmentation_mode : ‘2PI’ or ‘arc’. The first segments
    the whole ellipse into the given number of segments, the second segments the arc.
chiplotle.geometry.shapes.arrow(path, headwidth, headheight, filled=False)

Returns an arrow shape.

  • path is a Path object.
  • headwidth is the width of the arrow head.
  • headheight is the height of the arrow head.
chiplotle.geometry.shapes.catmull_path(points, interpolation_count=50)

Path with Catmull-Rom spline interpolation.

chiplotle.geometry.shapes.circle(radius, segments=36)

Returns a circle.

chiplotle.geometry.shapes.cross(width, height)

Draws a cross shape.

  • width is the length of the horizontal line.
  • height is the length of the vertical line..
chiplotle.geometry.shapes.donut(width, height, inset, segments=100)

A donut (ellipse within ellipse) with a width, height, inset, segments.

segments is how many lines should be used to draw ellipse. More segments create a smoother ellipse, but will take longer to draw.

inset is the distance to inset the inner ellipse from the outer.

The donut is drawn with the current pen location as the center. offset may be used to shift this around, for example, to draw from the lower, left corner.

chiplotle.geometry.shapes.ellipse(width, height, segments=36)

Constructs an ellipse with the given width, height, and number of segments.

chiplotle.geometry.shapes.fan(radius, start_angle, end_angle, height, segments=100, filled=False)

A Fan is a slice of a donut seen from above (when you can see the hole in the middle).

All angles are assumed to be in radians.

chiplotle.geometry.shapes.frame(width, height, inset)

A frame (rectangle within a rectangle) with a width, height, and inset.

  • width is the width of the frame.
  • height is the height of the frame.
  • inset is the distance to inset the inner rectangle from the outer.
chiplotle.geometry.shapes.grid(width, height, width_divisions, height_divisions)

Rectangular grid.

  • width : int or float, width of the rectangle.
  • height : int or float, height of the rectangle.
  • width_divisions : int, number of horizontal equidistant partitions.
  • height_divisions : int, number of vertical equidistant partitions.
chiplotle.geometry.shapes.group(lst)
chiplotle.geometry.shapes.isosceles(width, height, filled=False)
chiplotle.geometry.shapes.label(text, charwidth, charheight, charspace=None, linespace=None, origin='bottom-left')
chiplotle.geometry.shapes.layer(shapes, name)
chiplotle.geometry.shapes.line(startpoint, endpoint)

Returns a Path with only two points. The path describes a simple straight line.

chiplotle.geometry.shapes.line_displaced(start_coord, end_coord, displacements)

Returns a Path defined as a line spanning points start_coord and end_coord, displaced by scalars displacements. The number of points in the path is determined by the lenght of displacements.

chiplotle.geometry.shapes.lock_group(shapes, lock_transforms)
chiplotle.geometry.shapes.path(points)

A simple path.

chiplotle.geometry.shapes.path_linear(coords, interpolation_unit)

Returns a path with linearly interpolated segments. Visually the result is the same as a plain path, but this is useful as an intermediate step in constructing more interesting shapes by deforming this one.

  • coords is a CoordinateArray.
  • interpolation_unit is the magnitude of the path segments created.
    Think of it as the sampling period in digital recording. If interpolation_unit > coord[i] - coord[i-1], the coord[i] - coord[i-1] segment is not further segmented.
chiplotle.geometry.shapes.path_interpolated(points, curvature, interpolation_count=50)

Returns a Path with bezier interpolation between the given points. The interpolation is computed so that the resulting path touches the given points.

  • points the key points from which to interpolate.
  • curvature the smoothness of the curve [0, 1].
  • interpolation_count is the number of points to add by interpolation,
    per segment.
chiplotle.geometry.shapes.path_bezier(control_points, weight=1, interpolation_count=50)

Rational Bezier curve.

chiplotle.geometry.shapes.radial_ruler(radius, start_angle, end_angle, units, min_tick_height, symmetric=True)
chiplotle.geometry.shapes.random_walk_cartesian(steps, step_size=500)

Random Walk. Border is a square.

chiplotle.geometry.shapes.random_walk_polar(steps, step_size=500)

Random Walk. Border is a circle

chiplotle.geometry.shapes.rectangle(width, height)
chiplotle.geometry.shapes.ruler(start_coord, end_coord, units, min_tick_height, symmetric=False)

A measuring ruler.

  • units is a list of units on which to put marks, from smaller
    to larger. e.g., (10, 20, 40).
  • min_tick_height is the height of the marks for the smallest units.
    The hight of the other units are multiples of this.
  • symmetric set to True to draw the tick lines symmetrically around
    the invisible center-line.
chiplotle.geometry.shapes.spiral_archimedean(radius, num_turns=5, wrapping_constant=1, direction='cw', segments=500)

Constructs an Archimedean (arithmetic) spiral with the given number of turns using the specified number of points.

wrapping_constant controls how tightly the spiral is wound. Several classic spirals can be created using different wrapping_constants:

lituus: -2 hyperbolic spiral: -1 Archimedes’ spiral: 1 Fermat’s spiral: 2

scaler controls how large the spiral is.

The general Archimedean spiral equation is:

r = a * theta^(1/n)

where r is the radius, a is the scaler, and n is the wrapping_constant.

More info: http://mathworld.wolfram.com/ArchimedeanSpiral.html

chiplotle.geometry.shapes.spiral_logarithmic(num_turns=5, expansion_rate=0.2, direction='cw', segments=500)

Constructs an logarithmic spiral with the given number of turns using the specified number of points.

expansion_rate controls how large the spiral is for a given number of turns. Very small numbers will result in tightly-wound spirals. Large numbers will give spirals with giant “tails”. Typical values range from 0.1 to 0.3

The logarithmic spiral equation is:

r = e^(bt)

where r is the radius, e is e, b is the expansion rate, and t is theta

chiplotle.geometry.shapes.star_crisscross(width, height, num_points=5, jump_size=None, find_valid_jump_size=True)

Draws a star with criscrossing lines.

jump_size determines how many points to skip between connected points. an illegal jump size (one that does not result in a valid crisscross star) is ignored and replaced with a dot in the center of the star.

chiplotle.geometry.shapes.star_outline(width, height, num_points=5)

Constructs a star shape in outline.

chiplotle.geometry.shapes.supershape(width, height, m, n1, n2, n3, point_count=100, percentage=1.0, a=1.0, b=1.0, travel=None)

Supershape, generated using the superformula first proposed by Johan Gielis.

  • points_count is the total number of points to compute.
  • travel is the length of the outline drawn in radians.
    3.1416 * 2 is a complete cycle.
chiplotle.geometry.shapes.symmetric_polygon_side_length(count, length)

Creates a symmetric polygon with count sides, all with the same given length.

chiplotle.geometry.shapes.target(outer_radius, inner_radius, circles_count, segments=36)

Creates circles_count concentric circles. Can be used to create radially filled circles.

Transforms

chiplotle.geometry.transforms.TransformVisitor(transform)

“Crawler” pattern encapsulation for transformations applied to _Shapes. Separates the “what it does” (action) from “how it does it” (traversal).

chiplotle.geometry.transforms.arrange_shapes_on_path(shapes, path)
chiplotle.geometry.transforms.center_at(shape, coord)

Centers shape at the given coordinate.

chiplotle.geometry.transforms.noise(shape, value)

Distort shape by adding noise.

  • value can be a scalar or a tuple (x, y) that sets the range of the
    noise for the x and y coordinates.
chiplotle.geometry.transforms.offset(shape, value)

In place offsetting.

  • shape is the shape to be rotated.
  • value is the offset value. Can be a scalar or an (x, y) coordinate.
chiplotle.geometry.transforms.perpendicular_displace(path, displacements)

Displaces a path along its perpendiculars.

  • path is a Path instance.
  • displacement is a list of displacement values (scalars).
chiplotle.geometry.transforms.perpendicular_noise(shape, value)

Distort shape by adding noise perpendiculary to the path. This is an in-place destructive transformation; no new shapes are created.

  • shape is the shape to be noisified.
  • value must be a scalar defining the range of the noise
    for displacement.
chiplotle.geometry.transforms.rotate(shape, angle, pivot=(0, 0))

In place rotation.

  • shape is the shape to be rotated.
  • angle is the angle (in radians) of rotation.
  • pivot is the center of rotation. Must be a Coordinate or (x, y) pair.
chiplotle.geometry.transforms.scale(shape, value, pivot=Coordinate([0, 0]))

In place scaling.

  • shape is the shape to be rotated.
  • value is the scaling value. Can be a scalar or an (x, y) coordinate.
  • pivot is the Coordinate around which the shape will be scaled.