Rotate image with JavaScript for macro in Foundry vtt

  javascript, macros

Afternoon,

Trying to write a small macro for Foundry VTT to make a picture rotate on the spot. I can get it to rotate but it does it in a large circular motion instead of rotating on the spot. Wondering where I am going wrong.

Here is all the code:

const SPINNING_BLADE_TRAP_SRC = "modules/rotateTile/picSaw.png";

function animateBladeTraps(traps) {
    traps.forEach(t => {
        t.rotation -= 0.1;
    });
}

const traps = canvas.tiles.placeables.filter(t => t.data.img === SPINNING_BLADE_TRAP_SRC);
if (traps.length) {
    canvas.app.ticker.add(() => animateBladeTraps(traps));
}

Any thoughts?

Source: Ask Javascript Questions

LEAVE A COMMENT