-1
캔버스를 만들었지 만 창 크기를 조정하면 캔버스 내용이 사라집니다. 다음 코드를 사용하고 있습니다. 캔버스와 배경 이미지의 원래 크기는 960x558입니다. 캔버스와 배경 이미지의 크기가 다르기 때문에 app.stage.canvas의 너비와 높이를 사용하고 있습니다.캔버스에 내용의 크기를 조정하는 방법은 무엇입니까?
function resize(){
app.stage.canvas.width = $('#canvas').parent().width();
//app.stage.canvas.height = window.innerHeight;
app.stagetools.canvas.width = $('#canvas').parent().width();
//tools container
if(app.stage.canvas.width < 960){
app.stage.canvas.height = '558';
}
if(app.stage.canvas.width < 739){
app.stage.canvas.height = '400';
}
if(app.stage.canvas.width < 510){
app.stage.canvas.height = '300';
}
if(app.stage.canvas.width < 450){
app.stage.canvas.height = '240';
tools.toolsScale = 0.7;
}
tools.toolsContainer.scaleX = tools.toolsScale;
tools.toolsContainer.scaleY = tools.toolsScale;
tools.toolsContainer.x = app.stagetools.canvas.width/2 - 150 * tools.toolsScale;
app.container.x = app.stage.canvas.width/2;
app.container.y = app.stage.canvas.height/2;
//background image
app.bgscale = app.stage.canvas.width/app.backgroundBounds.width;
if(app.backgroundBounds.height * app.bgscale > app.stage.canvas.height){
app.bgscale = app.stage.canvas.height/app.backgroundBounds.height;
}
app.backgroundContainer.scaleX = app.bgscale;
app.backgroundContainer.scaleY = app.bgscale;
app.backgroundContainer.x = Math.floor(app.stage.canvas.width/2 - app.backgroundBounds.width/2 * app.bgscale);
app.backgroundContainer.y = Math.floor(app.stage.canvas.height/2 - app.backgroundBounds.height/2 * app.bgscale);
tools.clearHandler();
app.stage.update();
app.stagetools.update();
}
어떻게이 그리기 방법이 좋을까요? – zoolle
@zoolle은 사용자가 정의 할 수 있습니다 (다시 그리는 데 필요한 모든 것). – K3N