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
- #max_depth ⇒ Object
- #pixel_of(value) ⇒ Object
- #pixel_of_color(color) ⇒ Object
- #transparent_pixel ⇒ Object
- #white_pixel ⇒ Object
Instance Method Details
#max_depth ⇒ Object
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_pixel ⇒ Object
15 16 17 |
# File 'lib/visual_qrcode/pixel_tools.rb', line 15 def transparent_pixel @transparent_pixel ||= [0] * 4 end |
#white_pixel ⇒ Object
19 20 21 |
# File 'lib/visual_qrcode/pixel_tools.rb', line 19 def white_pixel @white_pixel ||= [255] * 4 end |