Skip to content

Commit

Permalink
Add sanitizeHex to the README
Browse files Browse the repository at this point in the history
  • Loading branch information
AtomicJon committed Jun 27, 2020
1 parent 95b2cf6 commit a195d82
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,30 @@ console.log(hsv);
// Object { hue: 300, saturation: 1, value: 1 }
```

### `sanitizeHex`
Sanitizes a hex string - removing invalid characters and expanding it to 6 characters, e.g.:

```
#1 => #111111
#12 => #111222
#123 => #112233
#1234 => #112233
zz123 => #112233
```


#### Example
```js
import { sanitizeHex } from 'colorutils';

const sanitizedHex = sanitizeHex('x123!');

console.log(sanitizedHex);
// #112233
```

### `getPerceivedLuminance`
Get the perceived brightness of a given color.
Get the perceived brightness of a given color.
See: https://www.w3.org/TR/AERT/#color-contrast

#### Example
Expand Down

0 comments on commit a195d82

Please sign in to comment.