You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am writing a Blazor WA game. When the game starts, it loads a big spritesheet and when the game runs, it draws rectangles from that spritesheet into the canvas using DrawImageAsync
My question is, what's the best way to initially load that big spritesheet? I've tried using <img id='spritesheet' src='....'/> but I get an exception saying Failed to execute 'drawImage' on 'CanvasRenderingContext2D': The provided value is not of type '(CSSImageValue or HTMLImageElement or SVGImageElement or HTMLVideoElement or HTMLCanvasElement or ImageBitmap or OffscreenCanvas)'
My call is:
ElementReference reference = new ElementReference("spritesheet");
await _canvas2DContext.DrawImageAsync(reference, spritePosition.X, spritePosition.Y);
When I inspect my spritesheet in the DOM, it is:
Am I setting ElementReference incorrectly?
Are there any example of using DrawImageAsync anywhere?
The text was updated successfully, but these errors were encountered:
SteveDunn
changed the title
How do I drawn images?
How do I draw images?
Apr 21, 2020
Hi, firstly thanks for a great library!
I am writing a Blazor WA game. When the game starts, it loads a big spritesheet and when the game runs, it draws rectangles from that spritesheet into the canvas using
DrawImageAsync
My question is, what's the best way to initially load that big spritesheet? I've tried using
<img id='spritesheet' src='....'/>
but I get an exception sayingFailed to execute 'drawImage' on 'CanvasRenderingContext2D': The provided value is not of type '(CSSImageValue or HTMLImageElement or SVGImageElement or HTMLVideoElement or HTMLCanvasElement or ImageBitmap or OffscreenCanvas)'
My call is:
When I inspect my spritesheet in the DOM, it is:
Am I setting
ElementReference
incorrectly?Are there any example of using
DrawImageAsync
anywhere?The text was updated successfully, but these errors were encountered: