def get_tree_vx(max_width, min_width, itter_width, itter_height, points=[], start_iter_height=None, tree_pointyness=1.9): """recursive tree builder""" if start_iter_height is None: start_iter_height = itter_height # reset list, at begining of every non-recursive function function call points = [] if max_width > min_width: itter_height += start_iter_height * 2 ratio = itter_height / float(itter_width) ratio /= ratio / tree_pointyness height_chunk = get_tree_square(max_width, start_iter_height, ratio) translate((0, -itter_height), height_chunk) points.append(height_chunk) next_width = max_width - itter_width return get_tree_vx(next_width, min_width, itter_width, itter_height, points, start_iter_height) else: bottom = get_square(max_width + itter_width, start_iter_height) translate((0, -start_iter_height), bottom) points.append(bottom) return points
def get_blades(blade_width, blade_length, dist_traveld): """for getting bladez""" dist_traveld /= 12.5 top_blade = [(i*sin(dist_traveld), i*cos(dist_traveld)) for i in range(-blade_length, blade_length)] bottom_blade = [x for x in reversed(top_blade)] translate((0, blade_width), bottom_blade) return top_blade+bottom_blade
def get_blades(blade_width, blade_length, dist_traveld): """for getting bladez""" dist_traveld /= 12.5 top_blade = [(i * sin(dist_traveld), i * cos(dist_traveld)) for i in range(-blade_length, blade_length)] bottom_blade = [x for x in reversed(top_blade)] translate((0, blade_width), bottom_blade) return top_blade + bottom_blade
def get_parrot(blade_length=50, blade_width=10, pin_height=10, pin_width=5, house_width=35, house_height=40, dist_traveld=0): """gets geometry vertex for parrot helicopeter""" blade = get_blades(blade_width, blade_length, dist_traveld) pin = get_square(pin_width, pin_height) translate((0, blade_width + pin_height), pin) house = get_circle(house_width, 100) translate((0, blade_width + pin_height + house_height), house) return [blade, pin, house]
def get_tree_vx(max_width, min_width, itter_width, itter_height, points=[], start_iter_height=None, tree_pointyness=1.9): """recursive tree builder""" if start_iter_height is None: start_iter_height = itter_height # reset list, at begining of every non-recursive function function call points = [] if max_width > min_width: itter_height += start_iter_height*2 ratio = itter_height / float(itter_width) ratio /= ratio/tree_pointyness height_chunk = get_tree_square(max_width, start_iter_height, ratio) translate((0, -itter_height), height_chunk) points.append(height_chunk) next_width = max_width - itter_width return get_tree_vx(next_width, min_width, itter_width, itter_height, points, start_iter_height) else: bottom = get_square(max_width+itter_width, start_iter_height) translate((0, -start_iter_height), bottom) points.append(bottom) return points
def loc_set_pos(self, new_pos): """sets position of object""" total = (-self.position[0]+new_pos[0], -self.position[1]+new_pos[1]) for point_batch in self.points: translate(total, point_batch) self.position = new_pos
def loc_translate(self, velocity, discreet=False): """local self.points translate""" if discreet is False: self.position = vector_add(self.position, velocity) for point_batch in self.points: translate(velocity, point_batch)
def test_translate(self): assert utils.translate("kurczak") == "chicken" with pytest.raises(textblob.exceptions.NotTranslated): utils.translate("kurczak", "en")