|
| 1 | +--- |
| 2 | +title: "SVGFEGaussianBlurElement: setStdDeviation() method" |
| 3 | +short-title: setStdDeviation() |
| 4 | +slug: Web/API/SVGFEGaussianBlurElement/setStdDeviation |
| 5 | +page-type: web-api-instance-method |
| 6 | +browser-compat: api.SVGFEGaussianBlurElement.setStdDeviation |
| 7 | +--- |
| 8 | + |
| 9 | +{{APIRef("SVG")}} |
| 10 | + |
| 11 | +The `setStdDeviation()` method of the {{domxref("SVGFEGaussianBlurElement")}} interface sets the values for the {{SVGAttr("stdDeviation")}} attribute. |
| 12 | + |
| 13 | +## Syntax |
| 14 | + |
| 15 | +```js-nolint |
| 16 | +SVGFEGaussianBlurElement.setStdDeviation(x, y) |
| 17 | +``` |
| 18 | + |
| 19 | +### Parameters |
| 20 | + |
| 21 | +- `x` |
| 22 | + - : A float representing X component of the {{SVGAttr("stdDeviation")}} attribute. |
| 23 | +- `y` |
| 24 | + - : A float representing Y component of the {{SVGAttr("stdDeviation")}} attribute. |
| 25 | + |
| 26 | +### Return value |
| 27 | + |
| 28 | +None ({{jsxref('undefined')}}). |
| 29 | + |
| 30 | +## Examples |
| 31 | + |
| 32 | +### Using `setStdDeviation()` |
| 33 | + |
| 34 | +```html |
| 35 | +<svg viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg"> |
| 36 | + <defs> |
| 37 | + <filter id="gaussian-blur-filter"> |
| 38 | + <feGaussianBlur |
| 39 | + in="SourceGraphic" |
| 40 | + stdDeviation="5 5" |
| 41 | + result="blurred-graphic" /> |
| 42 | + </filter> |
| 43 | + </defs> |
| 44 | + |
| 45 | + <!-- Rectangle with an initial blur effect --> |
| 46 | + <rect |
| 47 | + x="50" |
| 48 | + y="50" |
| 49 | + width="100" |
| 50 | + height="100" |
| 51 | + style="fill:hotpink;" |
| 52 | + filter="url(#gaussian-blur-filter)" /> |
| 53 | +</svg> |
| 54 | + |
| 55 | +<!-- Button to update the blur --> |
| 56 | +<button id="updateBlur">Update Blur</button> |
| 57 | +``` |
| 58 | + |
| 59 | +```js |
| 60 | +// Get the feGaussianBlur element |
| 61 | +const gaussianBlur = document.querySelector("feGaussianBlur"); |
| 62 | + |
| 63 | +// Button to trigger the update |
| 64 | +document.getElementById("updateBlur").addEventListener("click", () => { |
| 65 | + // Change the standard deviation (blur radius) of the blur effect |
| 66 | + gaussianBlur.setStdDeviation(15, 20); // Update to X: 15, Y: 20 |
| 67 | +}); |
| 68 | +``` |
| 69 | + |
| 70 | +## Specifications |
| 71 | + |
| 72 | +{{Specifications}} |
| 73 | + |
| 74 | +## Browser compatibility |
| 75 | + |
| 76 | +{{Compat}} |
| 77 | + |
| 78 | +## See also |
| 79 | + |
| 80 | +- {{domxref("SVGAnimatedLength")}} |
0 commit comments