mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-13 04:22:05 +01:00
Rename *MatrixI -> New*Matrix
This commit is contained in:
parent
f7b2157585
commit
d53d55a629
@ -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},
|
||||||
|
@ -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 {
|
||||||
|
@ -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},
|
||||||
|
@ -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 {
|
||||||
|
@ -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,
|
||||||
|
16
image.go
16
image.go
@ -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)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user