potracer 1.1.3 → 1.1.4

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: 6da744808fd40ff2c787e78a2d13e7d9c9ac51eb
4
- data.tar.gz: d0f3199933c29983afd712f1c4267d58915d20f9
3
+ metadata.gz: 9a23a82ce4fd9f8947a2730addd0c93b2d6952fc
4
+ data.tar.gz: 64c87ffb69f6de04d2449c4ddd871fcb056dde6c
5
5
  SHA512:
6
- metadata.gz: 93356f1cf863cadbb44aa2a5c430e5bd59c810a40f2ba485ee4732cfcdc0ba92ab2e78388b62cd3d8ff49221468cbc121148aa9968f957a4b7b55aec40d86bbe
7
- data.tar.gz: df942ab0e3d98cf43b64c28865ed169cdd225c2b285b1fa0a682159677d5d692f80734623b6e778058189a20e6e27047298f8888447a3baaae8d3dbb574dea82
6
+ metadata.gz: 578798745df2fc50983375f1f6eff6babf7d0307a2f33444ad41d1592192bf8a2a8a96c1ae25075710c175d7a95b46c6205582c6c0c06ee539d18c53aa437a23
7
+ data.tar.gz: 161b11a94b169f0d8199d5758a7cffd01e3bc71c7023acfc7d4f14e0478eb87b3e00df6fe14cb5631984dbcfc0d26a1100a8b366005d9675b113be709fdf8a09
@@ -6,14 +6,14 @@ LIBDIR = RbConfig::CONFIG['libdir']
6
6
  INCLUDEDIR = RbConfig::CONFIG['includedir']
7
7
 
8
8
  HEADER_DIRS = ['/opt/local/include', '/usr/local/include', INCLUDEDIR,
9
- '/usr/include']
9
+ '/usr/include']
10
10
 
11
11
  LIB_DIRS = ['/opt/local/lib', '/usr/local/lib', LIBDIR, '/usr/lib']
12
12
 
13
13
  dir_config('potrace', HEADER_DIRS, LIB_DIRS)
14
14
 
15
- abort "potracelib.h not found" unless find_header('potracelib.h')
16
- abort "lib potrace not found" unless find_library('potrace', 'potrace_version')
15
+ abort 'potracelib.h not found' unless find_header('potracelib.h')
16
+ abort 'lib potrace not found' unless find_library('potrace', 'potrace_version')
17
17
 
18
18
  create_header
19
19
  create_makefile('potracer/potracer')
@@ -5,12 +5,10 @@ rescue LoadError
5
5
  end
6
6
 
7
7
  module Potracer
8
-
9
8
  ##
10
9
  # This class represents a trace of a Potracer::Bitmap
11
10
 
12
11
  class Trace
13
-
14
12
  ##
15
13
  # Trace the given +bitmap+
16
14
  #
@@ -22,11 +20,11 @@ module Potracer
22
20
  # used.
23
21
  # * +block+ - optional block called to report trace progress
24
22
 
25
- def trace(bitmap=nil, params=nil, &block)
23
+ def trace(bitmap = nil, params = nil, &block)
26
24
  if block_given?
27
- self.do_trace(bitmap || @bitmap, params || @params, &block)
25
+ do_trace(bitmap || @bitmap, params || @params, &block)
28
26
  else
29
- self.do_trace(bitmap || @bitmap, params || @params)
27
+ do_trace(bitmap || @bitmap, params || @params)
30
28
  end
31
29
  end
32
30
 
@@ -35,8 +33,8 @@ module Potracer
35
33
  #
36
34
  # ==== Attributes
37
35
  #
38
- # * +bmp+ - mapped to a Potracer::Bitmap either a multi-dimensional array of
39
- # bits or a string of image data
36
+ # * +bmp+ - mapped to a Potracer::Bitmap either a multi-dimensional array
37
+ # of bits or a string of image data
40
38
  # * +width+ - width of the image to be mapped if +bmp+ is a string
41
39
  # * +height+ - height of the image to be mapped if +bmp+ is a string
42
40
  # * +map+ - pixel data format if +bmp+ is a string
@@ -52,17 +50,10 @@ module Potracer
52
50
  # end
53
51
  # pbar.finish
54
52
 
55
- def self.bitmap(bmp, width=nil, height=nil, map='RGB', &block)
56
- width ||= bmp.map {|r| r.length}.max
57
- height ||= bmp.length
58
-
59
- unless bmp.is_a? String
60
- bmp.map! {|r| r.fill(0, r.length, width - r.length)}
61
- end
62
-
63
- trace = self.new
53
+ def self.bitmap(bmp, width = nil, height = nil, map = 'RGB', &block)
54
+ trace = new
64
55
  params = Potracer::Params.new
65
- bits = Potracer::Bitmap.new(width, height, bmp, map)
56
+ bits = make_bits(bmp, width, height, map)
66
57
 
67
58
  if block_given?
68
59
  trace.trace(bits, params, &block)
@@ -71,5 +62,18 @@ module Potracer
71
62
  end
72
63
  trace
73
64
  end
65
+
66
+ private
67
+
68
+ def self.make_bits(bitmap, width, height, map)
69
+ width ||= bitmap.map { |r| r.length }.max
70
+ height ||= bitmap.length
71
+
72
+ unless bitmap.is_a? String
73
+ bitmap.map! { |r| r.fill(0, r.length, width - r.length) }
74
+ end
75
+
76
+ Potracer::Bitmap.new(width, height, bitmap, map)
77
+ end
74
78
  end
75
79
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: potracer
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.3
4
+ version: 1.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kenny Parnell
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-02 00:00:00.000000000 Z
11
+ date: 2014-02-13 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Ruby bindings for the potrace library.
14
14
  email: k.parnell@gmail.com