ebiten: Add comments about NewImage*

Closes #1894
This commit is contained in:
Hajime Hoshi 2021-12-09 21:03:22 +09:00
parent 490155583f
commit 9787e076bc

View File

@ -811,6 +811,10 @@ func (i *Image) ReplacePixels(pixels []byte) {
//
// If width or height is less than 1 or more than device-dependent maximum size, NewImage panics.
//
// NewImage should be called only when necessary.
// For example, you should avoid to call NewImage every Update or Draw call.
// Reusing the same image by Clear is much more efficient than creating a new image.
//
// NewImage panics if RunGame already finishes.
func NewImage(width, height int) *Image {
if isRunGameEnded() {
@ -834,6 +838,10 @@ func NewImage(width, height int) *Image {
//
// If source's width or height is less than 1 or more than device-dependent maximum size, NewImageFromImage panics.
//
// NewImageFromImage should be called only when necessary.
// For example, you should avoid to call NewImageFromImage every Update or Draw call.
// Reusing the same image by Clear is much more efficient than creating a new image.
//
// NewImageFromImage panics if RunGame already finishes.
func NewImageFromImage(source image.Image) *Image {
if isRunGameEnded() {