chiplotle-cli-wrapper 0.0.1 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -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
- message = ARGV[0]
10
- pen_no = ARGV[1]
11
- height = ARGV[2]
12
- width = ARGV[3]
13
- x = ARGV[4]
14
- y = ARGV[5]
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
- plotter.print_text(message, pen_no, height, width, x, y)
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(height, width)
54
- plotter "hpgl.SI(#{height}, #{width})"
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
- def print_text(text = "", pen_no = 1, height = 0.375, width = 0.285, x = 0, y = 0)
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
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chiplotle-cli-wrapper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: