import { Label, ShapeCircle } from "./Unit";

export class Index {
    data;

    images;

    scaleX = 1;

    scaleY = 1;

    bg;

    constructor(data, images) {

        this.data = data;

        this.images = images;
    }

    init(mapScaleX = 1, mapScaleY = 1) {
        this.scaleX = mapScaleX;

        this.scaleY = mapScaleY;

        this.initBg();

        this.initPic();
    }

    private initBg() {
        let r = 10 * this.scaleX;

        const bg = new ShapeCircle();
        bg.setRadius(r);
        bg.fillColor = "#000000";

        this.bg = bg;
    }

    private initPic() {
        //序号
        const index = new Label();
        index.text = this.data.text;
        index.textAlign = 'center';
        index.fontSize = 15;
        index.fontName = "FUTURA";
        index.fontColor = "#ffffff";
        index.setScaleXY(this.scaleX);
        index.refreshSize();
        index.x = 0;
        index.y = (this.bg.height - index.getBoundingBox().height) / 2;
        this.bg.addChild(index);
    }
}