render: map composing (working with proper shifts)

This commit is contained in:
muerwre 2018-11-28 09:38:39 +07:00
parent 4747c918e2
commit 2f3cb0e770
3 changed files with 22 additions and 8 deletions

View file

@ -49,12 +49,14 @@ export class Renderer extends React.Component {
composeImages = ({ images, geometry, ctx }) => {
const {
minX, minY, shiftX, shiftY, size
minX, minY, maxY, shiftX, shiftY, size
} = geometry;
images.map(({ x, y, image }) => {
const verticalShift = (maxY - minY) * size;
const posX = ((x - minX) * size) + shiftX;
const posY = ((y - minY) * size) + (window.innerHeight - shiftY - size);
const posY = ((y - minY) * size) - (verticalShift - shiftY);
return ctx.drawImage(image, posX, posY, 256, 256);
});