class BaseOrb {
    drawer;
    constructor(drawer) {
        this.drawer = drawer;
    }
}
/**
 * A moving circle that bounces inside a container.
 */
export class Orb extends BaseOrb {
    x;
    y;
    vx;
    vy;
    radius;
    bounds;
    constructor(drawer, velocity, bounds, radius) {
        super(drawer);
        this.x = (Math.random() * bounds.width) | 0;
        this.y = (Math.random() * bounds.height) | 0;
        this.radius = radius;
        this.bounds = bounds;
        var radiant = Math.random() * Math.PI * 2, vel = velocity;
        vel *= 0.2;
        this.vx = Math.cos(radiant) * vel;
        this.vy = Math.sin(radiant) * vel;
    }
    step() {
        this.x += this.vx;
        this.y += this.vy;
        var radius = this.radius / 2;
        if (this.x < -radius || this.x > this.bounds.width + radius)
            this.vx *= -1;
        if (this.y < -radius || this.y > this.bounds.height + radius)
            this.vy *= -1;
        this.drawer.drawOrb(this.x | 0, this.y | 0, this.radius);
    }
}
/**
 * A circle that follows and guides the main orb.
 */
export class GuideOrb extends BaseOrb {
    lastRadius;
    lastX;
    lastY;
    deflateDuration;
    constructor(drawer, deflateDuration) {
        super(drawer);
        this.deflateDuration = deflateDuration;
    }
    step(size, sizeToIncrease, lastSizeTimestamp, lastPositionTimestamp, currPos, moveBy) {
        const deltaTime = Date.now() - lastSizeTimestamp;
        const deltaTimePercent = deltaTime > 250 ? 1 : (deltaTime * 100) / 250 / 100;
        const radius = size - (sizeToIncrease - sizeToIncrease * deltaTimePercent);
        this.lastRadius = radius;
        const deltaTimePos = Date.now() - lastPositionTimestamp;
        const deltaTimePosPercent = deltaTimePos > this.deflateDuration
            ? 1
            : (deltaTimePos * 100) / this.deflateDuration / 100;
        const translateX = currPos.x - (moveBy.x - moveBy.x * deltaTimePosPercent);
        this.lastX = translateX;
        const translateY = currPos.y - (moveBy.y - moveBy.y * deltaTimePosPercent);
        this.lastY = translateY;
        this.drawer.drawOrb(translateX | 0, translateY | 0, radius);
    }
}
//# sourceMappingURL=Orbs.js.map