pixelart 1.3.6 → 1.3.8

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: 92c0d22468eb46c7120b5cdfeeca63f0d4049bdfc055037186e05690e81f3404
4
- data.tar.gz: 1d5cb926059539d9bce964243a099307e1c03de5be9de7c5285bc76d54acb7cb
3
+ metadata.gz: a7ef9b53c8d7eddc68fd7bcc85283b85e041ade464d15408296f76ec7e79cc94
4
+ data.tar.gz: 87c43c6be85a868c83839ba75a4d569b1d655ccbdbf7382fe150cddeff63fc57
5
5
  SHA512:
6
- metadata.gz: 17a632b18859b6c341e5d80ecc91bdacff31037c3067efcda244d722515e70f8689613dbc205ed0e43300fdb5e5e36da70e079287adf7b4775041ca6ed3d1653
7
- data.tar.gz: 8fe33b806a59f408ce6666de365e13023175f87314b832cad3f196dc96f4c83aee37013ab554e30e015e2df621047a28091937506b03df1f09deef10773dc5e3
6
+ metadata.gz: 45b4afb06f3744d61677bbbf88f835dad19098ca128c9b0982bfa179677c44a7895d457b43e708da818666f14d58c2d029cd88e36224202d70de50a85c8632f2
7
+ data.tar.gz: 186929d319a497d1c93962f97722888f3b173318bfca0c12397eef0a988178ce2dde11d9b4da80ad4a7dede5344831fdab8fda61ac87f04a02919964edfdf14f
data/Manifest.txt CHANGED
@@ -10,6 +10,7 @@ lib/pixelart/composite.rb
10
10
  lib/pixelart/convert.rb
11
11
  lib/pixelart/generator.rb
12
12
  lib/pixelart/image.rb
13
+ lib/pixelart/invert.rb
13
14
  lib/pixelart/led.rb
14
15
  lib/pixelart/misc.rb
15
16
  lib/pixelart/pixelator.rb
data/README.md CHANGED
@@ -1,10 +1,10 @@
1
1
  # Pixel Art
2
2
 
3
- pixelart - mint your own pixel art images off chain using any design (in ascii text) in any colors; incl. 2x/4x/8x zoom for bigger sizes
3
+ pixelart - yes, you can! generate your own pixel art images (off-blockchain) using any design (in ascii text) in any colors; incl. 2x/4x/8x zoom for bigger sizes
4
4
 
5
5
 
6
- * home :: [github.com/pixelartexchange/pixelart](https://github.com/pixelartexchange/pixelart)
7
- * bugs :: [github.com/pixelartexchange/pixelart/issues](https://github.com/pixelartexchange/pixelart/issues)
6
+ * home :: [github.com/learnpixelart/pixelart](https://github.com/learnpixelart/pixelart)
7
+ * bugs :: [github.com/learnpixelart/pixelart/issues](https://github.com/learnpixelart/pixelart/issues)
8
8
  * gem :: [rubygems.org/gems/pixelart](https://rubygems.org/gems/pixelart)
9
9
  * rdoc :: [rubydoc.info/gems/pixelart](http://rubydoc.info/gems/pixelart)
10
10
 
@@ -71,8 +71,8 @@ img3x.save( './i/mooncat_white-3x.png' )
71
71
 
72
72
  Voila!
73
73
 
74
- ![](https://github.com/pixelartexchange/pixelart/raw/master/pixelart/i/mooncat_white.png)
75
- ![](https://github.com/pixelartexchange/pixelart/raw/master/pixelart/i/mooncat_white-3x.png)
74
+ ![](https://github.com/learnpixelart/pixelart/raw/master/pixelart/i/mooncat_white.png)
75
+ ![](https://github.com/learnpixelart/pixelart/raw/master/pixelart/i/mooncat_white-3x.png)
76
76
 
77
77
 
78
78
 
@@ -100,8 +100,8 @@ img3x.save( './i/mooncat_black-3x.png' )
100
100
 
101
101
  Voila! Black is the new White!
102
102
 
103
- ![](https://github.com/pixelartexchange/pixelart/raw/master/pixelart/i/mooncat_black.png)
104
- ![](https://github.com/pixelartexchange/pixelart/raw/master/pixelart/i/mooncat_black-3x.png)
103
+ ![](https://github.com/learnpixelart/pixelart/raw/master/pixelart/i/mooncat_black.png)
104
+ ![](https://github.com/learnpixelart/pixelart/raw/master/pixelart/i/mooncat_black-3x.png)
105
105
 
106
106
 
107
107
 
@@ -227,8 +227,8 @@ img5x.save( './i/vader5x.png' )
227
227
 
228
228
  Voila!
229
229
 
230
- ![](https://github.com/pixelartexchange/pixelart/raw/master/pixelart/i/vader.png)
231
- ![](https://github.com/pixelartexchange/pixelart/raw/master/pixelart/i/vader5x.png)
230
+ ![](https://github.com/learnpixelart/pixelart/raw/master/pixelart/i/vader.png)
231
+ ![](https://github.com/learnpixelart/pixelart/raw/master/pixelart/i/vader5x.png)
232
232
 
233
233
 
234
234
 
@@ -291,6 +291,9 @@ Use it as you please with no restrictions whatsoever.
291
291
 
292
292
 
293
293
 
294
+
294
295
  ## Questions? Comments?
295
296
 
296
- Post them on the [D.I.Y. Punk (Pixel) Art reddit](https://old.reddit.com/r/DIYPunkArt). Thanks.
297
+ Post them over at the [Help & Support](https://github.com/geraldb/help) page. Thanks.
298
+
299
+
data/Rakefile CHANGED
@@ -5,13 +5,13 @@ Hoe.spec 'pixelart' do
5
5
 
6
6
  self.version = Pixelart::VERSION
7
7
 
8
- self.summary = "pixelart - mint your own pixel art images off chain using any design (in ascii text) in any colors; incl. 2x/4x/8x zoom for bigger sizes"
8
+ self.summary = "pixelart - yes, you can! generate your own pixel art images (off-blockchain) using any design (in ascii text) in any colors; incl. 2x/4x/8x zoom for bigger sizes"
9
9
  self.description = summary
10
10
 
11
- self.urls = { home: 'https://github.com/pixelartexchange/pixelart' }
11
+ self.urls = { home: 'https://github.com/learnpixelart/pixelart' }
12
12
 
13
13
  self.author = 'Gerald Bauer'
14
- self.email = 'wwwmake@googlegroups.com'
14
+ self.email = 'gerald.bauer@gmail.com'
15
15
 
16
16
  # switch extension to .markdown for gihub formatting
17
17
  self.readme_file = 'README.md'
data/lib/pixelart/base.rb CHANGED
@@ -42,6 +42,7 @@ require 'pixelart/led'
42
42
  require 'pixelart/sketch'
43
43
  require 'pixelart/transparent'
44
44
  require 'pixelart/silhouette'
45
+ require 'pixelart/invert'
45
46
  require 'pixelart/ukraine'
46
47
 
47
48
 
@@ -69,4 +70,5 @@ require 'pixelart/convert'
69
70
 
70
71
 
71
72
 
73
+
72
74
  puts Pixelart.banner # say hello
@@ -10,7 +10,7 @@ class ImageComposite < Image # check: (re)name to Collage, Sheet, Sprites, or s
10
10
  def self.read( path, width: TILE_WIDTH, height: TILE_WIDTH ) ## convenience helper
11
11
  img = ChunkyPNG::Image.from_file( path )
12
12
  new( img, width: width,
13
- height: width )
13
+ height: height )
14
14
  end
15
15
 
16
16
 
@@ -36,15 +36,18 @@ def self.convert( dir, from: 'jpg',
36
36
  system( cmd )
37
37
 
38
38
  if from == 'gif'
39
- ## assume multi-images for gif
39
+ ## check for multi-images for gif
40
40
  ## save image-0.png to image.png
41
41
  path0 = "#{outdir}/#{basename}-0.#{to}"
42
42
  path = "#{outdir}/#{basename}.#{to}"
43
43
 
44
- puts " saving #{path0} to #{path}..."
44
+ ## note: image-0.png only exists (gets generated) for multi-images
45
+ if File.exist?( path0 )
46
+ puts " saving #{path0} to #{path}..."
45
47
 
46
- blob = File.open( path0, 'rb' ) { |f| f.read }
47
- File.open( path, 'wb' ) { |f| f.write( blob ) }
48
+ blob = File.open( path0, 'rb' ) { |f| f.read }
49
+ File.open( path, 'wb' ) { |f| f.write( blob ) }
50
+ end
48
51
  end
49
52
  end
50
53
  end
@@ -51,7 +51,9 @@ CHARS = '.@xo^~%*+=:' ## todo/check: rename to default chars or such? why? w
51
51
 
52
52
  ## todo/check: support default chars encoding auto-of-the-box always
53
53
  ## or require user-defined chars to be passed in - why? why not?
54
- def self.parse( pixels, colors:, chars: CHARS )
54
+ def self.parse( pixels, colors:,
55
+ background: Color::TRANSPARENT,
56
+ chars: CHARS )
55
57
  has_keys = colors.is_a?(Hash) ## check if passed-in user-defined keys (via hash table)?
56
58
 
57
59
  colors = parse_colors( colors )
@@ -60,6 +62,8 @@ def self.parse( pixels, colors:, chars: CHARS )
60
62
  width = pixels.reduce(1) {|width,row| row.size > width ? row.size : width }
61
63
  height = pixels.size
62
64
 
65
+ background = Color.parse( background ) unless background.is_a?( Integer )
66
+
63
67
  img = new( width, height )
64
68
 
65
69
  pixels.each_with_index do |row,y|
@@ -77,7 +81,13 @@ def self.parse( pixels, colors:, chars: CHARS )
77
81
  end
78
82
  end
79
83
 
80
- img[x,y] = pixel
84
+
85
+ img[x,y] = if background && background != Color::TRANSPARENT &&
86
+ pixel == Color::TRANSPARENT
87
+ background ## note: auto-fill transparent with background color
88
+ else
89
+ pixel
90
+ end
81
91
  end # each row
82
92
  end # each data
83
93
 
@@ -311,17 +321,28 @@ def image() @img; end
311
321
  ######
312
322
  # helpers
313
323
  def self.parse_pixels( pixels )
314
- data = []
315
- pixels.each_line do |line|
316
- line = line.strip
317
- next if line.start_with?( '#' ) || line.empty? ## note: allow comments and empty lines
318
-
319
- ## note: allow multiple spaces or tabs to separate pixel codes
320
- ## e.g. o o o o o o o o o o o o dg lg w w lg w lg lg dg dg w w lg dg o o o o o o o o o o o
321
- ## or
322
- data << line.split( /[ \t]+/)
323
- end
324
- data
324
+ if pixels.is_a?( Array ) ## assume array of string (lines)
325
+ data = []
326
+ pixels.each do |line|
327
+ ## convert (string) line into indidual chars
328
+ data << line.each_char.reduce( [] ) { |mem, c| mem << c; mem }
329
+ end
330
+ data
331
+ else ## assume it's a (multi-line) string (with newlines)
332
+ ## assert and throw ArgumentError if not? - why? why not?
333
+ data = []
334
+ pixels.each_line do |line|
335
+ line = line.strip
336
+ next if line.start_with?( '#' ) || line.empty? ## note: allow comments and empty lines
337
+
338
+ ## note: allow multiple spaces or tabs
339
+ ## to separate pixel codes
340
+ ## e.g. o o o o o o o o o o o o dg lg w w lg w lg lg dg dg w w lg dg o o o o o o o o o o o
341
+ ## or
342
+ data << line.split( /[ \t]+/)
343
+ end
344
+ data
345
+ end
325
346
  end
326
347
 
327
348
 
@@ -0,0 +1,40 @@
1
+ module Pixelart
2
+
3
+
4
+ ## todo/check:
5
+ ## use a different name for invert
6
+ ## - why not - negate ???
7
+
8
+
9
+ class Image
10
+ ## note: invert will only invert r/g/b - and NOT the a(lpha) channel
11
+ ## the a(lpha) channel get passed on as is (1:1)
12
+ def invert
13
+ img = Image.new( @img.width, @img.height )
14
+
15
+ @img.width.times do |x|
16
+ @img.height.times do |y|
17
+ pixel = @img[x,y]
18
+
19
+ ## note: xor (^) with 0 returns the original value unmodified.
20
+ ## xor (^) with 0xff flips the bits.
21
+ ## that is we are flipping/inverting r, g and b.
22
+ ## and keep the a(lpha) channel as is.
23
+
24
+ ## hack - why? why not?
25
+ ## if transparent e.g. 0x0 than keep as is
26
+ ## do not use 0xffffff00 - makes a difference?
27
+
28
+ img[x,y] = if pixel == Color::TRANSPARENT # transparent (0)
29
+ Color::TRANSPARENT
30
+ else
31
+ pixel ^ 0xffffff00
32
+ end
33
+ end
34
+ end
35
+ img
36
+ end
37
+
38
+ end # class Image
39
+
40
+ end # module Pixelart
@@ -3,14 +3,24 @@ module Pixelart
3
3
 
4
4
 
5
5
  class Image
6
- def sketch( sketch=4, line: 1 )
6
+ def sketch( sketch=4, line: 1,
7
+ line_color: Color::BLACK,
8
+ colorize: false )
9
+ ## todo/check: rename color option to fill or such - why? why not?
10
+
7
11
  # todo: line - find a better name eg. line_strenght/width or such?
8
12
  width = @img.width*sketch + (@img.width+1)*line
9
13
  height = @img.height*sketch + (@img.height+1)*line
10
14
 
11
15
  puts " #{width}x#{height}"
12
16
 
13
- img = Image.new( width, height, Color::WHITE )
17
+
18
+ background_color = colorize ? Color::TRANSPARENT
19
+ : Color::WHITE
20
+
21
+
22
+ img = Image.new( width, height, background_color )
23
+
14
24
 
15
25
  @img.width.times do |x|
16
26
  @img.height.times do |y|
@@ -19,12 +29,13 @@ class Image
19
29
  ## get surrounding pixels - if "out-of-bound" use transparent (0)
20
30
  left = x == 0 ? Color::TRANSPARENT : @img[x-1,y]
21
31
  top = y == 0 ? Color::TRANSPARENT : @img[x ,y-1]
32
+ diag = (x==0 || y== 0) ? Color::TRANSPARENT : @img[x-1,y-1]
22
33
 
23
34
  if pixel != left ## draw vertical line
24
- (sketch+line*2).times do |n|
25
- line.times do |m|
26
- img[ x*sketch + line*x + m,
27
- n + y*sketch + line*y] = Color::BLACK
35
+ line.times do |n|
36
+ (sketch+line*2).times do |m|
37
+ img[ x*sketch + line*x + n,
38
+ m + y*sketch + line*y] = line_color
28
39
  end
29
40
  end
30
41
  end
@@ -33,7 +44,7 @@ class Image
33
44
  (sketch+line*2).times do |n|
34
45
  line.times do |m|
35
46
  img[n + x*sketch + line*x,
36
- y*sketch + line*y + m] = Color::BLACK
47
+ y*sketch + line*y + m] = line_color
37
48
  end
38
49
  end
39
50
  end
@@ -42,10 +53,10 @@ class Image
42
53
  ## check special edge case for x and y to add "finish-up" right and bottom line
43
54
  if x == @img.width-1 && pixel != Color::TRANSPARENT
44
55
  ## draw vertical line
45
- (sketch+line*2).times do |n|
46
- line.times do |m|
47
- img[ (x+1)*sketch + line*(x+1) + m,
48
- n + y*sketch + line*y] = Color::BLACK
56
+ line.times do |n|
57
+ (sketch+line*2).times do |m|
58
+ img[ (x+1)*sketch + line*(x+1) + n,
59
+ m + y*sketch + line*y] = line_color
49
60
  end
50
61
  end
51
62
  end
@@ -55,12 +66,56 @@ class Image
55
66
  (sketch+line*2).times do |n|
56
67
  line.times do |m|
57
68
  img[n + x*sketch + line*x,
58
- (y+1)*sketch + line*(y+1) + m] = Color::BLACK
69
+ (y+1)*sketch + line*(y+1) + m] = line_color
59
70
  end
60
71
  end
61
72
  end
62
- end
63
- end
73
+
74
+ ###############
75
+ ## fill with pixel color if color true (default is false)
76
+ if colorize && pixel != Color::TRANSPARENT
77
+ sketch.times do |n|
78
+ sketch.times do |m|
79
+ img[x*sketch + line*(x+1) + n,
80
+ y*sketch + line*(y+1) + m] = pixel
81
+ end
82
+ end
83
+
84
+ if pixel == left ## draw vertical line
85
+ line.times do |n|
86
+ sketch.times do |m|
87
+ img[x*sketch + line*x + n,
88
+ y*sketch + line*(y+1) + m] = pixel
89
+ # (y%2==0 ? 0x0000ffff : 0x000088ff ) # (for debugging)
90
+ end
91
+ end
92
+ end
93
+
94
+ if pixel == top ## draw horizontal line
95
+ sketch.times do |n|
96
+ line.times do |m|
97
+ img[x*sketch + line*(x+1) + n,
98
+ y*sketch + line*y + m] = pixel
99
+ # (x%2==0 ? 0xff0000ff : 0x880000ff ) # (for debugging)
100
+ end
101
+ end
102
+ end
103
+
104
+ ## check all four same color (00,01)
105
+ ## (10, x) - bingo!
106
+ if pixel == left && pixel == top && pixel == diag
107
+ line.times do |n|
108
+ line.times do |m|
109
+ img[x*sketch + line*x + n,
110
+ y*sketch + line*y + m] = pixel
111
+ # 0xffff00ff # (for debugging)
112
+ end
113
+ end
114
+ end
115
+ end # colorize?
116
+
117
+ end # height.times
118
+ end # width.times
64
119
 
65
120
  img
66
121
  end
@@ -3,7 +3,7 @@ module Pixelart
3
3
 
4
4
  MAJOR = 1
5
5
  MINOR = 3
6
- PATCH = 6
6
+ PATCH = 8
7
7
  VERSION = [MAJOR,MINOR,PATCH].join('.')
8
8
 
9
9
  def self.version
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.3.6
4
+ version: 1.3.8
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-08-17 00:00:00.000000000 Z
11
+ date: 2023-06-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cocos
@@ -100,9 +100,9 @@ dependencies:
100
100
  - - "~>"
101
101
  - !ruby/object:Gem::Version
102
102
  version: '3.23'
103
- description: pixelart - mint your own pixel art images off chain using any design
104
- (in ascii text) in any colors; incl. 2x/4x/8x zoom for bigger sizes
105
- email: wwwmake@googlegroups.com
103
+ description: pixelart - yes, you can! generate your own pixel art images (off-blockchain)
104
+ using any design (in ascii text) in any colors; incl. 2x/4x/8x zoom for bigger sizes
105
+ email: gerald.bauer@gmail.com
106
106
  executables: []
107
107
  extensions: []
108
108
  extra_rdoc_files:
@@ -122,6 +122,7 @@ files:
122
122
  - lib/pixelart/convert.rb
123
123
  - lib/pixelart/generator.rb
124
124
  - lib/pixelart/image.rb
125
+ - lib/pixelart/invert.rb
125
126
  - lib/pixelart/led.rb
126
127
  - lib/pixelart/misc.rb
127
128
  - lib/pixelart/pixelator.rb
@@ -134,7 +135,7 @@ files:
134
135
  - lib/pixelart/ukraine.rb
135
136
  - lib/pixelart/vector.rb
136
137
  - lib/pixelart/version.rb
137
- homepage: https://github.com/pixelartexchange/pixelart
138
+ homepage: https://github.com/learnpixelart/pixelart
138
139
  licenses:
139
140
  - Public Domain
140
141
  metadata: {}
@@ -158,6 +159,6 @@ requirements: []
158
159
  rubygems_version: 3.3.7
159
160
  signing_key:
160
161
  specification_version: 4
161
- summary: pixelart - mint your own pixel art images off chain using any design (in
162
- ascii text) in any colors; incl. 2x/4x/8x zoom for bigger sizes
162
+ summary: pixelart - yes, you can! generate your own pixel art images (off-blockchain)
163
+ using any design (in ascii text) in any colors; incl. 2x/4x/8x zoom for bigger sizes
163
164
  test_files: []