示例#1
0
def test_margin(ClipClass, margin_size, margins, color, expected_result):
    if ClipClass is BitmapClip:
        clip = BitmapClip([["RRR", "RRR"], ["RRR", "RRR"]], fps=1)
    else:
        clip = ColorClip(color=(255, 0, 0), size=(3, 2),
                         duration=2).with_fps(1)

    # if None, set default argument values
    if color is None:
        color = (0, 0, 0)

    if margins is None:
        margins = [0, 0, 0, 0]
    left, right, top, bottom = margins

    new_clip = margin(
        clip,
        margin_size=margin_size,
        left=left,
        right=right,
        top=top,
        bottom=bottom,
        color=color,
    )

    assert new_clip == BitmapClip(expected_result, fps=1)
示例#2
0
def test_margin():
    clip = BitmapClip([["RRR", "RRR"], ["RRB", "RRB"]], fps=1)

    # Make sure that the default values leave clip unchanged
    clip1 = margin(clip)
    assert clip == clip1

    # 1 pixel black margin
    clip2 = margin(clip, margin_size=1)
    target = BitmapClip(
        [["OOOOO", "ORRRO", "ORRRO", "OOOOO"], ["OOOOO", "ORRBO", "ORRBO", "OOOOO"]],
        fps=1,
    )
    assert target == clip2

    # 1 pixel green margin
    clip3 = margin(clip, margin_size=1, color=(0, 255, 0))
    target = BitmapClip(
        [["GGGGG", "GRRRG", "GRRRG", "GGGGG"], ["GGGGG", "GRRBG", "GRRBG", "GGGGG"]],
        fps=1,
    )
    assert target == clip3