def convert_relatives_to_absolutes(lst):
    if not isinstance(lst, (list, tuple)):
        raise TypeError("`lst` must be a list or tuple.")

    lst = pens_updown_to_papr(lst)

    result = []
    last_position = Coordinate(0, 0)
    command = None
    for e in lst:
        ## if has absolute position, keep track of last point...
        if is_primitive_absolute(e):
            if isinstance(e.xy, CoordinateArray):
                last_position = e.xy[-1]
            else:
                last_position = e.xy

        ## handle each HPGL command type...
        if isinstance(e, PR):
            command = pr_to_pa(e, last_position)
            last_position = command.xy[-1]
        elif isinstance(e, ER):
            command = EA(last_position + e.xy)
            last_position = command.xy
        elif isinstance(e, RR):
            command = RA(last_position + e.xy)
            last_position = command.xy
        elif isinstance(e, AR):
            command = AA(last_position + e.xy, e.angle, e.chordtolerance)
            last_position = command.xy
        else:
            command = e

        result.append(command)
    return result
def convert_relatives_to_absolutes(lst):
    if not isinstance(lst, (list, tuple)):
        raise TypeError("`lst` must be a list or tuple.")

    lst = pens_updown_to_papr(lst)

    result = []
    last_position = Coordinate(0, 0)
    for e in lst:
        ## if has absolute position, keep track of last point...
        if is_primitive_absolute(e):
            if isinstance(e.xy, CoordinateArray):
                last_position = e.xy[-1]
            else:
                last_position = e.xy

        ## handle each HPGL command type...
        if isinstance(e, PR):
            command = pr_to_pa(e, last_position)
            last_position = command.xy[-1]
        elif isinstance(e, ER):
            command = EA(last_position + e.xy)
            last_position = command.xy
        elif isinstance(e, RR):
            command = RA(last_position + e.xy)
            last_position = command.xy
        elif isinstance(e, AR):
            command = AA(last_position + e.xy, e.angle, e.chordtolerance)
            last_position = command.xy
        else:
            command = e

        result.append(command)
    return result
Beispiel #3
0
def _transpose_command(arg, val):
    from chiplotle.tools.iterabletools.ispair import ispair
    val = Coordinate(*val)
    if is_primitive_absolute(arg):
        arg.xy = arg.xy + val