如何在d3中使用高标准偏差高斯模糊?

时间:2019-06-12 17:26:46

标签: javascript d3.js svg

我正在尝试使用d3创建模糊弧。我正在创建弧并应用feGaussianBlur滤镜。但是,当我使用太高的标准偏差时,模糊似乎会碰到为弧创建的容器的边界。

增加容器的整体大小不会影响单个弧。是否可以增加弧形容器的尺寸?

var svgContainer = d3.select(".rainbow").append("svg")
    .attr("width", width)
    .attr("height", height)
    .append("g")
    .attr("transform", "translate(" + width/2 + "," + height/2 + ")");

//Define Arc 
var arc = d3.arc()
    .innerRadius(50)
    .outerRadius(55)
    .startAngle(-2)
    .endAngle(2)

// Container for the gradient
var defs = svgContainer.append("defs");

// Filter for the glow
var filter = defs.append("filter")
    .attr("id","glow");
filter.append("feGaussianBlur")
    .attr("stdDeviation","10");


//Adding arc
var path = svgContainer.selectAll("g.arc")
    .data('foo')
    .enter().append("g")
    .attr("class", "arc");
//Adding to path
path.append("path")
    .attr("d", arc)
    .style("filter", "url(#glow)");

我希望模糊可以扩展到所需的程度,但是它受到某些容器的约束,在圆弧周围形成了一个盒子,并切除了模糊的边缘。

0 个答案:

没有答案
相关问题