Class: Ucode::Glyphs::Grid
- Inherits:
-
Struct
- Object
- Struct
- Ucode::Glyphs::Grid
- Defined in:
- lib/ucode/glyphs/grid.rb
Instance Attribute Summary collapse
-
#block_first_cp ⇒ Object
Returns the value of attribute block_first_cp.
-
#column_pitch ⇒ Object
Returns the value of attribute column_pitch.
-
#columns ⇒ Object
Returns the value of attribute columns.
-
#origin_x ⇒ Object
Returns the value of attribute origin_x.
-
#origin_y ⇒ Object
Returns the value of attribute origin_y.
-
#row_pitch ⇒ Object
Returns the value of attribute row_pitch.
-
#rows ⇒ Object
Returns the value of attribute rows.
Instance Method Summary collapse
Instance Attribute Details
#block_first_cp ⇒ Object
Returns the value of attribute block_first_cp
5 6 7 |
# File 'lib/ucode/glyphs/grid.rb', line 5 def block_first_cp @block_first_cp end |
#column_pitch ⇒ Object
Returns the value of attribute column_pitch
5 6 7 |
# File 'lib/ucode/glyphs/grid.rb', line 5 def column_pitch @column_pitch end |
#columns ⇒ Object
Returns the value of attribute columns
5 6 7 |
# File 'lib/ucode/glyphs/grid.rb', line 5 def columns @columns end |
#origin_x ⇒ Object
Returns the value of attribute origin_x
5 6 7 |
# File 'lib/ucode/glyphs/grid.rb', line 5 def origin_x @origin_x end |
#origin_y ⇒ Object
Returns the value of attribute origin_y
5 6 7 |
# File 'lib/ucode/glyphs/grid.rb', line 5 def origin_y @origin_y end |
#row_pitch ⇒ Object
Returns the value of attribute row_pitch
5 6 7 |
# File 'lib/ucode/glyphs/grid.rb', line 5 def row_pitch @row_pitch end |
#rows ⇒ Object
Returns the value of attribute rows
5 6 7 |
# File 'lib/ucode/glyphs/grid.rb', line 5 def rows @rows end |
Instance Method Details
#cell_position(codepoint) ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/ucode/glyphs/grid.rb', line 12 def cell_position(codepoint) offset = codepoint - block_first_cp return nil if offset.negative? row, col = offset.divmod(columns) return nil if row >= rows [origin_x + (col * column_pitch), origin_y + (row * row_pitch)] end |
#codepoint_at(row, col) ⇒ Object
22 23 24 25 26 27 |
# File 'lib/ucode/glyphs/grid.rb', line 22 def codepoint_at(row, col) return nil if row.negative? || row >= rows return nil if col.negative? || col >= columns block_first_cp + (row * columns) + col end |