backgrounds 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Manifest.txt +3 -0
- data/Rakefile +3 -2
- data/config/spritesheet-24x24.csv +14 -0
- data/config/spritesheet-24x24.png +0 -0
- data/lib/backgrounds/image.rb +68 -0
- data/lib/backgrounds/version.rb +6 -3
- data/lib/backgrounds.rb +14 -23
- metadata +18 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ef9525f2d62a95bfe870dc67de9dac2da261841552f6125fe82b97b5c63605eb
|
4
|
+
data.tar.gz: 14cf97d01d360c1cc839a5eb2230a3100c5cde2e8a876a4df85f9f4ddbcd1729
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f592ad164a6e94f6644a3a6ddd1fadda9189f37e9dea4dab044f6ca06b60daf921ab57c6ae61238c7db0e387085329474e1044573df5cbf3ad2a3bfa131b73c7
|
7
|
+
data.tar.gz: 7eae74af8cba9636b9ef5f8b9d0b3c26986ef1535184c27ec8b2f4306c228dbc9e48cf18e54a722f9a2306df5cff189cd1b81d5023f87c1debc09dd8fda36763
|
data/Manifest.txt
CHANGED
data/Rakefile
CHANGED
@@ -11,7 +11,7 @@ end
|
|
11
11
|
|
12
12
|
Hoe.spec 'backgrounds' do
|
13
13
|
|
14
|
-
self.version = Backgrounds::VERSION
|
14
|
+
self.version = Pixelart::Module::Backgrounds::VERSION
|
15
15
|
|
16
16
|
self.summary = "backgrounds - generate your own unique pixel art background images (off chain) from text attributes (via built-in spritesheets); incl. color stripes, gradients, and more"
|
17
17
|
self.description = summary
|
@@ -26,7 +26,8 @@ Hoe.spec 'backgrounds' do
|
|
26
26
|
self.history_file = 'CHANGELOG.md'
|
27
27
|
|
28
28
|
self.extra_deps = [
|
29
|
-
['pixelart',
|
29
|
+
['pixelart', '>= 1.3.1'],
|
30
|
+
['spritesheet', '>= 1.0.1'],
|
30
31
|
]
|
31
32
|
|
32
33
|
self.licenses = ['Public Domain']
|
@@ -0,0 +1,14 @@
|
|
1
|
+
id, category, name, more_names
|
2
|
+
0, , Backenza Pattern, Backenza
|
3
|
+
1, , Colorful Pattern, Colurful
|
4
|
+
2, , Matrix 1 Pattern, Matrix 1
|
5
|
+
3, , Matrix 2 Pattern, Matrix 2
|
6
|
+
4, , Matrix 3 Pattern, Matrix 3
|
7
|
+
5, , Midnight Pattern, Midnight
|
8
|
+
6, , Purple Pattern,
|
9
|
+
7, , Snowy Pattern, Snowy
|
10
|
+
8, , Swamp Pattern, Swamp
|
11
|
+
9, , Rainbow 1,
|
12
|
+
10, , Rainbow 2,
|
13
|
+
11, , Rainbow 3,
|
14
|
+
12, , Rainbow 4,
|
Binary file
|
@@ -0,0 +1,68 @@
|
|
1
|
+
module Pixelart
|
2
|
+
module Background ## note: uses singular Background (no plural s here)
|
3
|
+
|
4
|
+
|
5
|
+
SPRITESHEETS = {
|
6
|
+
'24x24' => SpriteSheet.read( "#{Pixelart::Module::Backgrounds.root}/config/spritesheet-24x24.png",
|
7
|
+
"#{Pixelart::Module::Backgrounds.root}/config/spritesheet-24x24.csv",
|
8
|
+
width: 24, height: 24 )
|
9
|
+
}
|
10
|
+
|
11
|
+
|
12
|
+
class Image < Pixelart::Image
|
13
|
+
def self.generate( *values,
|
14
|
+
width:,
|
15
|
+
height: )
|
16
|
+
|
17
|
+
## check if spritesheet w/ patterns is available for width x height (eg.24x24)
|
18
|
+
sheet = SPRITESHEETS[ "#{width}x#{height}" ]
|
19
|
+
|
20
|
+
img = new( width, height )
|
21
|
+
img = do_parse( img, *values, sheet: sheet )
|
22
|
+
img
|
23
|
+
end # method Image.generate
|
24
|
+
|
25
|
+
##
|
26
|
+
## todo - what syntax to use for stripe/stripes ??
|
27
|
+
## or for gradient/gradients ??
|
28
|
+
## stripe( color1 color2 ) ??
|
29
|
+
## gradient( color1 color2 )
|
30
|
+
def self.do_parse( img, *values, sheet: )
|
31
|
+
head = values[0]
|
32
|
+
more = values[1..-1]
|
33
|
+
|
34
|
+
while head do
|
35
|
+
img = do_generate( img, head, sheet: sheet )
|
36
|
+
|
37
|
+
head = more[0]
|
38
|
+
more = more[1..-1]
|
39
|
+
end
|
40
|
+
img
|
41
|
+
end
|
42
|
+
|
43
|
+
|
44
|
+
def self.do_generate( img, value, sheet: )
|
45
|
+
if value.is_a?( String )
|
46
|
+
if ['ua','ukraine'].include?( value.downcase )
|
47
|
+
img.ukraine
|
48
|
+
elsif ['pride','rainbow'].include?( value.downcase )
|
49
|
+
img.pride
|
50
|
+
elsif sheet && pattern=sheet.find_by( name: value ) ## try some built-in background patterns
|
51
|
+
img.compose!( pattern )
|
52
|
+
img
|
53
|
+
else ### assume color
|
54
|
+
img.compose!( Image.new( img.width, img.height, value ) )
|
55
|
+
img
|
56
|
+
end
|
57
|
+
elsif value.is_a?( Pixelart::Image )
|
58
|
+
img.compose!( value )
|
59
|
+
img
|
60
|
+
else ### assume integer (assert) - why? why not
|
61
|
+
img.compose!( Image.new( img.width, img.height, value ) )
|
62
|
+
img
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
end # class Image
|
67
|
+
end # module Background
|
68
|
+
end # module Pixelart
|
data/lib/backgrounds/version.rb
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
|
2
|
-
|
2
|
+
module Pixelart
|
3
|
+
module Module
|
3
4
|
module Backgrounds
|
4
5
|
|
5
6
|
MAJOR = 0
|
6
|
-
MINOR =
|
7
|
-
PATCH =
|
7
|
+
MINOR = 1
|
8
|
+
PATCH = 0
|
8
9
|
VERSION = [MAJOR,MINOR,PATCH].join('.')
|
9
10
|
|
10
11
|
def self.version
|
@@ -20,4 +21,6 @@ module Backgrounds
|
|
20
21
|
end
|
21
22
|
|
22
23
|
end # module Backgrounds
|
24
|
+
end # module Module
|
25
|
+
end # module Pixelart
|
23
26
|
|
data/lib/backgrounds.rb
CHANGED
@@ -1,36 +1,27 @@
|
|
1
1
|
## 3rd party
|
2
2
|
require 'pixelart/base'
|
3
|
-
|
3
|
+
require 'spritesheet'
|
4
4
|
|
5
5
|
|
6
6
|
## our own code
|
7
7
|
require 'backgrounds/version' # note: let version always go first
|
8
|
-
|
9
|
-
|
10
|
-
## forward define superclass for image
|
11
|
-
module Backgrounds
|
12
|
-
class Image < Pixelart::Image; end
|
13
|
-
end
|
14
|
-
|
15
|
-
###
|
16
|
-
## add convenience pre-configurated generatored with build-in spritesheet (see config)
|
17
|
-
|
18
|
-
module Backgrounds
|
19
|
-
|
20
|
-
end # module Backgrounds
|
21
|
-
|
22
|
-
|
23
|
-
### add some convenience shortcuts
|
24
|
-
## add singular too -why? why not?
|
25
|
-
Background = Backgrounds
|
8
|
+
require 'backgrounds/image'
|
26
9
|
|
27
10
|
|
28
11
|
|
29
12
|
|
30
|
-
|
31
|
-
|
32
|
-
|
13
|
+
module Pixelart
|
14
|
+
class Image
|
15
|
+
def background( *values )
|
16
|
+
img = Background::Image.generate( *values,
|
17
|
+
width: @img.width,
|
18
|
+
height: @img.height )
|
19
|
+
img.compose!( self )
|
20
|
+
img # note: return new image
|
21
|
+
end
|
22
|
+
end # class Image
|
23
|
+
end # module Pixelart
|
33
24
|
|
34
25
|
|
35
26
|
|
36
|
-
puts Backgrounds.banner # say hello
|
27
|
+
puts Pixelart::Module::Backgrounds.banner # say hello
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: backgrounds
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gerald Bauer
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 1.3.1
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: spritesheet
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.0.1
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.0.1
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: rdoc
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -73,7 +87,10 @@ files:
|
|
73
87
|
- Manifest.txt
|
74
88
|
- README.md
|
75
89
|
- Rakefile
|
90
|
+
- config/spritesheet-24x24.csv
|
91
|
+
- config/spritesheet-24x24.png
|
76
92
|
- lib/backgrounds.rb
|
93
|
+
- lib/backgrounds/image.rb
|
77
94
|
- lib/backgrounds/version.rb
|
78
95
|
homepage: https://github.com/pixelartexchange/pixelart
|
79
96
|
licenses:
|