Gaussian blur (ground glass effect) implementation

Source code, welcome star oh

1: CSS



2: Canvas StackBlur. Js borrowed

3: SVG

Advantages of this method: smaller than Canvas library, library source algorithm is difficult to understand; The implementation is better than CSS style effect. We have encountered this kind of requirement before, the CSS edge will become blurred after the filter is large, and the effect is poor

The solution



Documentation comments

The ID attribute of the

tag defines a unique name for the filter (the same filter can be used by multiple elements in the document)
Filter: The URL attribute is used to link elements to filters. The # character must be used when linking filter IDS
The filter effect is defined using the

tag. The FE suffix is available for all filters
The stdDeviation attribute of the

tag defines the degree of blurring
In =”SourceGraphic” this section defines the effect created by the entire image

Step2: use



This example provides two interface dynamic Settings: setBlurAmount and generateBlurredImage

Source welcome star