Rename *MatrixI -> New*Matrix

This commit is contained in:
Hajime Hoshi 2014-12-26 03:58:33 +09:00
parent f7b2157585
commit d53d55a629
6 changed files with 18 additions and 12 deletions

View File

@ -32,8 +32,8 @@ type ColorMatrix struct {
es [ColorMatrixDim - 1][ColorMatrixDim]float64 es [ColorMatrixDim - 1][ColorMatrixDim]float64
} }
// ColorMatrixI returns an identity color matrix. // NewColorMatrix returns an identity color matrix.
func ColorMatrixI() ColorMatrix { func NewColorMatrix() ColorMatrix {
return ColorMatrix{ return ColorMatrix{
[ColorMatrixDim - 1][ColorMatrixDim]float64{ [ColorMatrixDim - 1][ColorMatrixDim]float64{
{1, 0, 0, 0, 0}, {1, 0, 0, 0, 0},

View File

@ -20,7 +20,7 @@ import (
) )
func TestColorIdentity(t *testing.T) { func TestColorIdentity(t *testing.T) {
m := ColorMatrixI() m := NewColorMatrix()
got := m.IsIdentity() got := m.IsIdentity()
want := true want := true
if want != got { if want != got {

View File

@ -27,8 +27,8 @@ type GeometryMatrix struct {
es [GeometryMatrixDim - 1][GeometryMatrixDim]float64 es [GeometryMatrixDim - 1][GeometryMatrixDim]float64
} }
// GeometryMatrixI returns an identity geometry matrix. // NewGeometryMatrix returns an identity geometry matrix.
func GeometryMatrixI() GeometryMatrix { func NewGeometryMatrix() GeometryMatrix {
return GeometryMatrix{ return GeometryMatrix{
[GeometryMatrixDim - 1][GeometryMatrixDim]float64{ [GeometryMatrixDim - 1][GeometryMatrixDim]float64{
{1, 0, 0}, {1, 0, 0},

View File

@ -20,7 +20,7 @@ import (
) )
func TestGeometryIdentity(t *testing.T) { func TestGeometryIdentity(t *testing.T) {
m := GeometryMatrixI() m := NewGeometryMatrix()
got := m.IsIdentity() got := m.IsIdentity()
want := true want := true
if want != got { if want != got {

View File

@ -67,7 +67,7 @@ func (c *graphicsContext) postUpdate() error {
scale := float64(c.screenScale) scale := float64(c.screenScale)
geo := ScaleGeometry(scale, scale) geo := ScaleGeometry(scale, scale)
clr := ColorMatrixI() clr := NewColorMatrix()
option := &DrawImageOptions{ option := &DrawImageOptions{
GeometryMatrix: &geo, GeometryMatrix: &geo,
ColorMatrix: &clr, ColorMatrix: &clr,

View File

@ -69,12 +69,12 @@ func (i *innerImage) drawImage(img *innerImage, options *DrawImageOptions) error
} }
geo := options.GeometryMatrix geo := options.GeometryMatrix
if geo == nil { if geo == nil {
i := GeometryMatrixI() i := NewGeometryMatrix()
geo = &i geo = &i
} }
clr := options.ColorMatrix clr := options.ColorMatrix
if clr == nil { if clr == nil {
i := ColorMatrixI() i := NewColorMatrix()
clr = &i clr = &i
} }
@ -155,10 +155,16 @@ func (i *Image) Fill(clr color.Color) (err error) {
} }
// DrawImage draws the given image on the receiver image. // DrawImage draws the given image on the receiver image.
// This method accepts the parts of the given image at the parts of the destination as the options.
// After determining parts to draw, this applies the geometry matrix and the color matrix as the options.
// //
// If you want to draw a whole image simply, use DrawWholeImage. // This method accepts the options.
// The parts of the given image at the parts of the destination.
// After determining parts to draw, this applies the geometry matrix and the color matrix.
//
// If options is nil or its members are nil, the default values are used.
// DstParts: (0, 0) - (source width, source height)
// SrcParts: (0, 0) - (source width, source height) (i.e. the whole source image)
// GeometryMatrix: Identity matrix
// ColorMatrix: Identity matrix (that changes no colors)
func (i *Image) DrawImage(image *Image, options *DrawImageOptions) (err error) { func (i *Image) DrawImage(image *Image, options *DrawImageOptions) (err error) {
return i.drawImage(image.inner, options) return i.drawImage(image.inner, options)
} }