def run(args): saver = ReproSaver() saver.seed() R = 150 phi = 1.6180339 smaller = R / phi # golden ratio pts = [] pts.extend(circle_connections(1200, R, np.pi, -np.pi)) rays = draw_rays(0, 7 * R * phi, 0, np.pi, 30) rays.extend(draw_rays(2.5 * R, 7 * R * phi, np.pi / 60, np.pi - np.pi / 60, 29)) rays = shift(rays, np.array([1.7 * R, 0])) rays = mask_drawing(rays, circle((0, 0), 1.05 * R, N=50), invert=True) pts.extend(rays) # pts = mask_drawing(pts, circle((0, 0), R, N=50)) # pts.extend(circle_connections(230, R, np.pi * 0.3, 0)) # pts.extend(circle_connections(530, R, np.pi * 0.5, 0)) # pts.extend(circle_connections(650, R, np.pi * 0.65, np.pi * 0.50)) # pts.extend(circle_connections(700, R, np.pi * 0.95, np.pi * 0.72)) # for i in range(1, 18): # smooth_circle = circle_connections(360, R * 1.02**i, np.pi / 180, np.pi / 180) # pts.extend(drop_parts(smooth_circle, space=1, passes=4)) lines = to_vpype(pts) lines.crop(-2.3 * R - smaller, 2.3 * R + smaller, R + smaller, -R - smaller) # left, bottom, right, top pts = from_vpype_lines(lines) if not args.nosave: saver.add_svg(pts) document = vpype.Document(lines) # document.extend_page_size(None) with open('/tmp/signal_planet.svg', 'w') as fout: vpype.write_svg(fout, document) vpype_viewer.show(document) return 0
def __init__(self, points, distance_fn, restricted_to=None): self.dist = distance_fn self.restricted_to = restricted_to if restricted_to is None: # construct bbox from points min_x, min_y = np.amin(points, axis=0) max_x, max_y = np.amax(points, axis=0) self.restricted_to = box(min_x, min_y, max_x, max_y) if points.shape[0] <= 1: self.inside_subtree = None self.outside_subtree = None self.vantage_point = None self.radius = 0 self.leaf = True else: self.leaf = False self.vantage_point = points[np.random.choice(len(points)), :] dists = distance_fn(self.vantage_point, points) self.radius = np.median(dists) inside_data = points[dists < self.radius, :] outside_data = points[dists >= self.radius, :] circle_poly = Polygon(circle(self.vantage_point, self.radius)) self.inside_subtree = VPTree( inside_data, distance_fn, self.restricted_to.intersection(circle_poly)) self.outside_subtree = VPTree( outside_data, distance_fn, self.restricted_to.difference(circle_poly))
def pcb_circle(p): #FIXME! This function does not know what units the gerber uses #It assumes millimeters. new = glif.circle(0, 0, 0, 0, "") new.design_rules.thickness = SCALE * p.diameter new.location = glif.coordinate(p.position[0] * CORD_SCALE, p.position[1] * CORD_SCALE) return new
def run(args): particles = circle((0, 0), 1, N=360) forces = [] x_noise = OpenSimplex(42) y_noise = OpenSimplex(211) np.random.seed(64) dist = lambda x: np.linalg.norm(x) forces.append(lambda x: 0.6*np.array( [x_noise.noise2d(x=x[0], y=x[1]), y_noise.noise2d(x=x[0], y=x[1])])) forces.append(lambda x: 0.05*gravity(x, np.array((2, 2)))) forces.append(lambda x: 0.05*gravity(x, np.array((1.5, 0)))) forces.append(lambda x: 0.05*gravity(x, np.array((1.5, 1.5)))) forces.append(lambda x: -x if dist(x) > 3 else np.array((0.0, 0.0))) to_draw = [] for p in tqdm.tqdm(particles): path = run_particle(p, forces, N_steps=np.random.randint(999, 1000), step_size=1) to_draw.append(path) x_margin_mm = 30 y_margin_mm = 30 H = 210 # A4 W = 297 # A4 to_draw = resize_and_center(to_draw, H, W, x_margin_mm, x_margin_mm, y_margin_mm, y_margin_mm) simplified = [] for p in to_draw: simplified.append(simplify_reumann_witkam(0.5, p)) to_draw = optimize(simplified) vis_drawing(to_draw, 'b-', lw=0.1) plt.axis('equal') plt.gca().invert_yaxis() plt.show() # return 1 with Plotter('/dev/ttyUSB0', 9600) as p: p.load_config('config.json') p.set_input_limits((0, 0), (W, 0), (0, H), (W, H)) p.draw_polylines(to_draw) return 0
def render(self): p = self.body.contents.p draw.circle((p[0]%800-800, p[1]), self.radius ,self.color) draw.circle((p[0]%800, p[1]), self.radius ,self.color) draw.circle((p[0]%800+800, p[1]), self.radius ,self.color)
def render(self, cx, cy): primitives.circle(x=self.x, y=self.y, radius=self.r, color=(1., 1., 1., 1.))
def render(self, cx, cy): primitives.circle(x=self.x - cx, y=self.y - cy, radius=self.r, color=(0., 0., 1., 1.))
def render(self): primitives.circle(self.pos, self.r, color=4 * (.7, ))