Sha256: c32ebe55d62aa7f6a68b82a6145e6e2b02eb2c19c33abed7a5d047a9d52ac593
Contents?: true
Size: 631 Bytes
Versions: 9
Compression:
Stored size: 631 Bytes
Contents
module Hershey class Word attr_reader :characters def initialize(text, options = {}) @spacing = 0 @characters = text.each_char.map do |c| char = Character.new(c, options) @spacing += char.spacing char end end def spacing @spacing ||= @characters.inject(0) {|memo, c| memo + c.spacing} end def to_path(current_offset) offset = 0 letters = [] @characters.each do |c| letters << c.to_path(offset) offset += c.spacing end %Q{<g transform="translate(#{current_offset},0)">#{letters.join}</g>} end end end
Version data entries
9 entries across 9 versions & 1 rubygems