Skip to content

Commit

Permalink
refactor(color): remove PD related functions, update readme
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Porter-Duff ops & pre/post-multiply moved to
new package @thi.ng/porter-duff
  • Loading branch information
postspectacular committed Jul 27, 2019
1 parent 47eef2a commit 5d868db
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 400 deletions.
39 changes: 26 additions & 13 deletions packages/color/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ This project is part of the
- [RGBA transformations](#rgba-transformations)
- [RGBA Porter-Duff compositing](#rgba-porter-duff-compositing)
- [Cosine gradients](#cosine-gradients)
- [Two-color gradients](#two-color-gradients)
- [Multi-stop gradients](#multi-stop-gradients)
- [Status](#status)
- [Installation](#installation)
Expand Down Expand Up @@ -51,10 +52,7 @@ that range, NOT in degrees.

Apart from conversions, most other operations provided by this package
are currently only supporting RGBA colors. These can also be converted
to / from sRGB (i.e. linear vs gamma corrected). Additionally, RGBA
colors can be pre-multiplied (and post-multiplied) with their alpha
channel (see [Porter-Duff](#rgba-porter-duff-compositing) section
below).
to / from sRGB (i.e. linear vs gamma corrected).

#### Class wrappers

Expand Down Expand Up @@ -85,18 +83,13 @@ including parametric preset transforms:
- luminance to alpha

Transformation matrices can be combined using matrix multiplication /
concatenation (`concat()`) for more efficient application.
concatenation (see `concat()`) for more efficient application.

### RGBA Porter-Duff compositing

The package provides all 12 basic
[Porter-Duff](https://github.com/thi-ng/umbrella/tree/master/packages/color/src/porter-duff.ts)
compositing / blending operators, both for colors with pre-multiplied
alpha and without.

![porter-duff compositing modes](https://raw.githubusercontent.com/thi-ng/umbrella/master/assets/porter-duff.png)

([Image source](http://www.svgopen.org/2005/papers/abstractsvgopen/#PorterDuffMap))
This feature has been moved to the separate
[@thi.ng/porter-duff](https://github.com/thi-ng/umbrella/tree/master/packages/porter-duff)
package.

### Cosine gradients

Expand Down Expand Up @@ -128,6 +121,26 @@ The following presets are bundled (in [`cosine-gradients.ts`](https://github.com
| ![](http://media.thi.ng/color/presets/blue-magenta-orange.svg) | ![](http://media.thi.ng/color/presets/magenta-green.svg) |
| blue-magenta-orange | magenta-green |

### Two-color gradients

The `cosineCoeffs()` function can be used to compute the cosine gradient
coefficients between 2 start/end colors:

```ts
// compute gradient coeffs between red / green
cosineGradient(10, cosineCoeffs([1,0,0,1], [0,1,0,1])).map(rgbaCss)
// #ff0000
// #f70800
// #e11e00
// #bf4000
// #966900
// #699600
// #40bf00
// #1ee100
// #08f700
// #00ff00
```

### Multi-stop gradients

The `multiCosineGradient()` function returns an iterator of raw RGBA
Expand Down
2 changes: 0 additions & 2 deletions packages/color/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,4 @@ export * from "./invert";
export * from "./luminance";
export * from "./luminance-rgb";
export * from "./mix";
export * from "./porter-duff";
export * from "./premultiply";
export * from "./transform";
Loading

0 comments on commit 5d868db

Please sign in to comment.