From 0b66b118b8e043553592bdc1691958da52edc937 Mon Sep 17 00:00:00 2001 From: Josh Deprez Date: Thu, 26 Aug 2021 11:35:15 +1000 Subject: [PATCH] comments --- engine/imageref.go | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/engine/imageref.go b/engine/imageref.go index e248a59..0e9980d 100644 --- a/engine/imageref.go +++ b/engine/imageref.go @@ -19,26 +19,24 @@ func init() { gob.Register(ImageRef{}) } -// ImageRef loads images from the AssetFS into *ebiten.Image form. -// It is your responsibility to import _ "image/..." for whatever -// format the files are in, and to load it (either return it as a -// subcomponent from Scan so that Game will Load it, or call Load -// yourself). +// ImageRef loads images from the AssetFS into *ebiten.Image form. It is your +// responsibility to import _ "image/..." for whatever format the files are in, +// and to load it (either return it as a subcomponent from Scan so that Game +// will Load it, or call Load yourself). type ImageRef struct { Path string image *ebiten.Image } -// Image returns the image, or nil if not loaded. -// Multiple distinct ImageRefs can use the same path. +// Image returns the image, or nil if not loaded. Multiple distinct ImageRefs +// can use the same path efficiently. func (r *ImageRef) Image() *ebiten.Image { return r.image } -// Load loads the image. Load is required before Image returns. -// Loading the same path multiple times uses a cache to return -// the same image. +// Load loads the image. Load is required before Image returns. Loading the same +// path multiple times uses a cache to return the same image. func (r *ImageRef) Load(assets fs.FS) error { // Fast path load from cache r.image = imageCache[assetKey{assets, r.Path}]