class SugarPNG::Glyph

Attributes

data[RW]
height[RW]
ord[RW]
width[RW]

Public Class Methods

new(h = {}) click to toggle source
# File lib/sugar_png/glyph.rb, line 5
def initialize h = {}
  @ord    = h[:ord]
  @data   = h[:data]
  @width  = h[:width]
  @height = h[:height]
end

Public Instance Methods

blank?() click to toggle source
# File lib/sugar_png/glyph.rb, line 12
def blank?
  @data.tr("\x00","").empty?
end
to_a() click to toggle source
# File lib/sugar_png/glyph.rb, line 26
def to_a
  bytes_in_row = (@width/8.0).ceil
  r = []; ptr = 0
  @height.times.each do
    r << @data[ptr,bytes_in_row].unpack("B#@width")[0].split('').map(&:to_i)
    ptr += bytes_in_row
  end
  r
end
to_s(repl=" click to toggle source
# File lib/sugar_png/glyph.rb, line 16
def to_s repl=" #"
  bytes_in_row = (@width/8.0).ceil
  r = ''; ptr = 0
  @height.times.each do
    r += @data[ptr,bytes_in_row].unpack("B#@width")[0].tr("01",repl) + "\n"
    ptr += bytes_in_row
  end
  r.chomp
end