Exemplo n.º 1
0
def test_x_cross_point():
    p = pnt()
    result = point.virtual_entities(p, pdmode=3)
    line1, line2 = result
    assert line1.dxf.start == (-1, -1)
    assert line1.dxf.end == (+1, +1)
    assert line2.dxf.start == (-1, +1)
    assert line2.dxf.end == (+1, -1)
Exemplo n.º 2
0
def test_dimensionless_point():
    loc = (2, 3)
    p = pnt(location=loc)
    result = point.virtual_entities(p, pdmode=0)
    line = result[0]
    assert line.dxftype() == "LINE"
    assert line.dxf.start.isclose(loc)
    assert line.dxf.end.isclose(loc)
Exemplo n.º 3
0
def test_rotated_cross_point():
    expected = Shape2d([(-1, 0), (1, 0), (0, -1), (0, 1)])
    expected.rotate(-30)  # count-clockwise rotation
    s1, e1, s2, e2 = expected.vertices

    p = pnt(angle=30)  # clockwise angle!!
    result = point.virtual_entities(p, pdmode=2)
    line1, line2 = result
    assert line1.dxf.start.isclose(s1)
    assert line1.dxf.end.isclose(e1)
    assert line2.dxf.start.isclose(s2)
    assert line2.dxf.end.isclose(e2)
Exemplo n.º 4
0
def test_square_point():
    p = pnt()
    result = point.virtual_entities(p, pdmode=65)
    line1, line2, line3, line4 = result
    lower_left = (-0.5, -0.5)
    assert line1.dxf.start == lower_left
    lower_right = (0.5, -0.5)
    assert line1.dxf.end == lower_right
    assert line2.dxf.start == lower_right
    upper_right = (0.5, 0.5)
    assert line2.dxf.end == upper_right
    assert line3.dxf.start == upper_right
    upper_left = (-0.5, 0.5)
    assert line3.dxf.end == upper_left
    assert line4.dxf.start == upper_left
    assert line4.dxf.end == lower_left
Exemplo n.º 5
0
    def virtual_entities(self,
                         pdsize: float = 1,
                         pdmode: int = 0) -> List['DXFGraphic']:
        """ Yields point graphic as DXF primitives LINE and CIRCLE entities.
        The dimensionless point is rendered as zero-length line!

        Check for this condition::

            e.dxftype() == 'LINE' and e.dxf.start.isclose(e.dxf.end)

        if the rendering engine can't handle zero-length lines.

        Args:
            pdsize: point size in drawing units
            pdmode: point styling mode

        .. versionadded:: 0.15

        """
        return point.virtual_entities(self, pdsize, pdmode)
Exemplo n.º 6
0
    def virtual_entities(self,
                         pdsize: float = 1,
                         pdmode: int = 0) -> Iterable["DXFGraphic"]:
        """Yields point graphic as DXF primitives LINE and CIRCLE entities.
        The dimensionless point is rendered as zero-length line!

        Check for this condition::

            e.dxftype() == 'LINE' and e.dxf.start.isclose(e.dxf.end)

        if the rendering engine can't handle zero-length lines.

        Args:
            pdsize: point size in drawing units
            pdmode: point styling mode

        """
        for e in point.virtual_entities(self, pdsize, pdmode):
            e.set_source_of_copy(self)
            yield e
Exemplo n.º 7
0
def test_circle_point():
    p = pnt()
    result = point.virtual_entities(p, pdmode=33)
    circle = result[0]
    assert circle.dxf.center == (0, 0)
    assert circle.dxf.radius == 0.5
Exemplo n.º 8
0
def test_tick_point():
    p = pnt()
    result = point.virtual_entities(p, pdmode=4)
    line1 = result[0]
    assert line1.dxf.start == (0, 0)
    assert line1.dxf.end == (0, 0.5)
Exemplo n.º 9
0
def test_none_point():
    p = pnt()
    result = point.virtual_entities(p, pdmode=1)
    assert len(result) == 0