Css 从画布到图像的fabricjs制作

Css 从画布到图像的fabricjs制作,css,html,canvas,fabricjs,Css,Html,Canvas,Fabricjs,我有不同的背景类型(长方体、圆形、椭圆形)。例如,当我选择类型rounded时,它如下所示: function download(url,name){ // make the link. set the href and download. emulate dom click $('<a>').attr({href:url,download:name})[0].click(); } $("#canvas-to-png&

我有不同的背景类型(长方体、圆形、椭圆形)。例如,当我选择类型rounded时,它如下所示:

function download(url,name){
// make the link. set the href and download. emulate dom click
            $('<a>').attr({href:url,download:name})[0].click();
        }
        $("#canvas-to-png").click(function(){
            // to PNG
            //window.open(canvas.toDataURL('png'), '_blank');
            download(canvas.toDataURL(), 'canvas' + '.png');
        });
此表单的css示例:

element.style {
    border-radius: 437px/437px !important;
    overflow: hidden;
    width: 874px;
    height: 874px;
}
但当我尝试将其转换为png时,如下所示:

function download(url,name){
// make the link. set the href and download. emulate dom click
            $('<a>').attr({href:url,download:name})[0].click();
        }
        $("#canvas-to-png").click(function(){
            // to PNG
            //window.open(canvas.toDataURL('png'), '_blank');
            download(canvas.toDataURL(), 'canvas' + '.png');
        });
函数下载(url、名称){
//创建链接。设置href并下载。模拟dom单击
$('

如何使png文件看起来像第一个屏幕(保存边缘)?
干杯!

您是否使用CSS将画布更改为圆形?@Observer是的。我正在更改CSSD,但不更改画布的样式。根据需要将织物对象(圆形、椭圆形等)放入其中,并按您的逻辑进行下载。