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 +4 -4
- data/lib/pangrid/plugins/exolve.rb +1 -1
- data/lib/pangrid/plugins/png.rb +13 -4
- data/lib/pangrid/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e04bea2f4ebdb7947ec122f28a4a8feaa9cb4e7c4a27206abb6ef0fe7e6f254c
|
4
|
+
data.tar.gz: d5f32ec895146fe2141c5f68dcf775477b7a381577239e8225d8d8a155fe0c10
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d8057bad79f07c4d761f136a8258171b5b7a3711d5d72d589282d7219153fbf6bbb28c29315ab0ee99eba74ef465d334dbef71fd7657e8881dfe42ad944076ac
|
7
|
+
data.tar.gz: e8bf9a1582e69ab4279505d19f957dbe3668cb471cd2644660fbaff073a08f3b608de57db830f637c6a97ada3f255e79bcbc59bab45f0e8d9e9ff345cc0636f8
|
data/lib/pangrid/plugins/png.rb
CHANGED
@@ -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
|
-
|
13
|
-
|
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
|
-
|
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
|
data/lib/pangrid/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2022-02-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: webrick
|