Skip to content

Commit

Permalink
ebiten: Remove the deprecated functions and constants
Browse files Browse the repository at this point in the history
Updates #1127
  • Loading branch information
hajimehoshi committed Oct 3, 2020
1 parent bf515bb commit 1d4ff9a
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 365 deletions.
45 changes: 0 additions & 45 deletions colorm.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,6 @@ func (c *ColorM) Concat(other ColorM) {
c.impl = c.impl.Concat(other.impl)
}

// Add adds a matrix, but in a wrong way.
//
// Deprecated: (as of 1.5.0) Do not use this.
//
// Note that this doesn't make sense as an operation for affine matrices.
func (c *ColorM) Add(other ColorM) {
c.impl = c.impl.Add(other.impl)
}

// Scale scales the matrix by (r, g, b, a).
func (c *ColorM) Scale(r, g, b, a float64) {
c.impl = c.impl.Scale(float32(r), float32(g), float32(b), float32(a))
Expand Down Expand Up @@ -123,39 +114,3 @@ func (c *ColorM) IsInvertible() bool {
func (c *ColorM) Invert() {
c.impl = c.impl.Invert()
}

// Monochrome returns a color matrix for monochrome.
//
// Deprecated: (as of 1.6.0) Use ChangeHSV(0, 0, 1) instead.
func Monochrome() ColorM {
c := ColorM{}
c.ChangeHSV(0, 0, 1)
return c
}

// ScaleColor returns a color matrix for scaling.
//
// Deprecated: (as of 1.2.0) Use Scale instead.
func ScaleColor(r, g, b, a float64) ColorM {
c := ColorM{}
c.Scale(r, g, b, a)
return c
}

// TranslateColor returns a color matrix for translating.
//
// Deprecated: (as of 1.2.0) Use Translate instead.
func TranslateColor(r, g, b, a float64) ColorM {
c := ColorM{}
c.Translate(r, g, b, a)
return c
}

// RotateHue returns a color matrix for chanting the hue.
//
// Deprecated: (as of 1.2.0-alpha) Use RotateHue member function instead.
func RotateHue(theta float64) ColorM {
c := ColorM{}
c.RotateHue(theta)
return c
}
104 changes: 24 additions & 80 deletions examples/windowsize/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,23 +36,6 @@ import (
)

var (
// flagLegacy represents whether the legacy APIs are used or not.
// If flagLegacy is true, these legacy APIs are used:
//
// * ebiten.Run
// * ebiten.ScreenScale
// * ebiten.SetScreenScale
// * ebiten.SetScreenSize
//
// If flagLegacy is false, these APIs are used:
//
// * ebiten.RunGame
// * ebiten.SetWindowSize
// * ebiten.WindowSize
//
// A resizable window is available only when flagLegacy is false.
flagLegacy = flag.Bool("legacy", false, "use the legacy API")

flagFullscreen = flag.Bool("fullscreen", false, "fullscreen")
flagResizable = flag.Bool("resizable", false, "make the window resizable")
flagWindowPosition = flag.String("windowposition", "", "window position (e.g., 100,200)")
Expand Down Expand Up @@ -120,23 +103,18 @@ func (g *game) Update(screen *ebiten.Image) error {
screenHeight int
screenScale float64
)
if *flagLegacy {
screenWidth, screenHeight = screen.Size()
screenScale = ebiten.ScreenScale()
screenWidth = g.width
screenHeight = g.height
if ww, wh := ebiten.WindowSize(); ww > 0 && wh > 0 {
screenScale = math.Min(float64(ww)/float64(g.width), float64(wh)/float64(g.height))
} else {
screenWidth = g.width
screenHeight = g.height
if ww, wh := ebiten.WindowSize(); ww > 0 && wh > 0 {
screenScale = math.Min(float64(ww)/float64(g.width), float64(wh)/float64(g.height))
} else {
// ebiten.WindowSize can return (0, 0) on browsers or mobiles.
screenScale = 1
}
// ebiten.WindowSize can return (0, 0) on browsers or mobiles.
screenScale = 1
}

fullscreen := ebiten.IsFullscreen()
runnableOnUnfocused := ebiten.IsRunnableOnUnfocused()
cursorVisible := ebiten.IsCursorVisible()
cursorVisible := ebiten.CursorMode() == ebiten.CursorModeVisible
vsyncEnabled := ebiten.IsVsyncEnabled()
tps := ebiten.MaxTPS()
decorated := ebiten.IsWindowDecorated()
Expand Down Expand Up @@ -242,18 +220,17 @@ func (g *game) Update(screen *ebiten.Image) error {
}

if toUpdateWindowSize {
if *flagLegacy {
ebiten.SetScreenSize(screenWidth, screenHeight)
ebiten.SetScreenScale(screenScale)
} else {
g.width = screenWidth
g.height = screenHeight
ebiten.SetWindowSize(int(float64(screenWidth)*screenScale), int(float64(screenHeight)*screenScale))
}
g.width = screenWidth
g.height = screenHeight
ebiten.SetWindowSize(int(float64(screenWidth)*screenScale), int(float64(screenHeight)*screenScale))
}
ebiten.SetFullscreen(fullscreen)
ebiten.SetRunnableOnUnfocused(runnableOnUnfocused)
ebiten.SetCursorVisible(cursorVisible)
if cursorVisible {
ebiten.SetCursorMode(ebiten.CursorModeVisible)
} else {
ebiten.SetCursorMode(ebiten.CursorModeHidden)
}
ebiten.SetVsyncEnabled(vsyncEnabled)
ebiten.SetMaxTPS(tps)
ebiten.SetWindowDecorated(decorated)
Expand All @@ -269,10 +246,7 @@ func (g *game) Update(screen *ebiten.Image) error {
if restore {
ebiten.RestoreWindow()
}
if !*flagLegacy {
// A resizable window is available only with RunGame.
ebiten.SetWindowResizable(resizable)
}
ebiten.SetWindowResizable(resizable)

if inpututil.IsKeyJustPressed(ebiten.KeyI) {
ebiten.SetWindowIcon([]image.Image{createRandomIconImage()})
Expand Down Expand Up @@ -311,13 +285,7 @@ func (g *game) Draw(screen *ebiten.Image) {
}
msgM := strings.Join(lines, "\n")

var msgS string
var msgR string
if *flagLegacy {
msgS = "[S] Change the window scale (only for desktops)\n"
} else {
msgR = "[R] Switch the window resizable state (only for desktops)\n"
}
msgR := "[R] Switch the window resizable state (only for desktops)\n"
fg := "Yes"
if !ebiten.IsFocused() {
fg = "No"
Expand All @@ -335,13 +303,12 @@ func (g *game) Draw(screen *ebiten.Image) {
[L] Switch the window floating state (only for desktops)
[W] Switch whether to skip clearing the screen
%s
%s
IsFocused?: %s
Windows Position: (%d, %d)
Cursor: (%d, %d)
TPS: Current: %0.2f / Max: %s
FPS: %0.2f
Device Scale Factor: %0.2f`, msgS, msgM, msgR, fg, wx, wy, cx, cy, ebiten.CurrentTPS(), tpsStr, ebiten.CurrentFPS(), ebiten.DeviceScaleFactor())
Device Scale Factor: %0.2f`, msgM, msgR, fg, wx, wy, cx, cy, ebiten.CurrentTPS(), tpsStr, ebiten.CurrentFPS(), ebiten.DeviceScaleFactor())
ebitenutil.DebugPrint(screen, msg)
}

Expand Down Expand Up @@ -369,10 +336,6 @@ func main() {
w, h := ebiten.ScreenSizeInFullscreen()
fmt.Printf("Screen size in fullscreen: %d, %d\n", w, h)

if !*flagLegacy {
fmt.Println("Tip: With -autoadjusting flag, you can make an adjustable game screen.")
}

// Decode image from a byte slice instead of a file so that
// this example works in any working directory.
// If you want to use a file, there are some options:
Expand Down Expand Up @@ -415,9 +378,6 @@ func main() {
}
ebiten.SetVsyncEnabled(*flagVsync)
if *flagAutoAdjusting {
if *flagLegacy {
log.Println("-autoadjusting flag cannot work with -legacy flag")
}
ebiten.SetWindowResizable(true)
}

Expand All @@ -427,27 +387,11 @@ func main() {
}

const title = "Window Size (Ebiten Demo)"
if *flagLegacy {
update := func(screen *ebiten.Image) error {
if err := g.Update(screen); err != nil {
return err
}
if ebiten.IsDrawingSkipped() {
return nil
}
g.Draw(screen)
return nil
}
if err := ebiten.Run(update, g.width, g.height, initScreenScale, title); err != nil {
log.Fatal(err)
}
} else {
w := int(float64(g.width) * initScreenScale)
h := int(float64(g.height) * initScreenScale)
ebiten.SetWindowSize(w, h)
ebiten.SetWindowTitle(title)
if err := ebiten.RunGame(g); err != nil {
log.Fatal(err)
}
ww := int(float64(g.width) * initScreenScale)
wh := int(float64(g.height) * initScreenScale)
ebiten.SetWindowSize(ww, wh)
ebiten.SetWindowTitle(title)
if err := ebiten.RunGame(g); err != nil {
log.Fatal(err)
}
}
41 changes: 0 additions & 41 deletions geom.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,20 +98,6 @@ func (g *GeoM) Concat(other GeoM) {
g.ty = ty
}

// Add adds a matrix, but in a wrong way.
//
// Deprecated: (as of 1.5.0) Do not use this.
//
// Note that this doesn't make sense as an operation for affine matrices.
func (g *GeoM) Add(other GeoM) {
g.a_1 += other.a_1
g.b += other.b
g.c += other.c
g.d_1 += other.d_1
g.tx += other.tx
g.ty += other.ty
}

// Scale scales the matrix by (x, y).
func (g *GeoM) Scale(x, y float64) {
a := (g.a_1 + 1) * x
Expand Down Expand Up @@ -232,30 +218,3 @@ func (g *GeoM) SetElement(i, j int, element float64) {
panic("ebiten: i or j is out of index")
}
}

// ScaleGeo returns a geometry matrix for scaling.
//
// Deprecated: (as of 1.2.0) Use Scale instead.
func ScaleGeo(x, y float64) GeoM {
g := GeoM{}
g.Scale(x, y)
return g
}

// TranslateGeo returns a geometry matrix for translating.
//
// Deprecated: (as of 1.2.0) Use Translate instead.
func TranslateGeo(tx, ty float64) GeoM {
g := GeoM{}
g.Translate(tx, ty)
return g
}

// RotateGeo returns a geometry matrix for rotating.
//
// Deprecated: (as of 1.2.0) Use Rotate instead.
func RotateGeo(theta float64) GeoM {
g := GeoM{}
g.Rotate(theta)
return g
}
7 changes: 0 additions & 7 deletions image.go
Original file line number Diff line number Diff line change
Expand Up @@ -851,10 +851,3 @@ func newScreenFramebufferImage(width, height int) *Image {
i.addr = i
return i
}

// MaxImageSize represented the maximum size of an image, but now this constant is deprecated.
//
// Deprecated: (as of 1.7.0) No replacement so far.
//
// TODO: Make this replacement (#541)
var MaxImageSize = 4096
41 changes: 0 additions & 41 deletions input.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,44 +214,3 @@ func TouchPosition(id int) (int, int) {

return uiDriver().Input().TouchPosition(id)
}

// Touch represents a touch.
//
// Deprecated: (as of 1.7.0). Use TouchPosition instead.
type Touch interface {
// ID returns an identifier for one stroke.
ID() int

// Position returns the position of the touch.
Position() (x, y int)
}

type touch struct {
id int
x int
y int
}

func (t *touch) ID() int {
return t.id
}

func (t *touch) Position() (x, y int) {
return t.x, t.y
}

// Touches returns the current touches.
//
// Deprecated: (as of 1.7.0) Use TouchIDs instead.
func Touches() []Touch {
var ts []Touch
for _, id := range TouchIDs() {
x, y := TouchPosition(id)
ts = append(ts, &touch{
id: id,
x: x,
y: y,
})
}
return ts
}
Loading

0 comments on commit 1d4ff9a

Please sign in to comment.