// Learn TypeScript:
//  - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/typescript.html
//  - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/typescript.html
// Learn Attribute:
//  - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
//  - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
//  - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/life-cycle-callbacks.html

const { ccclass, property } = cc._decorator;

@ccclass
export default class NewClass extends cc.Component {

    @property(cc.Canvas)
    canvas: cc.Canvas;


    // LIFE-CYCLE CALLBACKS:

    onLoad() {
        var canvas = this.canvas
        var designResolution = canvas.designResolution
        var viewSize = cc.view.getFrameSize()
        console.log("winsize", viewSize.width, viewSize.height)
        console.log("designResolution", designResolution.width, designResolution.height)
        console.log("canvas", canvas, canvas.fitWidth, canvas.fitHeight)
    
        if (viewSize.width/viewSize.height > designResolution.width/designResolution.height)
        {
            canvas.fitHeight = true
        }
        else{
            canvas.fitWidth = true
        }
    }

    start() {

    }

    // update (dt) {}
}
