mork 0.18.2 → 0.19.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8cdb6af94ff682ccad23d669fb624d263ea4fb28d5911e3ada2ceeb200c8fd4a
4
- data.tar.gz: 956342c055f892ee7e4c44187711b3660eefd8fcee68723bfd1cb2fb245d0a75
3
+ metadata.gz: 8d1ff44d3b000b420e231a5ab3823293dad26ef69ec29ade174e74db32b16b9c
4
+ data.tar.gz: 520167a98213a49bec5820fb7d2476416197484dd93785ed861bb4998b9ca2ec
5
5
  SHA512:
6
- metadata.gz: 0c75eaac5ad245b5c86dde97f7e68c43a08486c248014e27963c8c1f763b2cc14fbe545d13f1d75675f1367daaf11df05f8109fdf88d752324cf7972a560e9e4
7
- data.tar.gz: 8864848f8f6a4a9cada44dd6f74183928fcdbf15986c97a27eb4d95ba6f60f2c9f0dd6a95ec8029fe961df0f4289da21703e8b9472c4ba6ad3f70929c043ffeb
6
+ metadata.gz: 6c66b3b59d316efe183f978e7702c03608ef08208a202640648a5e76d023d54d9bd6985db7d9307d677ca5c6f85776f1264fe141f9edcebb8ecf206956f4ca49
7
+ data.tar.gz: 580d00362722d80ea7af5411486174f714328de9ddf936a59aa911f86525725e27c5452aaa909ea2d2bc89abd57ee6b46e7e9434f239201c7ae12ea738f06bdf
data/README.md CHANGED
@@ -315,7 +315,7 @@ system 'open corrections.jpg' # this works in macOS
315
315
 
316
316
  `overlay_corrections` applies:
317
317
 
318
- - a green outline on the marked cell when the response is correct
318
+ - a green outline and semitransparent green fill on the marked cell when the response is correct
319
319
  - a red outline on the expected cell and a red cross on the marked cell when the response is incorrect
320
320
  - a red outline on the expected cell when the response is blank or invalid
321
321
 
data/lib/mork/magicko.rb CHANGED
@@ -81,6 +81,13 @@ module Mork
81
81
  coords.each { |c| @cmd << [:draw, shape(c, rounded)] }
82
82
  end
83
83
 
84
+ def highlight_green(coords, rounded)
85
+ return if coords.empty?
86
+ @cmd << [:stroke, 'none']
87
+ @cmd << [:fill, 'rgba(0, 255, 0, 0.3)']
88
+ coords.each { |c| @cmd << [:draw, shape(c, rounded)] }
89
+ end
90
+
84
91
  def outline(coords, rounded)
85
92
  outline_with_color(coords, rounded, 'green')
86
93
  end
@@ -165,10 +165,10 @@ module Mork
165
165
 
166
166
  # Applies correctness-aware overlays to the image using an answer key.
167
167
  #
168
- # Correct responses receive a green outline on the marked cell. Incorrect
169
- # responses receive a red outline on the expected cell and a red cross on
170
- # the given cell. Blank or invalid responses receive only the red outline
171
- # on the expected cell.
168
+ # Correct responses receive a green outline and semitransparent green fill
169
+ # on the marked cell. Incorrect responses receive a red outline on the
170
+ # expected cell and a red cross on the given cell. Blank or invalid
171
+ # responses receive only the red outline on the expected cell.
172
172
  #
173
173
  # @param correct_choices [Array<Integer, Array<Integer>, nil>] one entry per
174
174
  # question. Each entry can be an integer choice index, a 1-element array
@@ -183,6 +183,7 @@ module Mork
183
183
  actual = marked_responses(marked)
184
184
 
185
185
  green_outlines = Array.new(expected.length) { [] }
186
+ green_highlights = Array.new(expected.length) { [] }
186
187
  red_outlines = Array.new(expected.length) { [] }
187
188
  red_crosses = Array.new(expected.length) { [] }
188
189
 
@@ -192,6 +193,7 @@ module Mork
192
193
  marked_cells = actual[question]
193
194
  if marked_cells == [choice]
194
195
  green_outlines[question] = [choice]
196
+ green_highlights[question] = [choice]
195
197
  next
196
198
  end
197
199
 
@@ -200,6 +202,7 @@ module Mork
200
202
  end
201
203
 
202
204
  @mim.overlay :outline_green, green_outlines
205
+ @mim.overlay :highlight_green, green_highlights
203
206
  @mim.overlay :outline_red, red_outlines
204
207
  @mim.overlay :check_red, red_crosses
205
208
  end
data/lib/mork/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Mork
2
- VERSION = '0.18.2'
2
+ VERSION = '0.19.0'
3
3
  end
@@ -73,6 +73,14 @@ module Mork
73
73
  ma.outline [co], false
74
74
  expect(ma.instance_variable_get(:@cmd)).to include([:strokewidth, 6])
75
75
  end
76
+
77
+ it 'draws a semitransparent green fill over the cell' do
78
+ ma.highlight_green [co], false
79
+ commands = ma.instance_variable_get(:@cmd)
80
+ expect(commands).to include([:stroke, 'none'])
81
+ expect(commands).to include([:fill, 'rgba(0, 255, 0, 0.3)'])
82
+ expect(commands).to include([:draw, 'rectangle 0 0 50 50'])
83
+ end
76
84
  end
77
85
  end
78
86
  end
@@ -167,6 +167,7 @@ module Mork
167
167
  allow(omr).to receive(:marked_choices).and_return([[1], [2], [], [3, 4]])
168
168
 
169
169
  expect(mim).to receive(:overlay).with(:outline_green, [[1], [], [], []]).ordered
170
+ expect(mim).to receive(:overlay).with(:highlight_green, [[1], [], [], []]).ordered
170
171
  expect(mim).to receive(:overlay).with(:outline_red, [[], [0], [2], [3]]).ordered
171
172
  expect(mim).to receive(:overlay).with(:check_red, [[], [2], [], []]).ordered
172
173
 
@@ -179,6 +180,7 @@ module Mork
179
180
  omr.set_choices [5] * 2
180
181
 
181
182
  expect(mim).to receive(:overlay).with(:outline_green, [[], []]).ordered
183
+ expect(mim).to receive(:overlay).with(:highlight_green, [[], []]).ordered
182
184
  expect(mim).to receive(:overlay).with(:outline_red, [[3], [1]]).ordered
183
185
  expect(mim).to receive(:overlay).with(:check_red, [[1, 2], [0]]).ordered
184
186
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mork
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.18.2
4
+ version: 0.19.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Giuseppe Bertini