Skip to content

Commit

Permalink
GCODE viewer: Even better version of initial bed centering, backporte…
Browse files Browse the repository at this point in the history
…d from c858c8f

See #719
  • Loading branch information
foosel committed Jan 19, 2015
1 parent a91a354 commit 6dd2dce
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/octoprint/static/gcodeviewer/js/renderer.js
Expand Up @@ -513,7 +513,16 @@ GCODE.renderer = (function(){
bedWidth = bedHeight = renderOptions["bed"]["r"] * 2;
}
zoomFactor = Math.min((canvas.width - 10) / bedWidth, (canvas.height - 10) / bedHeight);
ctx.translate((canvas.width - bedWidth * zoomFactor) / 2, (canvas.height + bedHeight * zoomFactor) / 2);

var translationX, translationY;
if (renderOptions["bed"]["circular"]) {
translationX = canvas.width / 2;
translationY = canvas.height / 2;
} else {
translationX = (canvas.width - bedWidth * zoomFactor) / 2;
translationY = bedHeight * zoomFactor + (canvas.height - bedHeight * zoomFactor) / 2;
}
ctx.translate(translationX, translationY);

offsetModelX = 0;
offsetModelY = 0;
Expand Down

0 comments on commit 6dd2dce

Please sign in to comment.