ā15391734[Quote]
function animate(p5, props) {
const { mainImage, size, currentFrame, totalFrames, bgColor, featureValue } = props;
p5.background(bgColor);
const t = (currentFrame / totalFrames) * Math.PI * 2;
const speed = 0.5 + (featureValue / 100) * 1.5;
const trailLength = Math.floor(5 + (featureValue / 100) * 15);
const biggestImageDimension = Math.max(mainImage.width, mainImage.height);
const scaleFactor = (size / biggestImageDimension) * 0.5;
// Draw ghost trail with decreasing opacity
for (let i = trailLength; i > 0; i–) {
const trailT = t - (i / trailLength) * 0.3 * speed;
const x = Math.sin(trailT * speed) * size * 0.25;
const y = Math.cos(trailT * speed * 0.7) * size * 0.2;
const z = Math.sin(trailT * speed * 0.5) * size * 0.15;
const opacity = (i / trailLength) * 0.4;
p5.push();
p5.translate(x, y, z);
p5.scale(scaleFactor);
p5.tint(255, 255, 255, opacity * 255);
p5.texture(mainImage);
p5.plane(mainImage.width, mainImage.height);
p5.pop();
}
}
ā15391743[Quote]
fly around like a spooky ghost with after images. make sure it shrinks and grows instead of moving in the Z axis, also make sure the gif loops
ā15391759[Quote]
>function animate(p5, props) {
> const { mainImage, size, currentFrame, totalFrames, bgColor, featureValue } = props;
>
> p5.background(bgColor);
>
> const t = (currentFrame / totalFrames) * Math.PI * 2;
> const speed = 0.5 + (featureValue / 100) * 1.5;
> const trailLength = Math.floor(5 + (featureValue / 100) * 15);
>
> const biggestImageDimension = Math.max(mainImage.width, mainImage.height);
> const scaleFactor = (size / biggestImageDimension) * 0.5;
>
> // Draw ghost trail with decreasing opacity
> for (let i = trailLength; i > 0; iā) {
> const trailT = t - (i / trailLength) * 0.3 * speed;
> const x = Math.sin(trailT * speed) * size * 0.25;
> const y = Math.cos(trailT * speed * 0.7) * size * 0.2;
> const z = Math.sin(trailT * speed * 0.5) * size * 0.15;
>
> const opacity = (i / trailLength) * 0.4;
> p5.push();
> p5.translate(x, y, z);
> p5.scale(scaleFactor);
> p5.tint(255, 255, 255, opacity * 255);
> p5.texture(mainImage);
> p5.plane(mainImage.width, mainImage.height);
> p5.pop();
> }
>
>
>}