why is Canvas moved to left top - thus not centered? #2402
Replies: 1 comment 3 replies
-
Hi @divinitas-art this is a great question! The reason the red rectangle isn't centered in the example is the underlying HTML canvas under the However there does seem to be a bug in the current Here is a workaround to center the ex.Canvas in that snippet: const canvas = new ex.Canvas({
width: 256,
height: 256,
cache: true, // If true draw once until flagged dirty again, otherwise draw to Canvas every frame
draw: (ctx) => {
console.log('With cache=true I draw once');
ctx.fillStyle = 'red';
ctx.fillRect(56/2, 56/2, 200, 200);
}
}) |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I am creating my own graphics using Canvas graphical component and the final image is not centered as any other graphics i use is.
Is this some sort of a bug or does this have a reason?
It might be a bug, since it does it in example on this page too
https://excaliburjs.com/docs/canvas
according to the code shown, the red box should be in center of scene? and it isnt...
Beta Was this translation helpful? Give feedback.
All reactions