spriteous 0.1.3 → 0.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.
- data/lib/spriteous.rb +4 -2
- metadata +4 -4
data/lib/spriteous.rb
CHANGED
@@ -7,7 +7,9 @@ class Spriteous
|
|
7
7
|
meth = data[1..3] == "PNG" ? :from_string : :from_file
|
8
8
|
@img = ChunkyPNG::Image.send meth, data
|
9
9
|
|
10
|
-
|
10
|
+
# Determine the sheet's background color by checking the last pixel. Obtain
|
11
|
+
# the sheet's width, which is used to determine a pixel's neighbors.
|
12
|
+
back, @w = @img.pixels.last, @img.width
|
11
13
|
|
12
14
|
# The original image's pixels get modified in place to erase the background
|
13
15
|
# color, They're duplicated because the algorithm relies on "erasing" found
|
@@ -28,7 +30,7 @@ class Spriteous
|
|
28
30
|
until queue.empty?
|
29
31
|
p = queue.pop
|
30
32
|
|
31
|
-
if @pixels[p] > 0
|
33
|
+
if @pixels[p] && @pixels[p] > 0
|
32
34
|
# Store this non-transparent pixel's index and then make it transparent
|
33
35
|
# to avoid unnecessarily checking it again from a neighbor.
|
34
36
|
@pixels[(@found << p).last] = 0
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spriteous
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-03-
|
12
|
+
date: 2012-03-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: oily_png
|
16
|
-
requirement: &
|
16
|
+
requirement: &75440490 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *75440490
|
25
25
|
description:
|
26
26
|
email:
|
27
27
|
- andkerosine@gmail.com
|