Diff
diff --git a/library/main.go b/library/main.go
index 45ce6ac..337e458 100644
--- a/library/main.go
+++ b/library/main.go
@@ -4 +3,0 @@ import (
- "fmt"
@@ -11,2 +10 @@ type Shelf struct {
- Textures map[string]image.Image
- Bounds map[string]Bounds
+ Textures map[string]image.RGBA
@@ -17,6 +15 @@ type Shelf struct {
-type Bounds struct {
- Width int
- Height int
-}
-
-func (s *Shelf) Set(key string, img image.Image) string {
+func (s *Shelf) Set(key string, img image.RGBA) string {
@@ -24 +17 @@ func (s *Shelf) Set(key string, img image.Image) string {
- s.Textures = map[string]image.Image{}
+ s.Textures = map[string]image.RGBA{}
@@ -29,5 +22 @@ func (s *Shelf) Set(key string, img image.Image) string {
- if s.Bounds == nil {
- s.Bounds = map[string]Bounds{}
- }
- b := img.Bounds()
- s.Bounds[key] = Bounds{Width: b.Dx(), Height: b.Dy()}
+
@@ -36 +24,0 @@ func (s *Shelf) Set(key string, img image.Image) string {
- fmt.Println("set",key)
@@ -40 +28 @@ func (s *Shelf) Set(key string, img image.Image) string {
-func (s *Shelf) Get(key string) (image.Image, bool) {
+func (s *Shelf) Get(key string) (*image.RGBA, bool) {
@@ -42,2 +30 @@ func (s *Shelf) Get(key string) (image.Image, bool) {
- s.Textures[key] = nil
- return a, exists
+ return &a, exists
@@ -55,4 +42,8 @@ func (s *Shelf) Check(key string) bool {
-func (s *Shelf) GetBounds(key string) (Bounds, bool) {
- b, exists := s.Bounds[key]
- // s.References[key] = true
- return b, exists
+func (s *Shelf) Bounds(key string) []int {
+ if _, exists := s.Textures[key]; exists {
+ img := s.Textures[key]
+ b := img.Bounds()
+ return []int{b.Dx(), b.Dy()}
+ } else {
+ return []int{0, 0}
+ }
@@ -63,3 +53,0 @@ func (s *Shelf) Delete(key string) {
- delete(s.Bounds, key)
- delete(s.References, key)
- fmt.Println("delete", key)
@@ -76,2 +63,0 @@ func (s *Shelf) Clean() {
- delete(s.Bounds, k)
- fmt.Println("clean",k)