Example #1
0
def Line(old, new, *args):
    
    blX, blY, trX, trY = args
    
    blX = utils.pixel_to_coord(blX, 'x')
    blY = utils.pixel_to_coord(blY, 'y')
    trX = utils.pixel_to_coord(trX, 'x')
    trY = utils.pixel_to_coord(trY, 'y')
    
    # use list so I can reuse the iterable
    points = list(utils.bresenham_line(blX, blY, trX, trY))
    
    color = utils.scale_100(old.pen_color)
    pixel_list = ((x, y, color) for x, y in points)
    
    new.image = old.image.set_pixels(pixel_list)
    
    current_line_no = new.line_no
    new_ghosts = (old.ghosts
                .add_dimension_line(current_line_no, 1, 'horizontal', blX, blY)  # for blX
                .add_dimension_line(current_line_no, 2, 'vertical', blX, blY) # for blY
                .add_dimension_line(current_line_no, 3, 'horizontal', trX, trY) # for trX
                .add_dimension_line(current_line_no, 4, 'vertical', trX, trY) # for trY
    )
    
    ## traverse up the environments,
    ## adding these points to the ghost pointer
    new_ghosts = new_ghosts.add_points_to_callstack(new.env, 0, points)

    new.ghosts = new_ghosts
Example #2
0
def Line(old, new, *args):

    blX, blY, trX, trY = args

    blX = utils.pixel_to_coord(blX, 'x')
    blY = utils.pixel_to_coord(blY, 'y')
    trX = utils.pixel_to_coord(trX, 'x')
    trY = utils.pixel_to_coord(trY, 'y')

    # use list so I can reuse the iterable
    points = list(utils.bresenham_line(blX, blY, trX, trY))

    color = utils.scale_100(old.pen_color)
    pixel_list = ((x, y, color) for x, y in points)

    new.image = old.image.set_pixels(pixel_list)

    current_line_no = new.line_no
    new_ghosts = (
        old.ghosts.add_dimension_line(current_line_no, 1, 'horizontal', blX,
                                      blY)  # for blX
        .add_dimension_line(current_line_no, 2, 'vertical', blX,
                            blY)  # for blY
        .add_dimension_line(current_line_no, 3, 'horizontal', trX,
                            trY)  # for trX
        .add_dimension_line(current_line_no, 4, 'vertical', trX,
                            trY)  # for trY
    )

    ## traverse up the environments,
    ## adding these points to the ghost pointer
    new_ghosts = new_ghosts.add_points_to_callstack(new.env, 0, points)

    new.ghosts = new_ghosts
Example #3
0
    def set(old, new, lval, rval):
        """
        sets lval to rval
        
        lval can be a DBNDot or a DBNVariable
        """
        if isinstance(lval, DBNDot):
            x_coord = utils.pixel_to_coord(lval.x, "x")
            y_coord = utils.pixel_to_coord(lval.y, "y")
            color = utils.scale_100(rval)
            new.image = old.image.set_pixel(x_coord, y_coord, color)

            ##### hinting stuff
            line_no = new.line_no

            new_ghosts = old.ghosts.add_dimension_line(line_no, 1, "horizontal", x_coord, y_coord).add_dimension_line(
                line_no, 2, "vertical", x_coord, y_coord
            )
            new_ghosts = new_ghosts.add_point(line_no, 0, (x_coord, y_coord))
            new_ghosts = new_ghosts.add_point_to_callstack(new.env, 0, (x_coord, y_coord))
            new.ghosts = new_ghosts

        elif isinstance(lval, DBNVariable):
            new.env = old.env.set(lval.name, rval)

        else:
            raise ValueError("Unknown lvalue! %s" % str(lval))
Example #4
0
    def set(old, new, lval, rval):
        """
        sets lval to rval
        
        lval can be a DBNDot or a DBNVariable
        """
        if isinstance(lval, DBNDot):
            x_coord = utils.pixel_to_coord(lval.x, 'x')
            y_coord = utils.pixel_to_coord(lval.y, 'y')
            color = utils.scale_100(rval)
            new.image = old.image.set_pixel(x_coord, y_coord, color)

            ##### hinting stuff
            line_no = new.line_no

            new_ghosts = (old.ghosts.add_dimension_line(
                line_no, 1, 'horizontal', x_coord,
                y_coord).add_dimension_line(line_no, 2, 'vertical', x_coord,
                                            y_coord))
            new_ghosts = new_ghosts.add_point(line_no, 0, (x_coord, y_coord))
            new_ghosts = new_ghosts.add_point_to_callstack(
                new.env, 0, (x_coord, y_coord))
            new.ghosts = new_ghosts

        elif isinstance(lval, DBNVariable):
            new.env = old.env.set(lval.name, rval)

        else:
            raise ValueError("Unknown lvalue! %s" % str(lval))
Example #5
0
def Paper(old, new, value):
    color = utils.scale_100(value)
    new.image = DBNImage(color=color)
Example #6
0
def Paper(old, new, value):
    color = utils.scale_100(value)
    new.image = DBNImage(color=color)