Class: Cryptopunks::Image

Inherits:
Pixelart::Image
  • Object
show all
Defined in:
lib/cryptopunks.rb,
lib/cryptopunks.rb,
lib/cryptopunks.rb,
lib/cryptopunks/image.rb

Constant Summary collapse

Composite =
ImageComposite

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(initial = nil, design: nil, colors: nil) ⇒ Image

keep design & colors keyword args in c’tor here

or use parse() like in pixelart - why? why not?


17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/cryptopunks/image.rb', line 17

def initialize( initial=nil, design: nil,
                             colors: nil )
    if initial
      ## pass image through as-is
      img = initial
    else
      ## note: unwrap inner image before passing on to super c'tor
      img = Pixelart::Image.parse( design, colors: colors ).image
    end

    super( img.width, img.height, img )
end

Class Method Details

.generate(*values) ⇒ Object



52
53
54
55
56
# File 'lib/cryptopunks.rb', line 52

def self.generate( *values )
  img = Cryptopunks.generator.generate( *values )
  ## note: unwrap inner image before passing on to c'tor (requires ChunkyPNG image for now)
  new( img.image )
end

.read(path) ⇒ Object

convenience helper



7
8
9
10
# File 'lib/cryptopunks/image.rb', line 7

def self.read( path )   ## convenience helper
  img = ChunkyPNG::Image.from_file( path )
  new( img )
end