Skip to content

Instantly share code, notes, and snippets.

@LizAinslie
Last active January 27, 2024 04:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LizAinslie/cfd28b507141e7a2b97d4c3c91a98fa6 to your computer and use it in GitHub Desktop.
Save LizAinslie/cfd28b507141e7a2b97d4c3c91a98fa6 to your computer and use it in GitHub Desktop.
Stacky bois
const stackCount = 10
const STACK_SPACE = 10;
// Draw the stack of images
for (let i = 0; i < stackCount; i++) {
const shearFactor = (stackCount - i)
// Calculate scale and position adjustments based on the current iteration
const scaleAdjustment = 0.9 + (0.1 * (i - shearFactor)) / stackCount
const positionAdjustmentX = (scaledImageWidth - (scaledImageWidth * scaleAdjustment)) / 2;
const positionAdjustmentY = (STACK_SPACE * shearFactor);
ctx.drawImage(
imageCanvas,
position.x + positionAdjustmentX, // 3 is a magic value i guess
position.y - positionAdjustmentY,
scaledImageWidth * scaleAdjustment,
scaledImageHeight * scaleAdjustment,
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment