Example #1
0
def rotate_hpglprimitives(arg, angle):
    for e in arg:
        if not isinstance(e, _HPGLPrimitive):
            raise TypeError("Elements must be of type _HPGLPrimitive")

        ## should we check for CoordinateArray and Coordinate instead?
        if hasattr(e, "xy"):
            pivot = Coordinate(0, 0)
            if isinstance(e.xy, CoordinateArray):
                result = []
                for cp in e.xy:
                    result.append(rotate_coordinate_2d(cp, angle, pivot))
                e.xy = CoordinateArray(result)
            elif isinstance(e.xy, Coordinate):
                e.xy = rotate_coordinate_2d(e.xy, angle, pivot)
def rotate_hpglprimitives(arg, angle):
    for e in arg:
        if not isinstance(e, _HPGLPrimitive):
            raise TypeError('Elements must be of type _HPGLPrimitive')

        ## should we check for CoordinateArray and Coordinate instead?
        if hasattr(e, 'xy'):
            pivot = Coordinate(0, 0)
            if isinstance(e.xy, CoordinateArray):
                result = [ ]
                for cp in e.xy:
                    result.append(rotate_coordinate_2d(cp, angle, pivot))
                e.xy = CoordinateArray(result)
            elif isinstance(e.xy, Coordinate):
                e.xy = rotate_coordinate_2d(e.xy, angle, pivot)
Example #3
0
    def rotate_to_offset(points, angle, pivot):
        def offset(points, value):
            return points + value

        center = points.center
        new_coord = rotate_coordinate_2d(center, angle, pivot)
        diff = new_coord - center
        return offset, [diff]