pixelart 1.1.1 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pixelart/composite.rb +23 -0
- data/lib/pixelart/image.rb +10 -5
- data/lib/pixelart/version.rb +2 -2
- 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: 798a4eb7b61556c0c79889d01d404a499598286779e009fa71304986f4d68c31
|
4
|
+
data.tar.gz: 9b17446fe914c1b62135c1e1432bc2debf74037ca9e602feb25e71ec7088b117
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8073e67ffd10361088fd66b768d4aa5927c2f65cdd54389615b980c2181ec8cde2a2ad21eced1fe7a756af7ce2e7c681b2aea4a89aed2c869ad04a956388d54a
|
7
|
+
data.tar.gz: b69918e012f6270a9aa0817d69e094bb52cd12ed05399ac566872efdd2174af9c9534ef2e72f4f34f4d3f1bbe4d5062aedcbb42deb67ff55c52a005965b2d969
|
data/lib/pixelart/composite.rb
CHANGED
@@ -7,6 +7,13 @@ class ImageComposite < Image # check: (re)name to Collage, Sheet, Sprites, or s
|
|
7
7
|
TILE_HEIGHT = 24
|
8
8
|
|
9
9
|
|
10
|
+
def self.read( path, width: TILE_WIDTH, height: TILE_WIDTH ) ## convenience helper
|
11
|
+
img = ChunkyPNG::Image.from_file( path )
|
12
|
+
new( img, width: width,
|
13
|
+
height: width )
|
14
|
+
end
|
15
|
+
|
16
|
+
|
10
17
|
def initialize( *args, **kwargs )
|
11
18
|
@tile_width = kwargs[:width] || kwargs[:tile_width] || TILE_WIDTH
|
12
19
|
@tile_height = kwargs[:height] || kwargs[:tile_height] || TILE_HEIGHT
|
@@ -73,5 +80,21 @@ class ImageComposite < Image # check: (re)name to Collage, Sheet, Sprites, or s
|
|
73
80
|
super ## e.g [x,y] --- get pixel
|
74
81
|
end
|
75
82
|
end
|
83
|
+
|
84
|
+
|
85
|
+
## convenience helpers to loop over composite
|
86
|
+
def each( &block )
|
87
|
+
count.times do |i|
|
88
|
+
block.call( tile( i ) )
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
def each_with_index( &block )
|
93
|
+
count.times do |i|
|
94
|
+
block.call( tile( i ), i )
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
|
76
99
|
end # class ImageComposite
|
77
100
|
end # module Pixelart
|
data/lib/pixelart/image.rb
CHANGED
@@ -94,12 +94,9 @@ def grayscale
|
|
94
94
|
img = @img.grayscale
|
95
95
|
Image.new( img.width, img.height, img )
|
96
96
|
end
|
97
|
+
alias_method :greyscale, :grayscale
|
98
|
+
|
97
99
|
|
98
|
-
def mirror
|
99
|
-
img = @img.mirror
|
100
|
-
Image.new( img.width, img.height, img )
|
101
|
-
end
|
102
|
-
alias_method :flip_vertically, :mirror
|
103
100
|
|
104
101
|
def flip
|
105
102
|
img = @img.flip
|
@@ -107,6 +104,14 @@ def flip
|
|
107
104
|
end
|
108
105
|
alias_method :flip_horizontally, :flip
|
109
106
|
|
107
|
+
def mirror
|
108
|
+
img = @img.mirror
|
109
|
+
Image.new( img.width, img.height, img )
|
110
|
+
end
|
111
|
+
alias_method :flip_vertically, :mirror
|
112
|
+
alias_method :flop, :mirror
|
113
|
+
|
114
|
+
|
110
115
|
|
111
116
|
|
112
117
|
|
data/lib/pixelart/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pixelart
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gerald Bauer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-10-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: chunky_png
|