Minor improvement with generating sprites
This commit is contained in:
parent
caf0e5c2f4
commit
e57c19defd
@ -124,13 +124,15 @@ export default class SpriteUpdateEvent extends BaseEvent {
|
||||
const maxWidth = Math.max(...imageData.map((data) => data.width))
|
||||
const maxHeight = Math.max(...imageData.map((data) => data.height))
|
||||
|
||||
console.log(maxWidth, maxHeight)
|
||||
|
||||
// Extend all images to match the largest dimensions without resizing
|
||||
const resizedBuffers = await Promise.all(
|
||||
imageData.map(async ({ buffer, width, height }) => {
|
||||
// Calculate padding to center the sprite
|
||||
const topPadding = 0 // This is always 0. We don't need to calculate it
|
||||
const bottomPadding = Math.ceil((maxHeight - height) / 2)
|
||||
const leftPadding = Math.floor((maxWidth - width) / 2)
|
||||
const leftPadding = Math.ceil((maxWidth - width) / 2)
|
||||
const rightPadding = Math.ceil((maxWidth - width) / 2)
|
||||
|
||||
return await sharp(buffer)
|
||||
|
Loading…
x
Reference in New Issue
Block a user