Skip to content

Commit 0bdd1a3

Browse files
committed
Update readme and changelog re: blend
1 parent 4db8c11 commit 0bdd1a3

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
## Culori Changelog
22

3+
### 0.8.0
4+
5+
Adds `culori.blend()` ([#59](https://github.com/Evercoder/culori/issues/59)).
6+
37
### 0.7.4
48

59
Fixes a typo that caused `formatter('rgb')('#f0f0f0f0')` and similar examples to ignore the `alpha` channel of the input color, generating `rgb(...)` instead of `rgba(...)`.

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,10 @@ Available blending modes:
432432
- `difference`
433433
- `exclusion`
434434

435+
> **Note:** culori currently implements the _separable_ blend modes, that is the blend modes that work on each channel in the color space independently. _color_, _hue_, _saturation_, and _lightness_ modes are not yet available.
436+
437+
An example of blending three colors:
438+
435439
```js
436440
culori.blend(
437441
['rgba(255, 0, 0, 0.5)', 'rgba(0, 255, 0, 0.5)', 'rgba(0, 0, 255, 0.5)'],
@@ -440,6 +444,14 @@ culori.blend(
440444
// => { mode: 'rgb', alpha: 0.875, r: 0.57..., g: 0.57..., b:0.57... }
441445
```
442446

447+
In addition to strings, the _type_ parameter supports a _function (b, s) → v_ that takes the values of the _backdrop_ and _source_ color to return the blended value. This allows you to write your own (separable) blending functions. For example, an _average_ blending mode:
448+
449+
```js
450+
culori.blend(['red', 'green'], function average(b, s) {
451+
return (b + s) / 2;
452+
});
453+
```
454+
443455
### Extending culori
444456

445457
<a name="culoriDefineMode" href="#culoriDefineMode">#</a> culori.**defineMode**(_definition_) [<>](https://github.com/evercoder/culori/blob/master/src/modes.js 'Source')

0 commit comments

Comments
 (0)