def symmetric_polygon_side_length(count, length): """Creates a symmetric polygon with `count` sides, all with the same given `length`. """ result = circle(1.0, count) scale(result, length / result.points.difference[0].magnitude) return result
def ellipse(width, height, segments=36): ''' Constructs an ellipse with the given width, height, and number of segments. ''' r = circle(1, segments) scale(r, (width / 2.0, height / 2.0)) return r
def symmetric_polygon_side_length(count, length): '''Creates a symmetric polygon with `count` sides, all with the same given `length`. ''' result = circle(1.0, count) scale(result, length / result.points.difference[0].magnitude) return result
def _annotate_center(self): coord = self.shape.center label = Label("\n\rcenter: " + str(coord), self.charwidth, self.charheight, origin="top-center") c = circle(20) cr = cross(50, 50) mark = Group([c, cr, label]) offset(label, coord) offset(c, coord) offset(cr, coord) return mark
def _annotate_center(self): coord = self.shape.center label = Label('\n\rcenter: ' + str(coord), self.charwidth, self.charheight, origin = 'top-center') c = circle(20) cr = cross(50, 50) mark = Group([c, cr, label]) offset(label, coord) offset(c, coord) offset(cr, coord) return mark
def target(outer_radius, inner_radius, circles_count, segments=36): """ Creates `circles_count` concentric circles. Can be used to create radially filled circles. """ if not outer_radius > inner_radius: raise ValueError("outer_radius must be > inner_radius.") if not circles_count > 1: raise ValueError("circles_count must be >= 2.") result = [] radius_delta = (outer_radius - inner_radius) / float(circles_count) for i in range(circles_count): result.append(circle(inner_radius + radius_delta * i, segments)) return Group(result)
def target(outer_radius, inner_radius, circles_count, segments=36): ''' Creates `circles_count` concentric circles. Can be used to create radially filled circles. ''' if not outer_radius > inner_radius: raise ValueError('outer_radius must be > inner_radius.') if not circles_count > 1: raise ValueError('circles_count must be >= 2.') result = [ ] radius_delta = (outer_radius - inner_radius) / float(circles_count) for i in range(circles_count): result.append(circle(inner_radius + radius_delta * i, segments)) return Group(result)
''' def noisify(coords, value): try: x, y = value except TypeError: x = y = value result = [ ] for point in coords: x_wiggle = random.randrange(-x, x) y_wiggle = random.randrange(-y, y) xy = point + Coordinate(x_wiggle, y_wiggle) result.append(xy) return CoordinateArray(result) t = TransformVisitor(noisify) t.visit(shape, value) ## RUN DEMO CODE if __name__ == "__main__": from chiplotle.geometry.shapes.circle import circle from chiplotle.tools import io c1 = circle(1000, 100) c2 = circle(800, 100) noise(c1, 90) c1 += Coordinate(1000, 1000) g = Group([c1, c2]) noise(g, 60) io.view(g)