import { GlobalVariables } from "../Data/GlobalVariables";

const { ccclass, property } = cc._decorator;

@ccclass
export default class Fill extends cc.Component {
  protected onLoad(): void {
    let originReso = cc.view.getDesignResolutionSize();
    let currentReso = cc.view.getVisibleSize();

    let ratioDiff: cc.Vec2 = new cc.Vec2();
    ratioDiff.x = currentReso.width / originReso.width;
    ratioDiff.y = currentReso.height / originReso.height;

    let originContentSize = this.node.getContentSize();
    this.node.setContentSize(
      originContentSize.width * ratioDiff.x,
      originContentSize.height * ratioDiff.y
    );

    GlobalVariables.ratioDiffX = ratioDiff.x;
    GlobalVariables.ratioDiffY = ratioDiff.y;
  }
}
