def _annotate_centroid(self): coord = self.shape.centroid label = Label("\n\rcentroid: " + str(coord), self.charwidth, self.charheight, origin="top-center") r = rectangle(20, 20) cr = cross(50, 50) mark = Group([r, cr, label]) offset(label, coord) offset(r, 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 _annotate_centroid(self): coord = self.shape.centroid label = Label('\n\rcentroid: ' + str(coord), self.charwidth, self.charheight, origin = 'top-center') r = rectangle(20, 20) cr = cross(50, 50) mark = Group([r, cr, label]) offset(label, coord) offset(r, 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
return Path(plot_points) ## RUN DEMO CODE if __name__ == "__main__": from chiplotle.tools import io from chiplotle.geometry.shapes.group import group from chiplotle.geometry.shapes.cross import cross from chiplotle.geometry.transforms.offset import offset t_base = 4000 points = [(-t_base / 2, 0), (0, t_base * 0.8660), (t_base / 2, 0)] ## a list containing different sets of weights for the middle point weights = [[1, 1, 1], [1, 2, 1], [1, 0.5, 1], [1, 0, 1], [1, -0.5, 1]] c = group([]) ## draws a cross at each control point for i in points: r = cross(100, 100) offset(r, i) c.append(r) ## draws the rational bezier curve for each weight set for w in weights: b = path_bezier(points, weight=w) c.append(b) io.view(c)
def catmull_path(points, interpolation_count=50): '''Path with Catmull-Rom spline interpolation.''' path_points = catmull_interpolation(points, interpolation_count) return Path(path_points) ## DEMO if __name__ == '__main__': from chiplotle.tools import io from chiplotle.geometry.shapes.cross import cross from chiplotle.geometry.core.group import Group from chiplotle.geometry.transforms.offset import offset import random points = [] for i in range(10): x, y = random.randint(-100, 100), random.randint(-100, 100) points.append((x, y)) crosses = [] for point in points: c = cross(15, 15) offset(c, point) crosses.append(c) path = catmull_path(points) g = Group([path] + crosses) io.view(g)
## RUN DEMO CODE if __name__ == '__main__': from chiplotle.tools import io from chiplotle.geometry.shapes.group import group from chiplotle.geometry.shapes.cross import cross from chiplotle.geometry.transforms.offset import offset t_base = 4000 points = [(-t_base/2,0),(0,t_base*0.8660),(t_base/2,0)] ## a list containing different sets of weights for the middle point weights = [[1,1,1],[1,2,1],[1,0.5,1],[1,0,1],[1,-0.5,1]] c = group([]) ## draws a cross at each control point for i in points: r = cross(100,100) offset(r, i) c.append(r) ## draws the rational bezier curve for each weight set for w in weights: b = path_bezier(points, weight=w) c.append(b) io.view(c)
path_points = catmull_interpolation(points, interpolation_count) return Path(path_points) ## DEMO if __name__ == '__main__': from chiplotle.tools import io from chiplotle.geometry.shapes.cross import cross from chiplotle.geometry.core.group import Group from chiplotle.geometry.transforms.offset import offset import random points = [ ] for i in range(10): x, y = random.randint(-100, 100), random.randint(-100, 100) points.append((x, y)) crosses = [ ] for point in points: c = cross(15, 15) offset(c, point) crosses.append(c) path = catmull_path(points) g = Group([path] + crosses) io.view(g)