-
Notifications
You must be signed in to change notification settings - Fork 9
/
cell.cr
27 lines (22 loc) · 801 Bytes
/
cell.cr
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
require "./element"
module Termbox
# A cell is a coordinate with content and foreground/background colors
class Cell < Termbox::Element
getter :position, :char, :foreground, :background
# Make a cell with a specified foreground and background
def initialize(@char : Char, @position : Position, @foreground : Int32, @background : Int32)
end
# Make a cell with default colors
def initialize(char : Char, position : Position)
initialize(char, position, COLOR_NIL, COLOR_NIL)
end
# Make a new cell with a position transformed by x and y
def new_transform(x : Int32, y : Int32)
Cell.new(@char, @position.new_transform(x, y), @foreground, @background)
end
# Render as list of cells
def render : Array(Cell)
[self]
end
end
end