image: Deprecate RotateHue

This commit is contained in:
Hajime Hoshi 2016-02-06 23:56:02 +09:00
parent 2a935f645d
commit d1ff3701a6
3 changed files with 20 additions and 3 deletions

View File

@ -101,6 +101,23 @@ func (c *ColorM) Translate(r, g, b, a float64) {
c.es[3][4] += a
}
// RotateHue rotates the hue.
func (c *ColorM) RotateHue(theta float64) {
sin, cos := math.Sincos(theta)
v1 := cos + (1.0-cos)/3.0
v2 := (1.0/3.0)*(1.0-cos) - math.Sqrt(1.0/3.0)*sin
v3 := (1.0/3.0)*(1.0-cos) + math.Sqrt(1.0/3.0)*sin
c.Concat(ColorM{
initialized: true,
es: [ColorMDim - 1][ColorMDim]float64{
{v1, v2, v3, 0, 0},
{v3, v1, v2, 0, 0},
{v2, v3, v1, 0, 0},
{0, 0, 0, 1, 0},
},
})
}
// SetElement sets an element at (i, j).
func (c *ColorM) SetElement(i, j int, element float64) {
if !c.initialized {
@ -151,7 +168,7 @@ func TranslateColor(r, g, b, a float64) ColorM {
}
}
// RotateHue returns a color matrix to rotate the hue
// Deprecated as of 1.2.0-alpha. Use RotateHue member function instead.
func RotateHue(theta float64) ColorM {
sin, cos := math.Sincos(theta)
v1 := cos + (1.0-cos)/3.0

View File

@ -37,7 +37,7 @@ func update(screen *ebiten.Image) error {
w, h := gophersImage.Size()
op := &ebiten.DrawImageOptions{}
op.GeoM.Translate(float64(screenWidth-w)/2, float64(screenHeight-h)/2)
op.ColorM.Concat(ebiten.RotateHue(float64(count%360) * 2 * math.Pi / 360))
op.ColorM.RotateHue(float64(count%360) * 2 * math.Pi / 360)
if err := screen.DrawImage(gophersImage, op); err != nil {
return err
}

View File

@ -47,7 +47,7 @@ func update(screen *ebiten.Image) error {
op.GeoM.Translate(float64(mx), float64(my))
op.ColorM.Scale(1.0, 0.25, 0.25, 1.0)
theta := 2.0 * math.Pi * float64(count%60) / 60.0
op.ColorM.Concat(ebiten.RotateHue(theta))
op.ColorM.RotateHue(theta)
if err := canvasImage.DrawImage(brushImage, op); err != nil {
return err
}