app.py 文件源码

python
阅读 35 收藏 0 点赞 0 评论 0

项目:blackout 作者: lizadaly 项目源码 文件源码
def draw_vertical_lines(draw, boxes, doc_bounding_box, line_width):
    line_weight_factor = random.triangular(0.005, 1.2)
    current_x = doc_bounding_box[0] - line_width / 2
    color = get_color()

    while current_x < doc_bounding_box[2]:
        start_x = current_x
        start_y = doc_bounding_box[1] - line_width / 2
        end_x = start_x
        end_y = doc_bounding_box[3] - line_width / 2

        bx0 = start_x
        bx1 = start_x + line_width

        select_boxes = []
        for box in boxes:
            wx0 = box.position[0][0] - BOUND_PADDING
            wx1 = box.position[1][0] + BOUND_PADDING
            if bx0 < wx0 and wx1 < bx1 or \
               wx0 < bx1 and bx1 < wx1 or \
               wx0 < bx0 and bx0 < wx1:
                select_boxes.append(box)

        if select_boxes:
            y0 = start_y
            y1 = end_y
            for box in select_boxes:
                y1 = box.position[0][1] - BOX_PADDING
                draw_line(draw, [start_x, y0, end_x, y1], line_width=line_width, color=color,
                          line_weight_factor=line_weight_factor, dir='v')
                y0 = box.position[1][1] + BOX_PADDING
            draw_line(draw, [start_x, y0, end_x, end_y], line_width=line_width,  color=color,
                      line_weight_factor=line_weight_factor, dir='v')
        else:
            draw_line(draw, [start_x, start_y, end_x, end_y], line_width=line_width,  color=color,
                      line_weight_factor=line_weight_factor, dir='v')

        current_x = start_x + line_width
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号