7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/rough/hachure_fill.rb', line 7
def hachure_lines(polygons, hachure_gap, hachure_angle, hachure_step_offset = 1)
gap = [hachure_gap, 0.1].max
polygon_list = if polygons[0] && polygons[0][0]&.is_a?(Numeric)
[polygons]
else
polygons
end
rotation_center = [0, 0]
if hachure_angle != 0
polygon_list.each { |polygon| rotate_points(polygon, rotation_center, hachure_angle) }
end
lines = straight_hachure_lines(polygon_list, gap, hachure_step_offset)
if hachure_angle != 0
polygon_list.each { |polygon| rotate_points(polygon, rotation_center, -hachure_angle) }
rotate_lines(lines, rotation_center, -hachure_angle)
end
lines
end
|