Last active
January 27, 2024 04:07
-
-
Save LizAinslie/cfd28b507141e7a2b97d4c3c91a98fa6 to your computer and use it in GitHub Desktop.
Stacky bois
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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