barf 0.1.0 → 1.0.0

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: 59c0f8aa73023649c7593291cd4f1f98fda68a14bd0872e1efec312e15ffb501
4
- data.tar.gz: ea4c410456db38efaa10d1cc22f98906f177fd8bf8873f6311e575aefe347eeb
3
+ metadata.gz: 55081eb4528651032a7ed560be6886ae3492373054f0d8482ffa7044671a3ddc
4
+ data.tar.gz: ded67bbf6670bd22c9bd653d1fd890741c8fb2cb146fc4d79c30a8137af01e09
5
5
  SHA512:
6
- metadata.gz: 6a36d96b366574e4ad452acb4dd55c93e14e10e05688d14f6879ccc150cf822543ee28a6417364bb4e104a4690ede28740d6eb1369db81a2ada5b606c160708c
7
- data.tar.gz: 568259b8c99f81f3c959de076433002b40700cb017ce6ffd1801ea221b009d3d745aedadb1fc546f74acb77fc146435f18e76b71fd4ccca9f5315bd1ca3d26b4
6
+ metadata.gz: 02a3900ab92c40b8fc68e9fcceee6a4afb74dcb25f97084fb349e09b1de7e59e002d90220627bababba86725124b251d505895be27ee7a91351bd6b79efa2ad1
7
+ data.tar.gz: 0a1431cb7fddfea311733ef8f4717513aecf49fdadc31a4ec2c9311a7f371c60ea9ea16c9b66a2dbbae76011d4f5291420b65444ec26a98a3e203fe1e11dea2c
data/.gitignore CHANGED
@@ -11,3 +11,5 @@
11
11
  .rspec_status
12
12
  Gemfile.lock
13
13
  .idea/
14
+ .DS_Store
15
+
data/lib/barf/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Barf
2
- VERSION = "0.1.0"
2
+ VERSION = "1.0.0"
3
3
  end
data/lib/barf.rb CHANGED
@@ -5,15 +5,21 @@ require "tco"
5
5
 
6
6
  module Barf
7
7
 
8
+ @palette = "inline:data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAP4AAAABCAIAAABxMITKAAABpklEQVR4AW2StWIUXRTHf2d2o9+Huzv85yGooKJKic7wKukueYvZICXW0kZ67CwV7lbh7CVzd+IZ/dv1Y8Dw8PDo8uvYzHSnsIJ4oyrPQafk1KtXfWtoaKjVarXb7cHBwTm6aWJiM2wHwQZjVySUCEtPL1SliDU2QoFoHlPFARihdENWqWcZRc+qWwWy0iOiGqusW8YTlFR4iaLC5ObNbP8cXWkIjyJz9UQW6m8zbrh1SZAyyFnAYayqsRfCGpdq/Rt27mo/8YsiujhO3JjlQ1FG6wwPQVXpg+gcDrpXaQidxMl095KPoNNJVyeI6JarR5vW0eyhIh6VVu0CNykiEkaC0JGiOScEosmst9e72R0uLTbJ8RPg1DjLA2mWJvjeLp49sESjmEx7YQlf9kXcCfV3o+urKLtO3Zdo8qmrDa9t1+5LvrhNh8bH+0fcP+5N7965Un+ufuTQz58LgbnvztlZRTxHsJARFvQ44TRHl4zuCU6A3JNe465rAV8JDV7eT8qvpYfcFdMql+s7ZmYWqvTY37/NQF0p4mLdq1eZZcMjw5s2bfoHC6PO/+pdxgEAAAAASUVORK5CYII="
9
+
8
10
  def self.print(path)
9
11
  image = MiniMagick::Image.open(path)
10
12
 
11
13
  terminal_width = `tput cols`.to_i
12
14
 
13
15
  # Height must be divisible by 2 for the half pixels to be clean.
14
- new_height = (image.height * (0.5 * terminal_width / image.width)).to_i * 2
16
+ new_height = [2, (image.height * (0.5 * terminal_width / image.width)).to_i * 2].max
15
17
 
16
- image.resize "#{terminal_width}x#{new_height}!"
18
+ image.combine_options do |tmp|
19
+ tmp.resize "#{terminal_width}x#{new_height}!"
20
+ tmp.dither 'FloydSteinberg'
21
+ tmp.remap @palette
22
+ end
17
23
 
18
24
  # Two dimensional array of pixels:
19
25
  image.get_pixels.each_slice(2) do |top, bottom|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: barf
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jacob Duffy