Module: Pixelart::Dollar
- Defined in:
- lib/punkart/dollar.rb
Overview
use/rename to Greenback - why? why not?
Constant Summary collapse
- DOLLAR_FRAME =
helpers
Image.read( "#{Module::Punkart.root}/config/dollar.png" )
- DOLLAR_PALETTE =
_gen_palette( '#536140' )
Class Method Summary collapse
- ._gen_palette(color) ⇒ Object
- .frame ⇒ Object
- .height ⇒ Object
- .palette ⇒ Object
- .print(img) ⇒ Object
- .width ⇒ Object
Class Method Details
._gen_palette(color) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/punkart/dollar.rb', line 26 def self._gen_palette( color ) color = Color.parse( color ) if color.is_a?( String ) h,s,l = Color.to_hsl( color ) pp h pp s pp l darker = 0.25 ## cut-off colors starting from black lighter = 0.05 ## cut-off colors starting from white ldiff = (1.0 - darker - lighter) puts " ldiff: #{ldiff}" colors = [] 256.times do |i| lnew = darker+(ldiff*i / 256.0) puts " #{i} - #{lnew}" colors << Color.from_hsl( h, s, lnew) end colors end |
.frame ⇒ Object
20 |
# File 'lib/punkart/dollar.rb', line 20 def self.frame() DOLLAR_FRAME; end |
.height ⇒ Object
22 |
# File 'lib/punkart/dollar.rb', line 22 def self.height() DOLLAR_FRAME.height; end |
.palette ⇒ Object
23 |
# File 'lib/punkart/dollar.rb', line 23 def self.palette() DOLLAR_PALETTE; end |
.print(img) ⇒ Object
5 6 7 8 9 10 11 12 13 |
# File 'lib/punkart/dollar.rb', line 5 def self.print( img ) raise ArgumentError, "sorry only 24x24 supported for now; called on image #{img.width}x#{img.height}" unless img.width == 24 && img.height == 24 ## change to greenback color palette dollar = Image.new( DOLLAR_FRAME.width, DOLLAR_FRAME.height ) dollar.compose!( DOLLAR_FRAME ) dollar.compose!( img.change_palette8bit( DOLLAR_PALETTE ), 16, 0 ) dollar end |
.width ⇒ Object
21 |
# File 'lib/punkart/dollar.rb', line 21 def self.width() DOLLAR_FRAME.width; end |