Ejemplo n.º 1
0
def test_circle_line_overlap():
    # Draw a circle that is above one line but below the other line.
    p = Pen()

    p.stroke_mode(1.0, color=(1.0, 0.0, 0.0))
    p.move_to((0, 0))
    p.turn_to(0)
    p.line_forward(4)

    p.fill_mode(color=(0.0, 1.0, 0.0))
    p.move_to((2, 2))
    p.circle(2)

    p.stroke_mode(1.0, color=(0.0, 0.0, 1.0))
    p.move_to((0, 4))
    p.turn_to(0)
    p.line_forward(4)

    assert_equal(
        p.paper.svg_elements(1),
        [
            (
                '<path d="M0.0,-0.5 L0.0,0.5 L4.0,0.5 L4.0,-0.5 L0.0,-0.5 z" '
                'fill="#ff0000" />'
            ),
            (
                '<path d="M4.0,-2.0 A 2.0,2.0 0 0 0 0.0,-2.0 '
                'A 2.0,2.0 0 0 0 4.0,-2.0 z" fill="#00ff00" />'
            ),
            (
                '<path d="M0.0,-4.5 L0.0,-3.5 L4.0,-3.5 L4.0,-4.5 L0.0,-4.5 z" '
                'fill="#0000ff" />'
            ),
        ]
    )
Ejemplo n.º 2
0
def test_circle_line_overlap():
    # Draw a circle that is above one line but below the other line.
    p = Pen()

    p.stroke_mode(1.0, color=(1.0, 0.0, 0.0))
    p.move_to((0, 0))
    p.turn_to(0)
    p.line_forward(4)

    p.fill_mode(color=(0.0, 1.0, 0.0))
    p.move_to((2, 2))
    p.circle(2)

    p.stroke_mode(1.0, color=(0.0, 0.0, 1.0))
    p.move_to((0, 4))
    p.turn_to(0)
    p.line_forward(4)

    assert_equal(
        p.paper.svg_elements(1),
        [
            (
                '<path d="M0.0,-0.5 L0.0,0.5 L4.0,0.5 L4.0,-0.5 L0.0,-0.5 z" '
                'fill="#ff0000" />'
            ),
            (
                '<path d="M4.0,-2.0 A 2.0,2.0 0 0 0 0.0,-2.0 '
                'A 2.0,2.0 0 0 0 4.0,-2.0 z" fill="#00ff00" />'
            ),
            (
                '<path d="M0.0,-4.5 L0.0,-3.5 L4.0,-3.5 L4.0,-4.5 L0.0,-4.5 z" '
                'fill="#0000ff" />'
            ),
        ]
    )
Ejemplo n.º 3
0
def test_circle_degenerate():
    p = Pen()
    p.stroke_mode(2.0)
    p.circle(1)
    assert_equal(
        p.paper.svg_elements(0),
        ['<path d="M2,0 A 2,2 0 0 0 -2,0 A 2,2 0 0 0 2,0 z" fill="#000000" />']
    )
Ejemplo n.º 4
0
def test_circle_degenerate():
    p = Pen()
    p.stroke_mode(2.0)
    p.circle(1)
    assert_equal(
        p.paper.svg_elements(0),
        ['<path d="M2,0 A 2,2 0 0 0 -2,0 A 2,2 0 0 0 2,0 z" fill="#000000" />']
    )
Ejemplo n.º 5
0
def test_circle():
    p = Pen()
    p.fill_mode()
    p.circle(1)

    assert_equal(
        p.paper.svg_elements(0),
        ['<path d="M1,0 A 1,1 0 0 0 -1,0 A 1,1 0 0 0 1,0 z" fill="#000000" />']
    )
Ejemplo n.º 6
0
def test_circle():
    p = Pen()
    p.fill_mode()
    p.circle(1)

    assert_equal(
        p.paper.svg_elements(0),
        ['<path d="M1,0 A 1,1 0 0 0 -1,0 A 1,1 0 0 0 1,0 z" fill="#000000" />']
    )
Ejemplo n.º 7
0
def test_circle_color():
    p = Pen()
    p.move_to((0, 0))

    p.turn_to(0)
    p.fill_mode((1.0, 0.0, 0.0))
    p.circle(1)
    p.move_forward(2)
    p.fill_mode((0.0, 1.0, 0.0))
    p.circle(1)
    p.move_forward(2)
    p.fill_mode((0.0, 0.0, 1.0))
    p.circle(1)

    assert_equal(
        p.paper.svg_elements(0),
        [
            '<path d="M1,0 A 1,1 0 0 0 -1,0 A 1,1 0 0 0 1,0 z" fill="#ff0000" />',
            '<path d="M3,0 A 1,1 0 0 0 1,0 A 1,1 0 0 0 3,0 z" fill="#00ff00" />',
            '<path d="M5,0 A 1,1 0 0 0 3,0 A 1,1 0 0 0 5,0 z" fill="#0000ff" />',
        ]
    )
Ejemplo n.º 8
0
def test_circle_color():
    p = Pen()
    p.move_to((0, 0))

    p.turn_to(0)
    p.fill_mode((1.0, 0.0, 0.0))
    p.circle(1)
    p.move_forward(2)
    p.fill_mode((0.0, 1.0, 0.0))
    p.circle(1)
    p.move_forward(2)
    p.fill_mode((0.0, 0.0, 1.0))
    p.circle(1)

    assert_equal(
        p.paper.svg_elements(0),
        [
            '<path d="M1,0 A 1,1 0 0 0 -1,0 A 1,1 0 0 0 1,0 z" fill="#ff0000" />',
            '<path d="M3,0 A 1,1 0 0 0 1,0 A 1,1 0 0 0 3,0 z" fill="#00ff00" />',
            '<path d="M5,0 A 1,1 0 0 0 3,0 A 1,1 0 0 0 5,0 z" fill="#0000ff" />',
        ]
    )