backgrounds 0.0.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8f62ccfe8a89aa93902d2aea2911c3a9e580ea3f4bd23c8277a550d5acb7754f
4
- data.tar.gz: eb4ba8feed49159128e6fe1c1c52a45203c70a7407e1791d4a20f8eace5f2e07
3
+ metadata.gz: 14d98f76de79e232de2a25cfca5ae7376c8d2649d138fbe9b15a328a119dd979
4
+ data.tar.gz: 62b22da720a8635701eeec4203f9994c537aef5ccf1a4f5508be5932f279f729
5
5
  SHA512:
6
- metadata.gz: f6ceff50a9273953ac241808b92862b6254a10eaf98048c3539d6533da0b5614ebfd5fe48f032b2cf5553f973ddfcedfd2c55c5a7bda60a719a05b5a674cf983
7
- data.tar.gz: 34153a7df201740a50bedc87502d6a8dff745bf1644067f4d27d9e7acc8a8ed27eb275194a84590d879498bdf53a71d925ec669d7ac0bdd4f53e89a2773aef12
6
+ metadata.gz: 8a3c867dc78df7092b8bf50e51b9b101f1a26ac75ed13b463f364e3dd801da2920e237ed5c6316afa8fee02765a8b81a371ff7b5a5e87f31f49bb6bf37fd375d
7
+ data.tar.gz: 8f6a3d4e1245d215024dd8069a7255c14afdde6eb9cb860dd56332c4b0284b9537fa495f746eea9667a9bbd36f480ebcff6763d504d76934ce46ce9dc7e3066e
data/Manifest.txt CHANGED
@@ -2,5 +2,11 @@ CHANGELOG.md
2
2
  Manifest.txt
3
3
  README.md
4
4
  Rakefile
5
+ config/spritesheet-24x24.csv
6
+ config/spritesheet-24x24.png
7
+ config/spritesheet-32x32.csv
8
+ config/spritesheet-32x32.png
5
9
  lib/backgrounds.rb
10
+ lib/backgrounds/base.rb
11
+ lib/backgrounds/image.rb
6
12
  lib/backgrounds/version.rb
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', '>= 1.3.1'],
29
+ ['pixelart', '>= 1.3.2'],
30
+ ['spritesheet', '>= 1.1.0'],
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,45 @@
1
+ id, category, name, more_names
2
+ 0, , metropolis_1,
3
+ 1, , metropolis_2,
4
+ 2, , codelines,
5
+ 3, , sun,
6
+ 4, , beam,
7
+ 5, , green_tie_dye,
8
+ 6, , orange_tie_dye,
9
+ 7, , purple_tie_dye,
10
+ 8, , yellow_diag,
11
+ 9, , green_diag,
12
+ 10, , blue_diag,
13
+ 11, , pink_diag,
14
+ 12, , yellow_pink_diag,
15
+ 13, , green_black_diag,
16
+ 14, , black_orange_diag,
17
+ 15, , blue_orange_diag,
18
+ 16, , purple_green_diag,
19
+ 17, , purple_orange_diag,
20
+ 18, , green_blue_vert,
21
+ 19, , peach_blue_vert,
22
+ 20, , green_stripe,
23
+ 21, , purple_stripe,
24
+ 22, , candy_stripe,
25
+ 23, , yellow_double_stripe,
26
+ 24, , green_double_stripe,
27
+ 25, , double_yellow,
28
+ 26, , double_green,
29
+ 27, , double_pink,
30
+ 28, , double_purple,
31
+ 29, , triple_green,
32
+ 30, , triple_blue,
33
+ 31, , triple_pink,
34
+ 32, , yellow_solid,
35
+ 33, , green_solid,
36
+ 34, , blue_solid,
37
+ 35, , light_blue_solid,
38
+ 36, , dark_purple_solid,
39
+ 37, , magenta_solid,
40
+ 38, , purple_solid,
41
+ 39, , pink_solid,
42
+ 40, , peach_solid,
43
+ 41, , orange_solid,
44
+ 42, , red_solid,
45
+ 43, , grey_solid,
Binary file
@@ -0,0 +1,27 @@
1
+ ## 3rd party
2
+ require 'pixelart/base'
3
+ require 'spritesheet/base'
4
+
5
+
6
+ ## our own code
7
+ require 'backgrounds/version' # note: let version always go first
8
+ require 'backgrounds/image'
9
+
10
+
11
+
12
+
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
24
+
25
+
26
+
27
+ puts Pixelart::Module::Backgrounds.banner # say hello
@@ -0,0 +1,74 @@
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
+ '32x32' => SpriteSheet.read( "#{Pixelart::Module::Backgrounds.root}/config/spritesheet-32x32.png",
10
+ "#{Pixelart::Module::Backgrounds.root}/config/spritesheet-32x32.csv",
11
+ width: 32, height: 32 ),
12
+ }
13
+
14
+
15
+ class Image < Pixelart::Image
16
+ def self.generate( *values,
17
+ width:,
18
+ height: )
19
+
20
+ ## check if spritesheet w/ patterns is available for width x height (eg.24x24, 32x32, etc.)
21
+ sheet = SPRITESHEETS[ "#{width}x#{height}" ]
22
+
23
+ img = new( width, height )
24
+ img = do_parse( img, *values, sheet: sheet )
25
+ img
26
+ end # method Image.generate
27
+
28
+ ##
29
+ ## todo - what syntax to use for stripe/stripes ??
30
+ ## or for gradient/gradients ??
31
+ ## stripe( color1 color2 ) ??
32
+ ## gradient( color1 color2 )
33
+ def self.do_parse( img, *values, sheet: )
34
+ head = values[0]
35
+ more = values[1..-1]
36
+
37
+ while head do
38
+ img = do_generate( img, head, sheet: sheet )
39
+
40
+ head = more[0]
41
+ more = more[1..-1]
42
+ end
43
+ img
44
+ end
45
+
46
+
47
+ def self.do_generate( img, value, sheet: )
48
+ if value.is_a?( String )
49
+ key = Pixelart::Spritesheet.normalize_key( value )
50
+ if ['ua','ukraine',
51
+ 'saveukraine', 'standwithukraine',
52
+ 'glorytoukraine'].include?( key )
53
+ img.ukraine
54
+ elsif ['pride','rainbow'].include?( key )
55
+ img.pride
56
+ elsif sheet && pattern=sheet.find_by( name: value, warn: false ) ## try some built-in background patterns
57
+ img.compose!( pattern )
58
+ img
59
+ else ### assume (try) color
60
+ img.compose!( Image.new( img.width, img.height, value ) )
61
+ img
62
+ end
63
+ elsif value.is_a?( Pixelart::Image )
64
+ img.compose!( value )
65
+ img
66
+ else ### assume integer (assert) - why? why not
67
+ img.compose!( Image.new( img.width, img.height, value ) )
68
+ img
69
+ end
70
+ end
71
+
72
+ end # class Image
73
+ end # module Background
74
+ end # module Pixelart
@@ -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 = 0
7
- PATCH = 1
7
+ MINOR = 2
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,10 @@
1
- ## 3rd party
2
- require 'pixelart/base'
3
-
4
-
5
-
6
- ## our own code
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
26
-
27
-
1
+ ## our own code (without "top-level" shortcuts e.g. "modular version")
2
+ require 'backgrounds/base' # aka "strict(er)" version
28
3
 
29
4
 
30
5
  ###
31
- # note: for convenience auto include Pixelart namespace!!! - why? why not?
6
+ # add convenience top-level shortcuts / aliases
7
+ # make Image, Color, Palette8bit, etc top-level
32
8
  include Pixelart
33
9
 
34
10
 
35
-
36
- puts Backgrounds.banner # say hello
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: backgrounds
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.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: 2022-06-08 00:00:00.000000000 Z
11
+ date: 2022-06-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pixelart
@@ -16,14 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 1.3.1
19
+ version: 1.3.2
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 1.3.1
26
+ version: 1.3.2
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.1.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 1.1.0
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: rdoc
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -73,7 +87,13 @@ files:
73
87
  - Manifest.txt
74
88
  - README.md
75
89
  - Rakefile
90
+ - config/spritesheet-24x24.csv
91
+ - config/spritesheet-24x24.png
92
+ - config/spritesheet-32x32.csv
93
+ - config/spritesheet-32x32.png
76
94
  - lib/backgrounds.rb
95
+ - lib/backgrounds/base.rb
96
+ - lib/backgrounds/image.rb
77
97
  - lib/backgrounds/version.rb
78
98
  homepage: https://github.com/pixelartexchange/pixelart
79
99
  licenses: