Class: RQRCodePNG::Image

Inherits:
Object
  • Object
show all
Defined in:
lib/rqrcode_png/image.rb

Constant Summary collapse

BLACK =
::ChunkyPNG::Color::BLACK
WHITE =
::ChunkyPNG::Color::WHITE
TRANSPARENT =
::ChunkyPNG::Color::TRANSPARENT

Instance Method Summary collapse

Constructor Details

#initialize(qr_code) ⇒ Image

Returns a new instance of Image.



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

def initialize(qr_code)
  @sequence = Sequence.new(qr_code)
end

Instance Method Details

#render(bg_color = WHITE) ⇒ Object

Returns an image file of the QR Code



12
13
14
15
16
17
18
# File 'lib/rqrcode_png/image.rb', line 12

def render bg_color = WHITE
  png = blank_img(bg_color)
  @sequence.dark_squares_only do |x, y|
    png[y + @sequence.border_width(), x + @sequence.border_width()] = BLACK
  end
  return png
end