Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- func Blit(x, y, width int, cells []termbox.Cell) {
- tw, th := termbox.Size()
- height := len(cells) / width
- rw, rh := width, height
- offset := 0
- if x > tw || y > th {
- return
- }
- if x+width > tw {
- rw = tw - x
- }
- if x < 0 {
- rw += x
- offset = -x
- if offset > width {
- return
- }
- }
- if y+height > th {
- rh = th - y
- }
- if y < 0 {
- rh += y
- if rh <= 0 {
- return
- }
- y = 0
- }
- bb := termbox.CellBuffer()
- for i := 0; i < rh; i++ {
- copy(bb[(y+i)*tw+x+offset:], cells[i*width+offset:i*width+offset+rw])
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement