Skip to content

Commit a94e439

Browse files
committed
doc(README) Rewording of SVG Filter
1 parent 8ba7f96 commit a94e439

1 file changed

Lines changed: 43 additions & 21 deletions

File tree

README.md

Lines changed: 43 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -244,37 +244,59 @@ It returns any error message from the Constraint Validation API, and a collectio
244244

245245
## Filter
246246

247-
`<Filter>` provides common filter effects to use in a `SVGElement`. Each filter effect is indentified by a `name` property.
247+
`<Filter>` provides common filter effects to use in a `SVGElement`.
248248

249-
**List of effects and their props:**
249+
**Effect `name`s and props:**
250250

251-
| Id | Props |
252-
| ------------ | -------------------------------------------------------------- |
253-
| glow | blur, spread, lightness, opacity |
254-
| glow-inset | blur, threshold, lightness, opacity |
255-
| gooey | tolerance |
256-
| noise | frequency, blend, color (default to black), lightness, opacity |
257-
| shadow | offsetX, offsetY, blur, spread, opacity |
258-
| shadow-inset | offsetX, offsetY, blur, threshold, opacity |
251+
| Name | Props |
252+
| ---------------- | ------------------------------------------- |
253+
| color-correction | lightness, opacity |
254+
| glow | blur, spread, lightness, opacity |
255+
| glow-inset | blur, threshold, lightness, opacity |
256+
| gooey | tolerance |
257+
| noise | frequency, blend, color, lightness, opacity |
258+
| shadow | offsetX, offsetY, blur, spread, opacity |
259+
| shadow-inset | offsetX, offsetY, blur, threshold, opacity |
259260

260-
All prop are `Number`s or numerical `String`s except for the `blend` prop of the noise filter, which should be a CSS blend mode (`String`).
261+
Default values:
261262

262-
Lightness always default to `1`, ie. with no white or black mixed in, and opacity always default to `0.5`.
263+
- color: `'black'`
264+
- lightness: `1`
265+
- opacity: `0.5`
266+
- offsetX: `0`
267+
- offsetY: `0`
263268

264-
Using a single filter effect (ie. it should not have a `in` or `result` prop):
269+
All props require a number, except `blend` (CSS blend mode) and `color` (CSS color).
270+
271+
**Usage for a single filter effect:**
265272

266273
```js
267-
<Filter id='glow-large' name='glow' blur='10' spread='3' opacity='0.3' />
268-
<Filter id='glow-small' name='glow' blur='5' spread='2' opacity='0.7' />
274+
<svg viewBox='0 0 100 100'>
275+
<Filter id='glow-large' name='glow' blur='10' spread='3' opacity='0.3' />
276+
<Filter id='glow-small' name='glow' blur='5' spread='2' opacity='0.7' />
277+
<circle filter='url(#glow-large)' cx='25' cy='25' r='25'>
278+
<circle filter='url(#glow-small)' cx='75' cy='75' r='25'>
279+
</svg>
269280
```
270281

271-
**Note:** `id` will default to `name` if not provided.
282+
- it should not have a `in` or `result` prop
283+
- it will automatically be wrapped in a `<filter>`
284+
- default `'id'` is `'name'`
285+
- default `'width'`, `'height'` are based on `'name'`
286+
- default `'x'` is based on `'width'` and default `'y'` is based on `'height'`
287+
- `'width'`, `'height'`, `'x'`, `'y'` should be provided as percentage values
288+
272289

273-
Composing filter effects (ie. it should have a `in` and/or a `result` prop):
290+
**Usage for composing filter effects:**
274291

275292
```js
276-
<filter id='glow-noise' x='-100%' y='-100%' height='300%' width='300%'>
277-
<Filter name='glow' blur='10' spread='3' result='glow' />
278-
<Filter name='noise' in='glow' opacity='0.2' frequency='0.2' />
279-
</filter>
293+
<svg viewBox='0 0 100 100'>
294+
<filter id='glow-noise' x='-100%' y='-100%' height='300%' width='300%'>
295+
<Filter name='glow' blur='10' spread='3' result='glow' />
296+
<Filter name='noise' in='glow' opacity='0.2' frequency='0.2' />
297+
</filter>
298+
<circle filter='url(#glow-noise)' cx='50' cy='50' r='25'>
299+
</svg>
280300
```
301+
302+
It should have a `in` and/or a `result` prop.

0 commit comments

Comments
 (0)