const {ccclass, property, executeInEditMode, playOnFocus} = cc._decorator;

@ccclass
@executeInEditMode
export class Draw extends cc.Component {
    protected onLoad(): void {
        let debugDrawer = this.node.addComponent(cc.Graphics);
        debugDrawer.lineWidth = 5;
        debugDrawer.strokeColor = new cc.Color(255, 0, 0);
        debugDrawer.fillColor = new cc.Color(255, 0, 0);

        let size = this.node.getContentSize();
        if(size.width == 0){
            size = cc.size(10,10)
        }
        
        debugDrawer.moveTo(-size.width * 0.5 , -size.height * 0.5 );
        debugDrawer.lineTo(-size.width * 0.5 , +size.height * 0.5 );
        debugDrawer.lineTo(size.width * 0.5 , +size.height * 0.5 );
        debugDrawer.lineTo(size.width * 0.5 , -size.height * 0.5 );
        debugDrawer.lineTo(-size.width * 0.5 , -size.height * 0.5 );
        debugDrawer.stroke();
    }
}