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

export class Letter{
    data;

    images;

    bgColor;

    scaleX = 1;

    scaleY = 1;

    bg : ShapeCircle;

    init(images, data, bgColor, scaleX = 1, scaleY = 1) {

        this.images = images;

        this.data = data;

        this.bgColor = bgColor;

        this.scaleX = scaleX;

        this.scaleY = scaleY;

        this.initBg();

        this.initView();
    }

    initBg(){

        let w = 180 * this.scaleX;

        let h = 90 * this.scaleY;

        let bg = new ShapeRect();

        bg.setSize(w, h);

        bg.fillColor = this.bgColor;

        this.bg = bg;

    }

    initView(){
        const letter = new Label();
        letter.text = this.data.val;
        letter.textAlign = 'center';
        letter.fontSize = 64;
        letter.fontName = "FuturaB";
        letter.fontColor = "#ffffff";
        letter.setScaleXY(this.scaleX);
        letter.setMaxSize(170 * this.scaleX);
        letter.refreshSize();
        letter.x = this.bg.width / 2;
        letter.y = this.bg.height / 2;
        this.bg.addChild(letter);
    }
}