chiplotle-cli-wrapper 0.0.1 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/bin/print_text.rb +12 -7
- data/lib/chiplotle-cli-wrapper.rb +34 -7
- metadata +1 -1
data/bin/print_text.rb
CHANGED
@@ -4,19 +4,24 @@
|
|
4
4
|
#
|
5
5
|
|
6
6
|
require 'chiplotle-cli-wrapper'
|
7
|
+
require 'awesome_print'
|
7
8
|
|
8
9
|
# FIXME: check args..
|
9
|
-
|
10
|
-
pen_no
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
10
|
+
text = ARGV[0]
|
11
|
+
pen_no = ARGV[1]
|
12
|
+
rotation = ARGV[2]
|
13
|
+
slant = ARGV[3]
|
14
|
+
character_height = ARGV[4]
|
15
|
+
character_width = ARGV[5]
|
16
|
+
x = ARGV[6]
|
17
|
+
y = ARGV[7]
|
15
18
|
|
16
19
|
plotter = ChiplotleCliWrapper::Plotter.new
|
17
20
|
|
18
21
|
plotter.debug = true
|
19
22
|
|
20
|
-
|
23
|
+
ap ARGV
|
24
|
+
|
25
|
+
plotter.print_text(*ARGV)
|
21
26
|
|
22
27
|
plotter.close
|
@@ -42,37 +42,64 @@ module ChiplotleCliWrapper
|
|
42
42
|
plotter "hpgl.SP(#{pen_no})"
|
43
43
|
end
|
44
44
|
|
45
|
+
# device will continue from last position if no values are supplied
|
45
46
|
def position(x, y)
|
46
|
-
plotter "hpgl.PA([(#{x}, #{y})])"
|
47
|
+
plotter "hpgl.PA([(#{x}, #{y})])" unless x == nil or y == nil
|
47
48
|
end
|
48
49
|
|
49
50
|
def label(text)
|
50
51
|
plotter "hpgl.LB('#{text}')"
|
51
52
|
end
|
52
53
|
|
53
|
-
def label_size(
|
54
|
-
plotter "hpgl.SI(#{
|
54
|
+
def label_size(width, height)
|
55
|
+
plotter "hpgl.SI(#{width}, #{height})"
|
55
56
|
end
|
56
57
|
|
57
58
|
def label_size_reset
|
58
59
|
plotter "hpgl.SI()"
|
59
60
|
end
|
60
61
|
|
62
|
+
def rotate(angle)
|
63
|
+
plotter "hpgl.RO(#{angle})"
|
64
|
+
end
|
65
|
+
|
66
|
+
def slant(slant)
|
67
|
+
plotter "hpgl.SL(#{slant})"
|
68
|
+
end
|
69
|
+
|
61
70
|
def replace_pen
|
62
71
|
pen(0)
|
63
72
|
end
|
64
73
|
|
65
|
-
|
74
|
+
# FIXME: maybe use nil rather than defaul values to leave setting unchanged..
|
75
|
+
def print_text(
|
76
|
+
text = "",
|
77
|
+
pen_no = 1,
|
78
|
+
rotation = 0,
|
79
|
+
slant = 0,
|
80
|
+
character_width = 0.285,
|
81
|
+
character_height = 0.375,
|
82
|
+
x = nil,
|
83
|
+
y = nil
|
84
|
+
)
|
85
|
+
|
86
|
+
# TODO: only set settings for settings that have changed (will decrease wait before drawing)
|
66
87
|
|
67
88
|
# pick up a pen
|
68
89
|
pen(pen_no)
|
69
90
|
|
70
|
-
# scale label
|
71
|
-
label_size(height, width)
|
72
|
-
|
73
91
|
# move to position
|
74
92
|
position(x, y)
|
75
93
|
|
94
|
+
# scale label
|
95
|
+
label_size(character_height, character_width)
|
96
|
+
|
97
|
+
# rotate label
|
98
|
+
rotate(rotation)
|
99
|
+
|
100
|
+
# vertical_label
|
101
|
+
slant(slant)
|
102
|
+
|
76
103
|
# print message
|
77
104
|
label(text)
|
78
105
|
|