func Run(f func(*Image) error, width, height int, scale float64, title string) error {
	f = (&imageDumper{f: f}).update

	c := newUIContext(f)
	theUIContext.Store(c)

	atomic.StoreInt32(&isRunning, 1)
	// On GopherJS, run returns immediately.
	if !web.IsGopherJS() {
		defer atomic.StoreInt32(&isRunning, 0)
	}

	if err := uiDriver().Run(width, height, scale, title, c, graphicsDriver()); err != nil {
		if err == driver.RegularTermination {
			return nil
		}
		return err
	}

	return nil
}
func Run(f func(*Image) error, width, height int, scale float64, title string) error {
	f = (&imageDumper{f: f}).update

	c := newUIContext(f)
	theUIContext.Store(c)

	atomic.StoreInt32(&isRunning, 1)
	// On GopherJS, run returns immediately.
	if !web.IsGopherJS() {
		defer atomic.StoreInt32(&isRunning, 0)
	}

	if err := uiDriver().Run(width, height, scale, title, c, graphicsDriver()); err != nil {
		if err == driver.RegularTermination {
			return nil
		}
		return err
	}

	return nil
}
// Run runs the game.
// f is a function which is called at every frame.
// The argument (*Image) is the render target that represents the screen.
// The screen size is based on the given values (width and height).
//
// A window size is based on the given values (width, height and scale).
// scale is used to enlarge the screen.
// Note that the actual screen is multiplied not only by the given scale but also
// by the device scale on high-DPI display.
// If you pass inverse of the device scale,
// you can disable this automatical device scaling as a result.
// You can get the device scale by DeviceScaleFactor function.
//
// Run must be called on the main thread.
// Note that Ebiten bounds the main goroutine to the main OS thread by runtime.LockOSThread.
//
// Ebiten tries to call f 60 times a second by default. In other words,
// TPS (ticks per second) is 60 by default.
// This is not related to framerate (display's refresh rate).
//
// f is not called when the window is in background by default.
// This setting is configurable with SetRunnableInBackground.
//
// The given scale is ignored on fullscreen mode or gomobile-build mode.
//
// On non-GopherJS environments, Run returns error when 1) OpenGL error happens, 2) audio error happens or
// 3) f returns error. In the case of 3), Run returns the same error.
//
// On GopherJS, Run returns immediately.
// It is because the 'main' goroutine cannot be blocked on GopherJS due to the bug (gopherjs/gopherjs#826).
// When an error happens, this is shown as an error on the console.
//
// The size unit is device-independent pixel.
//
// Don't call Run twice or more in one process.