1 package imagefn // import "vimagination.zapto.org/imagefn" 2 3 import ( 4 "image" 5 "image/color" 6 ) 7 8 type empty struct { 9 color.Model 10 Min image.Point 11 } 12 13 func newEmpty(i image.Image) image.Image { 14 e := empty{ 15 Model: i.ColorModel(), 16 Min: i.Bounds().Min, 17 } 18 19 if _, ok := i.(setter); ok { 20 return &emptySet{ 21 empty: e, 22 } 23 } 24 return &e 25 } 26 27 func (e empty) ColorModel() color.Model { 28 return e.Model 29 } 30 31 func (e empty) Bounds() image.Rectangle { 32 return image.Rectangle{e.Min, e.Min} 33 } 34 35 func (e empty) At(x, y int) color.Color { 36 return e.Model.Convert(color.Alpha{}) 37 } 38 39 type emptySet struct { 40 empty 41 } 42 43 func (emptySet) Set(_, _ int, _ color.Color) {} 44