class RQRCodePNG::Image
Constants
- BLACK
- TRANSPARENT
- WHITE
Public Class Methods
new(qr_code)
click to toggle source
# File lib/rqrcode_png/image.rb, line 7 def initialize(qr_code) @sequence = Sequence.new(qr_code) end
Public Instance Methods
render(bg_color = WHITE)
click to toggle source
Returns an image file of the QR Code
# 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
Private Instance Methods
blank_img(bg_color = WHITE)
click to toggle source
Returns an appropriately sized, blank (white) image
# File lib/rqrcode_png/image.rb, line 28 def blank_img bg_color = WHITE ::ChunkyPNG::Image.new(img_size(), img_size(), bg_color) end
img_size()
click to toggle source
Returns the size of the image
# File lib/rqrcode_png/image.rb, line 23 def img_size() @img_size ||= @sequence.img_size() + @sequence.border_width() * 2 end