1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
|
# Copyright (c) 2021, Manfred Moitzi
# License: MIT License
import pytest
from ezdxf.entities import Hatch
from ezdxf.math import Vec2
@pytest.fixture
def all_edge_types_hatch():
# used in test files:
# 229c
# 250
hatch = Hatch.new(
dxfattribs={
"layer": "0",
"color": "2",
"elevation": (0.0, 0.0, 0.0),
"extrusion": (0.0, 0.0, 1.0),
"pattern_name": "SOLID",
"solid_fill": 1,
"associative": 0,
"hatch_style": 0,
"pattern_type": 1,
},
)
# edge-path contains all supported edge types:
ep = hatch.paths.add_edge_path(flags=1)
ep.add_arc( # clockwise oriented ARC
center=(0.0, 13.0),
radius=3.0,
start_angle=-90.0,
end_angle=90.0,
ccw=False,
)
ep.add_ellipse( # clockwise oriented ELLIPSE
center=(0.0, 5.0),
major_axis=(0.0, 5.0),
ratio=0.6,
start_angle=180.0,
end_angle=360.0,
ccw=False,
)
ep.add_line((0.0, 0.0), (10.0, 0.0)) # LINE
ep.add_ellipse( # counter-clockwise oriented ELLIPSE
center=(10.0, 5.0),
major_axis=(0.0, -5.0),
ratio=0.6,
start_angle=0.0,
end_angle=180.0,
ccw=True,
)
ep.add_arc( # counter-clockwise oriented ARC
center=(10.0, 13.0),
radius=3.0,
start_angle=270.0,
end_angle=450.0,
ccw=True,
)
ep.add_spline( # SPLINE
control_points=[
Vec2(10.0, 16.0),
Vec2(9.028174684192452, 16.0),
Vec2(6.824943218065775, 12.14285714285714),
Vec2(3.175056781934232, 19.85714285714287),
Vec2(0.9718253158075516, 16.0),
Vec2(0, 16.0),
],
knot_values=[
0.0,
0.0,
0.0,
0.0,
2.91547594742265,
8.746427842267952,
11.6619037896906,
11.6619037896906,
11.6619037896906,
11.6619037896906,
],
degree=3,
periodic=0,
)
return hatch
|