def _make_rounded_rectangle(self, start_point, width, height, radius):

        path = Path2D(start_point)
        path.horizontal_to(width)
        path.vertical_to(height, radius=radius)
        path.horizontal_to(-width, radius=radius)
        path.close(radius=radius, close_radius=radius)

        return path
    def _make_quadratic(self, start_point):

        path = Path2D(start_point)
        path.quadratic_to(
            Vector2D(0, 10),
            Vector2D(10, 10),
        )

        return path
    def _make_cubic(self, start_point):

        path = Path2D(start_point)
        path.cubic_to(
            Vector2D(5, 10),
            Vector2D(10, 10),
            Vector2D(15, 0),
        )

        return path
    def _make_absolute_quadratic(self, start_point):

        path = Path2D(start_point)
        path.quadratic_to(
            path.p0 + Vector2D(0, 10),
            path.p0 + Vector2D(10, 10),
            absolute=True,
        )

        return path
    def _make_absolute_cubic(self, start_point):

        path = Path2D(start_point)
        path.cubic_to(
            path.p0 + Vector2D(5, 10),
            path.p0 + Vector2D(10, 10),
            path.p0 + Vector2D(15, 0),
            absolute=True,
        )

        return path
    def _make_closed_path(self, start_point, radius):

        path = Path2D(start_point)
        path.line_to(Vector2D(10, 0))
        path.line_to(Vector2D(0, 10), radius=radius)
        path.line_to(Vector2D(10, 0), radius=radius)
        path.line_to(Vector2D(0, 20), radius=radius)
        path.line_to(Vector2D(-10, 0), radius=radius)
        path.line_to(Vector2D(0, -10), radius=radius)
        path.close(radius=radius, close_radius=radius)

        return path
示例#7
0
    def _make_figure1(self):

        width = 30
        space = 2
        seam_length = width / 4
        long_arm_length = width / 2
        short_arm_length = long_arm_length * .6
        height = 4
        radius = 2

        vertical_seam_position = short_arm_length * 2 / 3
        vertical_seam_length = height * 1.5

        right_side_length = width / 4
        y_right_side = height * 1.5
        right_side_circle_radius = 1

        path1 = Path2D((short_arm_length + space / 2, -height / 2))
        path1.west_to(short_arm_length)
        path1.north_to(height, radius=radius)
        path1.east_to(long_arm_length, radius=radius)

        path2 = path1.x_mirror(clone=True)

        path3 = Path2D((-seam_length / 2, 0))
        path3.east_to(seam_length)

        path4 = Path2D((vertical_seam_position, -vertical_seam_length / 2))
        path4.north_to(vertical_seam_length)

        path5 = path4.x_mirror(clone=True)

        path6 = Path2D((-right_side_length / 2, y_right_side))
        path6.east_to(right_side_length)

        circle = Circle2D((0, y_right_side), right_side_circle_radius)

        return [path1, path2, path3, path4, path5, path6, circle]
示例#8
0
    def to_geometry(cls, commands):

        # cls._logger.info('Path:\n' + str(commands).replace('), ', '),\n '))
        path = None
        for command, args in commands:
            command_lower = command.lower()
            absolute = command_lower != command  # Upper case means absolute
            # if is_lower:
            #     cls._logger.warning('incremental command')
            #     raise NotImplementedError
            if path is None:
                if command_lower != 'm':
                    raise NameError('Path must start with m')
                path = Path2D(args)  # Vector2D()
            else:
                if command_lower == 'l':
                    path.line_to(args, absolute=absolute)
                elif command == 'h':
                    path.horizontal_to(*args, absolute=False)
                elif command == 'H':
                    path.absolute_horizontal_to(*args)
                elif command_lower == 'v':
                    path.vertical_to(*args, absolute=absolute)
                elif command == 'V':
                    path.absolute_vertical_to(*args)
                elif command_lower == 'c':
                    path.cubic_to(*cls.as_vector(args), absolute=absolute)
                elif command_lower == 's':
                    path.stringed_quadratic_to(*cls.as_vector(args),
                                               absolute=absolute)
                elif command_lower == 'q':
                    path.quadratic_to(*cls.as_vector(args), absolute=absolute)
                elif command_lower == 't':
                    path.stringed_cubic_to(*cls.as_vector(args),
                                           absolute=absolute)
                elif command_lower == 'a':
                    radius_x, radius_y, angle, large_arc, sweep, x, y = args
                    point = Vector2D(x, y)
                    path.arc_to(point,
                                radius_x,
                                radius_y,
                                angle,
                                bool(large_arc),
                                bool(sweep),
                                absolute=absolute)
                elif command_lower == 'z':
                    path.close()

        return path
    def _make_directional_path(self, start_point):

        path = Path2D(start_point)
        path.horizontal_to(10)
        path.vertical_to(10)
        path.north_east_to(10)
        path.north_west_to(10)
        path.south_west_to(10)
        path.south_east_to(5)
        path.south_to(5)
        path.west_to(10)
        path.north_to(5)
        path.east_to(5)

        return path
    def _make_absolute_ccw_path(self, start_point, radius):

        path = Path2D(start_point)
        for i, vector in enumerate((
            (10, 0),
            (15, 10),
            (5, 15),
            (-5, 10),
        )):
            path.line_to(path.p0 + Vector2D(vector),
                         absolute=True,
                         radius=(radius if i else None))
        path.close(radius=radius, close_radius=radius)

        return path
示例#11
0
    def geometry(self):

        # Fixme: width is str
        width = float(self.width)
        height = float(self.height)

        # Fixme: which one ???
        radius_x = self.rx
        radius_y = self.ry
        if radius_y == 0:
            radius = None
        else:
            radius = radius_y

        point = Vector2D(self.x, self.y)
        path = Path2D(point)
        path.horizontal_to(width)
        path.vertical_to(height, radius=radius)
        path.horizontal_to(-width, radius=radius)
        path.close(radius=radius, close_radius=radius)

        return path
示例#12
0
 def get_geometry(self):
     position = self.casted_position
     return Path2D(position)  # Fixme: !!!