Module: PixelTools

Included in:
VisualQrcode::Export, VisualQrcode::PixelsHandler, VisualQrcode::Qrcode
Defined in:
lib/visual_qrcode/pixel_tools.rb

Constant Summary collapse

PIXEL_DEPTH =
8

Instance Method Summary collapse

Instance Method Details

#max_depthObject



6
7
8
# File 'lib/visual_qrcode/pixel_tools.rb', line 6

def max_depth
  @max_depth ||= (2**PIXEL_DEPTH) - 1
end

#pixel_of(value) ⇒ Object



10
11
12
13
# File 'lib/visual_qrcode/pixel_tools.rb', line 10

def pixel_of(value)
  pixel_value = value ? 0 : max_depth
  [pixel_value, pixel_value, pixel_value, max_depth]
end

#pixel_of_color(color) ⇒ Object



23
24
25
# File 'lib/visual_qrcode/pixel_tools.rb', line 23

def pixel_of_color(color)
  send(:"#{color}_pixel")
end

#transparent_pixelObject



15
16
17
# File 'lib/visual_qrcode/pixel_tools.rb', line 15

def transparent_pixel
  @transparent_pixel ||= [0] * 4
end

#white_pixelObject



19
20
21
# File 'lib/visual_qrcode/pixel_tools.rb', line 19

def white_pixel
  @white_pixel ||= [255] * 4
end