mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
image: Deprecate RotateHue
This commit is contained in:
parent
2a935f645d
commit
d1ff3701a6
19
colorm.go
19
colorm.go
@ -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
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user