|
Posted by kingoftailor
at Aug 12, 2022, 5:25:34 PM
|
Re: Sweet Home 3D JS Online
It's almost good. There is only a problem with the background color. It should be all white. (The invisible part is not white)
function AlaprajzMentes() { let downloadLink = document.createElement('a'); downloadLink.setAttribute('download', 'alaprajz.jpg');
var planView = application.getHomeController(application.getHomes()[0]).getPlanController().getView(); var oldGridColor = planView.gridColor; planView.gridColor = "white"; planView.repaint(); var canvas = document.createElement('canvas'); canvas.width = planView.getPreferredSize().width * 2; canvas.height = planView.getPreferredSize().height * 2; planView.paintComponent(new Graphics2D(canvas));
setTimeout(function () { let dataURL = canvas.toDataURL('image/jpg'); let url = dataURL.replace(/^data:image\/jpg/, 'data:application/octet-stream'); downloadLink.setAttribute('href', url); downloadLink.click(); planView.gridColor = oldGridColor; planView.repaint(); }, 100); }

|