pangrid 0.5.1 → 0.5.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0ec0d0d4bf728c0021f9db679a2c0b3208b7a5971888ef4de9490e8dc07037b1
4
- data.tar.gz: eb305d1960b5876c0d31d562a0734cd61f9c7683f0bed5cf5af2c3fb2f8b2f99
3
+ metadata.gz: e04bea2f4ebdb7947ec122f28a4a8feaa9cb4e7c4a27206abb6ef0fe7e6f254c
4
+ data.tar.gz: d5f32ec895146fe2141c5f68dcf775477b7a381577239e8225d8d8a155fe0c10
5
5
  SHA512:
6
- metadata.gz: 2a8cc63d397ce5047e9e85b0665f7436af2aff9f59a8dec8d8b9f6ed9abb83b333d0f8f348fc3d460c908dcb6bc6b11338cba2ed7ad8d7af8bb29680dc0ad901
7
- data.tar.gz: d9b5dec6380b0bcd6429e7a61f085330c329f70e75518a7c4471e4c5abab2c7d570c3696ef4034028627b8bb329d3b0aa4a861257d11adeedcaa8d3594a76b0c
6
+ metadata.gz: d8057bad79f07c4d761f136a8258171b5b7a3711d5d72d589282d7219153fbf6bbb28c29315ab0ee99eba74ef465d334dbef71fd7657e8881dfe42ad944076ac
7
+ data.tar.gz: e8bf9a1582e69ab4279505d19f957dbe3668cb471cd2644660fbaff073a08f3b608de57db830f637c6a97ada3f255e79bcbc59bab45f0e8d9e9ff345cc0636f8
@@ -95,7 +95,7 @@ module ExolveReader
95
95
  end
96
96
 
97
97
  def parse_grid(lines)
98
- grid = lines.map(&:strip).map {|x| x.split(//)}
98
+ grid = lines.map {|x| x.gsub(/\s/, '').split(//)}
99
99
  grid.map do |col|
100
100
  col.map do |c|
101
101
  Cell.new(:solution => parse_grid_char(c))
@@ -3,21 +3,30 @@ require 'chunky_png'
3
3
  module Pangrid
4
4
 
5
5
  class PNGThumbnail < Plugin
6
+ attr_reader :scale, :border
7
+
8
+ def initialize(scale = 4, border = [128, 0, 0])
9
+ @scale = scale
10
+ @border = border
11
+ end
6
12
 
7
13
  def write(xw)
8
14
  black = ChunkyPNG::Color::BLACK
9
15
  white = ChunkyPNG::Color::WHITE
10
- red = ChunkyPNG::Color::rgb(255, 0, 0)
11
16
  grey = ChunkyPNG::Color::rgb(128, 128, 128)
12
- scale = 4
13
- png = ChunkyPNG::Image.new(64, 64, ChunkyPNG::Color::TRANSPARENT)
17
+ xdim = xw.width * scale + 2
18
+ ydim = xw.height * scale + 2
19
+ png = ChunkyPNG::Image.new(xdim, ydim, ChunkyPNG::Color::TRANSPARENT)
14
20
  xw.each_cell_with_coords do |x, y, cell|
15
21
  c = cell.black? ? black : white
16
22
  png.rect(
17
23
  x * scale, y * scale, (x + 1) * scale, (y + 1) * scale,
18
24
  stroke_color = grey, fill_color = c)
19
25
  end
20
- png.rect(0, 0, xw.width * scale, xw.height * scale, stroke_color = red)
26
+ if border
27
+ stroke = ChunkyPNG::Color::rgb(*border)
28
+ png.rect(0, 0, xw.width * scale, xw.height * scale, stroke_color = stroke)
29
+ end
21
30
  png.to_blob
22
31
  end
23
32
  end
@@ -1,3 +1,3 @@
1
1
  module Pangrid
2
- VERSION='0.5.1'
2
+ VERSION='0.5.2'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pangrid
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin DeMello
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-02-05 00:00:00.000000000 Z
11
+ date: 2022-02-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: webrick