pixelart 1.3.4 → 1.3.5
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 +4 -4
- data/Rakefile +1 -1
- data/lib/pixelart/base.rb +4 -4
- data/lib/pixelart/image.rb +55 -5
- data/lib/pixelart/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 43bc0ad17527099593a49e143036c875bf93fc61873d551252a19376490734fd
|
4
|
+
data.tar.gz: c57fdb4d5241915767f4480a698f3f362d25c53f99805050b8c8dd4c2ca9ec27
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 742db57f909288c2a19105244951f676c99723544be749e60544d3576f326f323ec00bcdf0ea9fbeef0e6a6a0d55771f5ad06a7e5fe1a32814b6f509bc472be4
|
7
|
+
data.tar.gz: 2b7d05f9e4ab9a4f4348b3fb7b7f1f5b36ee884b4db3bae901479c84c4dac0207f67f56ba140319a45bd1704c9af14075ef7dfc3ef20897476dfc5bf242a509c
|
data/Rakefile
CHANGED
data/lib/pixelart/base.rb
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
require 'cocos'
|
2
|
+
require 'base64'
|
3
|
+
|
4
|
+
|
1
5
|
###
|
2
6
|
# base module
|
3
7
|
require 'pixelart/colors'
|
@@ -13,10 +17,6 @@ require 'chunky_png'
|
|
13
17
|
require 'mini_magick'
|
14
18
|
|
15
19
|
|
16
|
-
# bonus / prologue / convenience 3rd party
|
17
|
-
require 'csvreader'
|
18
|
-
|
19
|
-
|
20
20
|
|
21
21
|
## our own code
|
22
22
|
require 'pixelart/version' # note: let version always go first
|
data/lib/pixelart/image.rb
CHANGED
@@ -2,12 +2,42 @@ module Pixelart
|
|
2
2
|
|
3
3
|
class Image
|
4
4
|
|
5
|
+
|
6
|
+
## keep track of all (inherited) subclasses via inherited hook
|
7
|
+
##
|
8
|
+
## change/rename to descendants - why? why not?
|
9
|
+
##
|
10
|
+
## note about rails (activesupport?)
|
11
|
+
## If you use rails >= 3, you have two options in place.
|
12
|
+
## Use .descendants if you want more than one level depth of children classes,
|
13
|
+
## or use .subclasses for the first level of child classes.
|
14
|
+
|
15
|
+
def self.subclasses
|
16
|
+
@subclasses ||= []
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.inherited( subclass )
|
20
|
+
subclasses << subclass
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
|
5
27
|
def self.read( path ) ## convenience helper
|
6
28
|
img_inner = ChunkyPNG::Image.from_file( path )
|
7
29
|
img = new( img_inner.width, img_inner.height, img_inner )
|
8
30
|
img
|
9
31
|
end
|
10
32
|
|
33
|
+
def self.parse_base64( str )
|
34
|
+
blob = Base64.decode64( str )
|
35
|
+
img_inner = ChunkyPNG::Image.from_blob( blob )
|
36
|
+
img = new( img_inner.width, img_inner.height, img_inner )
|
37
|
+
img
|
38
|
+
end
|
39
|
+
|
40
|
+
|
11
41
|
|
12
42
|
|
13
43
|
CHARS = '.@xo^~%*+=:' ## todo/check: rename to default chars or such? why? why not?
|
@@ -95,6 +125,16 @@ def crop( x, y, crop_width, crop_height )
|
|
95
125
|
end
|
96
126
|
|
97
127
|
|
128
|
+
## shift image n-pixels to the left (NOT changing width/height)
|
129
|
+
def left( left )
|
130
|
+
img = Image.new( width, height )
|
131
|
+
img.compose!( crop( 0, 0, width-left, height ), left, 0 )
|
132
|
+
img
|
133
|
+
end
|
134
|
+
|
135
|
+
|
136
|
+
|
137
|
+
|
98
138
|
|
99
139
|
#######################
|
100
140
|
## filter / effects
|
@@ -106,19 +146,29 @@ end
|
|
106
146
|
alias_method :greyscale, :grayscale
|
107
147
|
|
108
148
|
|
109
|
-
|
110
|
-
|
111
|
-
|
149
|
+
######################
|
150
|
+
# flip horizontally on x-axis (top-to-bottom/bottom-to-top)
|
151
|
+
# e.g. pixels on the top will now be pixels on the bottom
|
152
|
+
def flip_horizontally
|
153
|
+
img = @img.flip_horizontally
|
112
154
|
Image.new( img.width, img.height, img )
|
113
155
|
end
|
114
|
-
|
156
|
+
## keep flop? alias - why? why not?
|
157
|
+
## note: chunky_png use flip alias for flip_horizontally!!!!
|
158
|
+
alias_method :flop, :flip_horizontally
|
159
|
+
|
115
160
|
|
161
|
+
###
|
162
|
+
# flip vertially on y-axis (right-to-left/left-to-right)
|
163
|
+
# e.g. pixels on the left will now be pixels on the right
|
116
164
|
def mirror
|
117
165
|
img = @img.mirror
|
118
166
|
Image.new( img.width, img.height, img )
|
119
167
|
end
|
120
168
|
alias_method :flip_vertically, :mirror
|
121
|
-
alias_method :
|
169
|
+
alias_method :flip, :mirror ## note: chunky_png use flip alias for flip_horizontally (top-to-bottom)!!!!
|
170
|
+
alias_method :phlip, :mirror ## philip the intern ("hand-phlip one-by-one")
|
171
|
+
alias_method :hand_phlip, :mirror
|
122
172
|
|
123
173
|
|
124
174
|
def rotate_counter_clockwise # 90 degrees
|
data/lib/pixelart/version.rb
CHANGED
metadata
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pixelart
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gerald Bauer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-08-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: cocos
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
@@ -25,7 +25,7 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: pixelart-colors
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
@@ -39,7 +39,7 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: chunky_png
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
@@ -53,7 +53,7 @@ dependencies:
|
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: mini_magick
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - ">="
|