Cell gets the region at the index i, updates and pulls from cache if need be
(index int)
| 119 | |
| 120 | // Cell gets the region at the index i, updates and pulls from cache if need be |
| 121 | func (s *Spritesheet) Cell(index int) Texture { |
| 122 | if r, ok := s.cache[index]; ok { |
| 123 | return r |
| 124 | } |
| 125 | |
| 126 | cell := s.cells[index] |
| 127 | s.cache[index] = Texture{ |
| 128 | id: s.texture, |
| 129 | width: float32(cell.Width), |
| 130 | height: float32(cell.Height), |
| 131 | viewport: engo.AABB{ |
| 132 | Min: engo.Point{ |
| 133 | X: cell.Position.X / s.width, |
| 134 | Y: cell.Position.Y / s.height, |
| 135 | }, |
| 136 | Max: engo.Point{ |
| 137 | X: (cell.Position.X + float32(cell.Width)) / s.width, |
| 138 | Y: (cell.Position.Y + float32(cell.Height)) / s.height, |
| 139 | }, |
| 140 | }, |
| 141 | } |
| 142 | |
| 143 | return s.cache[index] |
| 144 | } |
| 145 | |
| 146 | // Drawable returns the drawable for a given index |
| 147 | func (s *Spritesheet) Drawable(index int) Drawable { |
no outgoing calls
no test coverage detected