blob: a495852c61c96569370a7190713ca0dc7a4fbd07 (
plain)
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
|
module Scale
class Path
include Node
attribute :d, String
def move_to(x:, y:)
command("M#{x} #{y}")
end
def line_to(x:, y:)
command("L #{x} #{y}")
end
def horizontal(n, relative: false)
command("#{relative ? "h" : "H"} #{n}")
end
def vertical(n, relative: false)
command("#{relative ? "v" : "V"} #{n}")
end
def close_path
command("Z")
end
def xml_tag
:path
end
private
def command(instructions)
if self.d.nil?
self.d = instructions
else
self.d = "#{self.d} #{instructions}"
end
end
end
end
|