sanity check tests.

This commit is contained in:
Will Charczuk 2017-03-05 16:52:34 -08:00
parent 10950a3bf2
commit 8b34cb3bd7
8 changed files with 138 additions and 35 deletions

View file

@ -104,6 +104,16 @@ func (c Color) Equals(other Color) bool {
c.A == other.A
}
// AverageWith averages two colors.
func (c Color) AverageWith(other Color) Color {
return Color{
R: (c.R + other.R) >> 1,
G: (c.G + other.G) >> 1,
B: (c.B + other.B) >> 1,
A: c.A,
}
}
// String returns a css string representation of the color.
func (c Color) String() string {
fa := float64(c.A) / float64(255)

View file

@ -1,23 +0,0 @@
package drawing
import "image"
// Image is a helper wraper that allows (sane) access to pixel info.
type Image struct {
Inner *image.RGBA
}
// Width returns the image's width in pixels.
func (i Image) Width() int {
return i.Inner.Rect.Size().X
}
// Height returns the image's height in pixels.
func (i Image) Height() int {
return i.Inner.Rect.Size().Y
}
// At returns a pixel color at a given x/y.
func (i Image) At(x, y int) Color {
return ColorFromAlphaMixedRGBA(i.Inner.At(x, y).RGBA())
}