def hexacircle(start_x, start_y): r, g, b = random.choice(palette) canvas.set_fill_color(r, g, b, random.random() * 0.75 + 0.25) canvas.set_stroke_color(1.0, 1.0, 1.0, random.random() * 0.50 + 0.50) canvas.set_line_width(random.random() * 0.75 + 0.25) circle = (start_x - (0.5 * circle_size), start_y - (0.5 * circle_size), circle_size, circle_size) canvas.draw_ellipse(*circle) canvas.fill_ellipse(*circle) # draw lines rstrokedline(start_x, start_y - circle_size, start_x, start_y + circle_size) rstrokedline(start_x - step, start_y, start_x + step, start_y) rstrokedline(start_x - step, start_y - (0.5 * circle_size), start_x + step, start_y + (0.5 * circle_size)) rstrokedline(start_x - step, start_y + (0.5 * circle_size), start_x + step, start_y - (0.5 * circle_size)) rstrokedline(start_x - step, start_y + (1.5 * circle_size), start_x + step, start_y - (1.5 * circle_size)) rstrokedline(start_x - step, start_y - (1.5 * circle_size), start_x + step, start_y + (1.5 * circle_size)) rstrokedline(start_x - step, start_y + (2.5 * circle_size), start_x + step, start_y - (2.5 * circle_size)) rstrokedline(start_x - step, start_y - (2.5 * circle_size), start_x + step, start_y + (2.5 * circle_size)) rstrokedline(start_x - (3.0 * step), start_y + (0.5 * circle_size), start_x + (3.0 * step), start_y - (0.5 * circle_size)) rstrokedline(start_x - (3.0 * step), start_y - (0.5 * circle_size), start_x + (3.0 * step), start_y + (0.5 * circle_size))
def testidea(): j = what() a = time.time() print j.nearestjunction() print j.prev print time.time() - a import canvas canvas.set_size(256, 256) x = [] for n in j.junctions: x.append(j.junctions[n]) mn = [min(x)[0], min(x, key=lambda a: a[1])[1]] mx = [max(x)[0], max(x, key=lambda a: a[1])[1]] ml = (mx[0] - mn[0]) / 256.0 mf = (mx[1] - mn[1]) / 256.0 md = max([ml, mf]) print mn, mx print ml, mf for n in x: canvas.draw_ellipse((n[0] - mn[0]) / md, 256 - (n[1] - mn[1]) / md, 2, 2) canvas.set_stroke_color(255, 0, 0) canvas.draw_ellipse((j.loc[0] - mn[0]) / md, 256 - (j.loc[1] - mn[1]) / md, 2, 2) canvas.set_stroke_color(0, 255, 255) d = j.nearestjunction()[0] x = [] for n in d: x.append(n[4]) for n in x: canvas.draw_ellipse((n[0] - mn[0]) / md, 256 - (n[1] - mn[1]) / md, 2, 2)
canvas.begin_updates() canvas.set_size(width, height) canvas.set_fill_color(*palette['darkest']) canvas.fill_rect(0, 0, width, height) canvas.set_fill_color(*random.choice(palette['palette'])) canvas.set_stroke_color(*palette['lightest']) start_x, start_y = (width / 2.0, height / 2.0) lollipop_points = [] for x in xrange(64): end_x, end_y = (random.random() * (width * 0.8) + (width * 0.1), random.random() * (height * 0.8) + (height * 0.1)) lollipop_points.append((end_x, end_y)) canvas.set_line_width(random.random() * 0.75 + 0.25) canvas.draw_line(start_x, start_y, end_x, end_y) for x in xrange(64): end_x, end_y = lollipop_points[x] size = random.random() * 128.0 + 32.0 canvas.fill_ellipse(end_x - (size / 2.0), end_y - (size / 2.0), size, size) canvas.set_line_width(1.25) canvas.draw_ellipse(end_x - (size / 2.0), end_y - (size / 2.0), size, size) size = random.random() * 128.0 + 32.0 canvas.fill_ellipse(start_x - (size / 2.0), start_y - (size / 2.0), size, size) canvas.set_line_width(1.25) canvas.draw_ellipse(start_x - (size / 2.0), start_y - (size / 2.0), size, size) canvas.end_updates()
canvas.set_size(width, height) canvas.set_fill_color(*palette.darkest) canvas.fill_rect(0, 0, width, height) canvas.set_fill_color(*random.choice(palette.colors)) canvas.set_stroke_color(*palette.lightest) start_x, start_y = (width / 2.0, height / 2.0) lollipop_points = [] for x in xrange(64): end_x, end_y = (random.random() * (width * 0.8) + (width * 0.1), random.random() * (height * 0.8) + (height * 0.1)) lollipop_points.append((end_x, end_y)) canvas.set_line_width(random.random() * 0.75 + 0.25) canvas.draw_line(start_x, start_y, end_x, end_y) size = random.random() * (width * 0.10) canvas.fill_ellipse(start_x - (size / 2.0), start_y - (size / 2.0), size, size) canvas.set_line_width(1.25) canvas.draw_ellipse(start_x - (size / 2.0), start_y - (size / 2.0), size, size) for x in xrange(64): end_x, end_y = lollipop_points[x] size = random.random() * (width * 0.10) canvas.fill_ellipse(end_x - (size / 2.0), end_y - (size / 2.0), size, size) canvas.set_line_width(1.25) canvas.draw_ellipse(end_x - (size / 2.0), end_y - (size / 2.0), size, size) canvas.end_updates()
def circle(x1, y1, c=10): canvas.draw_ellipse(t_c_x(x1) - c / 2, t_c_y(y1) - c / 2, c, c)
def draw_circle(x, y, r): canvas.set_line_width(3) canvas.set_stroke_color(0, 0, 0) canvas.set_fill_color(255,255,255) canvas.fill_ellipse(x - r, y - r, 2 * r, 2 * r) canvas.draw_ellipse(x - r, y - r, 2 * r, 2 * r)