pxlsrt 1.4.0 → 1.5.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
  SHA1:
3
- metadata.gz: b9904ad442d8b272d6aa9e196085efc13e9e6c0e
4
- data.tar.gz: 145c0cae2d397312d85a4c3627581eb2076a95a8
3
+ metadata.gz: 656493d31b58b436d501a9211402394cb3527753
4
+ data.tar.gz: ab1f3e92f84610d992a7bf1295db33e556309ec6
5
5
  SHA512:
6
- metadata.gz: 2fc1fd26d049302824076066ec5a495ba27f76402263e20aba2a02dd673357a6b46d4b5685bea5a1c6935ad51512ba566ded3ee43b0f786f0e1baf1dd80aa25d
7
- data.tar.gz: 204629fbe1687469b21fea3f1bf2a94350fa2ad1b657625cbd753cf11a9ddba06a683542bc470678cab1116720263ba491ca3190368b6d058ce8d4ed7e3e3dd9
6
+ metadata.gz: 8acafe9a33025af289c5753f8abb320f87cb16633fefa9b43b2008dfec9193917bc8386d9fec9896901c5229b301a3c5de59222622ef2767050ffec70b2cbb64
7
+ data.tar.gz: 952ada3617bb2514ff162c466b9f7935aab2e6ff396201a2b1e614739c431652a4dfd36934597da519f6ed1bbb237d2008a27d11f9136050ae3f17e4b041c842
data/bin/pxlsrt CHANGED
@@ -20,6 +20,7 @@ class CLI < Thor
20
20
  class_option :smooth, :type => :boolean, :default => false, :aliases => "-s"
21
21
  class_option :method, :type => :string, :default => "sum-rgb", :banner => "[sum-rgb | red | green | blue | sum-hsb | hue | saturation | brightness | uniqueness | luma | random | cyan | magenta | yellow | alpha | sum-rgba | sum-hsba]", :aliases => "-m", :enum => ["sum-rgb", "red", "green", "blue", "sum-hsb", "hue", "saturation", "brightness", "uniqueness", "luma", "random", "cyan", "magenta", "yellow", "alpha", "sum-rgba", "sum-hsba"]
22
22
  class_option :verbose, :type => :boolean, :default => false, :aliases => "-V"
23
+ class_option :middle, :type => :boolean, :default => false, :aliases => "-M"
23
24
 
24
25
  option :min, :type => :numeric, :default => Float::INFINITY, :banner => "MINIMUM BANDWIDTH"
25
26
  option :max, :type => :numeric, :default => Float::INFINITY, :banner => "MAXIMUM BANDWIDTH"
data/lib/pxlsrt/brute.rb CHANGED
@@ -27,7 +27,8 @@ module Pxlsrt
27
27
  :verbose => false,
28
28
  :min => Float::INFINITY,
29
29
  :max => Float::INFINITY,
30
- :trusted => false
30
+ :trusted => false,
31
+ :middle => false
31
32
  }
32
33
  defRules={
33
34
  :reverse => ["no", "reverse", "either"],
@@ -38,7 +39,8 @@ module Pxlsrt
38
39
  :verbose => [false, true],
39
40
  :min => [Float::INFINITY, {:class => [Fixnum]}],
40
41
  :max => [Float::INFINITY, {:class => [Fixnum]}],
41
- :trusted => [false, true]
42
+ :trusted => [false, true],
43
+ :middle => [false, true]
42
44
  }
43
45
  options=defOptions.merge(o)
44
46
  if o.length==0 or options[:trusted]==true or (options[:trusted]==false and o.length!=0 and Pxlsrt::Helpers.checkOptions(options, defRules)!=false)
@@ -91,12 +93,14 @@ module Pxlsrt
91
93
  newInTown=[]
92
94
  if options[:smooth]!=true
93
95
  for ranger in sliceRanges
94
- newInTown.concat(Pxlsrt::Colors.pixelSort(m[ranger[0]..ranger[1]], options[:method].downcase, nre))
96
+ newInTown.concat(Pxlsrt::Lines.middlate(Pxlsrt::Colors.pixelSort(m[ranger[0]..ranger[1]], options[:method].downcase, nre))) if options[:middle]
97
+ newInTown.concat(Pxlsrt::Colors.pixelSort(m[ranger[0]..ranger[1]], options[:method].downcase, nre)) if !options[:middle]
95
98
  end
96
99
  else
97
100
  for ranger in sliceRanges
98
101
  k=(m[ranger[0]..ranger[1]]).group_by { |x| x }
99
102
  g=Pxlsrt::Colors.pixelSort(k.keys, options[:method].downcase, nre)
103
+ g=Pxlsrt::Lines.middlate(g) if options[:middle]
100
104
  j=g.map { |x| k[x] }.flatten(1)
101
105
  newInTown.concat(j)
102
106
  end
@@ -112,12 +116,14 @@ module Pxlsrt
112
116
  newInTown=[]
113
117
  if options[:smooth]!=true
114
118
  for ranger in sliceRanges
115
- newInTown.concat(Pxlsrt::Colors.pixelSort(dia[m][ranger[0]..ranger[1]], options[:method].downcase, nre))
119
+ newInTown.concat(Pxlsrt::Lines.middlate(Pxlsrt::Colors.pixelSort(dia[m][ranger[0]..ranger[1]], options[:method].downcase, nre))) if options[:middle]
120
+ newInTown.concat(Pxlsrt::Colors.pixelSort(dia[m][ranger[0]..ranger[1]], options[:method].downcase, nre)) if !options[:middle]
116
121
  end
117
122
  else
118
123
  for ranger in sliceRanges
119
124
  k=(dia[m][ranger[0]..ranger[1]]).group_by { |x| x }
120
125
  g=Pxlsrt::Colors.pixelSort(k.keys, options[:method].downcase, nre)
126
+ g=Pxlsrt::Lines.middlate(g) if options[:middle]
121
127
  j=g.map { |x| k[x] }.flatten(1)
122
128
  newInTown.concat(j)
123
129
  end
data/lib/pxlsrt/lines.rb CHANGED
@@ -25,6 +25,21 @@ module Pxlsrt
25
25
  return nu
26
26
  end
27
27
  ##
28
+ # Some fancy rearranging.
29
+ # [a, b, c, d, e] -> [d, b, a, c, e]
30
+ def self.middlate(arr)
31
+ a=[]
32
+ f=(arr.length/2.0).ceil-1
33
+ for e in 1..arr.length
34
+ if (arr.length+e)%2==0
35
+ a[f+(e/2.0).floor]=arr[e-1]
36
+ elsif (arr.length+e)%2==1
37
+ a[f-(e/2.0).floor]=arr[e-1]
38
+ end
39
+ end
40
+ return a
41
+ end
42
+ ##
28
43
  # Gets "rows" of an array based on a width
29
44
  def self.imageRGBLines(image, width)
30
45
  return image.each_slice(width).to_a
data/lib/pxlsrt/smart.rb CHANGED
@@ -29,7 +29,8 @@ module Pxlsrt
29
29
  :absolute => false,
30
30
  :threshold => 20,
31
31
  :edge => 2,
32
- :trusted => false
32
+ :trusted => false,
33
+ :middle => false
33
34
  }
34
35
  defRules={
35
36
  :reverse => ["no", "reverse", "either"],
@@ -41,7 +42,8 @@ module Pxlsrt
41
42
  :absolute => [false, true],
42
43
  :threshold => [{:class => [Float, Fixnum]}],
43
44
  :edge => [{:class => [Fixnum]}],
44
- :trusted => [false, true]
45
+ :trusted => [false, true],
46
+ :middle => [false, true]
45
47
  }
46
48
  options=defOptions.merge(o)
47
49
  if o.length==0 or options[:trusted]==true or (options[:trusted]==false and o.length!=0 and Pxlsrt::Helpers.checkOptions(options, defRules)!=false)
@@ -149,11 +151,13 @@ module Pxlsrt
149
151
  if options[:smooth]
150
152
  for band in bands
151
153
  u=band.group_by {|x| x}
152
- image.concat(Pxlsrt::Colors.pixelSort(u.keys, options[:method], nre).map { |x| u[x] }.flatten(1))
154
+ image.concat(Pxlsrt::Colors.pixelSort(u.keys, options[:method], nre).map { |x| u[x] }.flatten(1)) if !options[:middle]
155
+ image.concat(Pxlsrt::Lines(Pxlsrt::Colors.pixelSort(u.keys, options[:method], nre).map { |x| u[x] }.flatten(1))) if options[:middle]
153
156
  end
154
157
  else
155
158
  for band in bands
156
- image.concat(Pxlsrt::Colors.pixelSort(band, options[:method], nre))
159
+ image.concat(Pxlsrt::Colors.pixelSort(band, options[:method], nre)) if !options[:middle]
160
+ image.concat(Pxlsrt::Lines.middlate(Pxlsrt::Colors.pixelSort(band, options[:method], nre))) if options[:middle]
157
161
  end
158
162
  end
159
163
  else
@@ -204,11 +208,13 @@ module Pxlsrt
204
208
  if options[:smooth]
205
209
  for band in dia[j]
206
210
  u=band.group_by {|x| x}
207
- ell.concat(Pxlsrt::Colors.pixelSort(u.keys, options[:method], nre).map { |x| u[x] }.flatten(1))
211
+ ell.concat(Pxlsrt::Colors.pixelSort(u.keys, options[:method], nre).map { |x| u[x] }.flatten(1)) if !options[:middle]
212
+ ell.concat(Pxlsrt::Lines.middlate(Pxlsrt::Colors.pixelSort(u.keys, options[:method], nre).map { |x| u[x] }.flatten(1))) if options[:middle]
208
213
  end
209
214
  else
210
215
  for band in dia[j]
211
- ell.concat(Pxlsrt::Colors.pixelSort(band, options[:method], nre))
216
+ ell.concat(Pxlsrt::Colors.pixelSort(band, options[:method], nre)) if !options[:middle]
217
+ ell.concat(Pxlsrt::Lines.middlate(Pxlsrt::Colors.pixelSort(band, options[:method], nre))) if options[:middle]
212
218
  end
213
219
  end
214
220
  dia[j]=ell
@@ -1,5 +1,5 @@
1
1
  ##
2
2
  # The main module, your best friend.
3
3
  module Pxlsrt
4
- VERSION = "1.4.0"
4
+ VERSION = "1.5.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pxlsrt
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - EVA-01
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-06 00:00:00.000000000 Z
11
+ date: 2014-07-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler