def generate_image_circle(self, field, title, condDict=None): res = self._db.query_group_count(field, condDict) labels = [] weights = [] for r in res: labels.append(r[0]) weights.append(r[1]) draw.draw_circle(labels, weights, title)
def draw_reachable_stops_from_name(name, rad): reachable_stops = get_reachable_stops_from_name(name, rad) lat_rad, lon_rad = None, None for stop in reachable_stops: if not (lat_rad and lon_rad): # Work out radius in latitudinal/longitudinal degrees for this # general area lat_rad, lon_rad = calculate_lat_lon_rads(stop, rad) lat, lon = convert.OSGB36toWGS84(stop.x, stop.y) draw_circle(stop.name, lat, lon, lat_rad, lon_rad) save_kml()
def detect_rectangles(binary, original): steps = [] height, width = binary.shape timings.start('detect_lines') (horizontal, vertical) = detect_lines_rust(cv2.bitwise_not(binary), min_line_length) timings.end('detect_lines') (vertical_lines, horizontal_lines) = reduce_lines(horizontal, vertical, min_distance) # TODO: Only remove them if they are touching the border (in the step before or something) (horizontal_lines, vertical_lines) = remove_lines_close_to_border(horizontal_lines, vertical_lines, width, height, 0.1 * min_distance) # debug raw_lines = np.copy(original) draw_lines(raw_lines, horizontal, color=(0, 255, 0)) draw_lines(raw_lines, vertical, color=(240, 150, 100)) steps.append(('raw-lines', raw_lines)) before_connect = np.copy(original) draw_lines(before_connect, vertical_lines + horizontal_lines) steps.append(('before-connect', before_connect)) # add helper lines for borders horizontal_lines += [(0, 0, width, 0), (0, height, width, height)] vertical_lines += [(width, height, width, 0), (0, height, 0, 0)] (horizontal, vertical) = connect_lines(horizontal_lines, vertical_lines) top_left, bottom_left, bottom_right, top_right = find_corners( horizontal, vertical) # add given image corners top_left.append((0, 0)) bottom_left.append((0, height)) bottom_right.append((width, height)) top_right.append((width, 0)) (rectangles, errors) = find_rectangles(top_left, bottom_left, top_right) with_lines = np.copy(original) for error in errors: draw_circle(with_lines, error) draw_corners(with_lines, top_left, (0, 90)) draw_corners(with_lines, top_right, (90, 180)) draw_corners(with_lines, bottom_right, (180, 270)) draw_corners(with_lines, bottom_left, (270, 360)) draw_lines(with_lines, horizontal + vertical) steps.append(('lines', with_lines)) rects_with_color = find_colors_for_rects(rectangles, original) return (rects_with_color, steps)
def generate_tree(self): _limbs = [] for x in xrange(-6,7): _y = [] for y in xrange(-6,7): _y.append(0) _limbs.append(_y) _limbs[0][0]=1 for pos in draw.draw_circle((0,0),random.choice([5,7,9,11,13])): _limbs[pos[0]][pos[1]]=1 return _limbs
def tick_lights(self): for _l in self.lights: light = self.lmap[_l[0]][_l[1]] if self.lmap[_l[0]][_l[1]]['life']<=0: self.lmap[_l[0]][_l[1]]['source'] = False self.lmap[_l[0]][_l[1]]['color'] = (0,0,0) self.lmap[_l[0]][_l[1]]['brightness'] = 0 self.lights.remove(_l) continue self.lmap[_l[0]][_l[1]]['life']-=1 if light['source']: light['children'] = [] for _pos in draw.draw_circle(_l,light['brightness']): if not (_pos) in light['children']: light['children'].append(_pos)
def draw(self, screen): for segment in self.segments(): segment.draw(screen) draw_circle(screen, self.color, self.pivot, self.r1) draw_circle(screen, self.color, self.extreme(), self.r2)
def animate(i): x1 = x1_list[i] x2 = x2_list[i] draw.draw_rectangle(wx[0], wx[1], wy[0], wy[1]) draw.draw_circle(x1[0], x1[1], r1, c1, 0.7) draw.draw_circle(x2[0], x2[1], r2, c2, 0.7)
def draw(self, screen): draw_circle(screen, (255, 255, 255), self.center, self.radius)
def draw(self): draw.draw_circle((int(self.x),int(self.y)), self.shape['rad'], 250, 100, 100) draw.draw_circle((int(self.x),int(self.y)), self.shape['rad'] * (1000-self.cooldown)/1000, 100, 250, 100)
def draw(self): draw.draw_circle((int(self.x),int(self.y)), self.shape['rad'], 50, 150, 255) draw.draw_circle((int(self.x),int(self.y)), int(self.shape['rad']*self.hp/self.max_hp), 255, 100, 200)