Skip to content

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
exogen committed Oct 10, 2024
1 parent 2767c8d commit ae6c70f
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,18 @@ converted from arbitrary color to Turbo. The alpha channel is copied as-is.
| ---------- | ---------- |
| `convertColorBufferToTurbo` | `(buffer: ArrayBufferLike, targetBuffer?: ArrayBufferLike, options?: { cache: Map<string, number>; }) => ArrayBufferLike` |

Parameters:

* `buffer`: A buffer containing RGBA intensities, such as one backing
an ImageData instance.
* `targetBuffer`: A same-sized buffer to write converted RGBA intensities
to. If not provided, one will automatically be created. You can pass the
same buffer provided as input to convert in-place.
* `options.cache`: A Map to use as a lookup cache, to avoid repeated
nearest-neighbor searches. If not provided, a temporary one will be used
for each function call.


### :gear: convertGrayscaleBufferToTurbo

Given an ArrayBuffer-like `buffer` containing RGBA intensities, return a new
Expand All @@ -182,6 +194,15 @@ converted from grayscale to Turbo. The alpha channel is copied as-is.
| ---------- | ---------- |
| `convertGrayscaleBufferToTurbo` | `(buffer: ArrayBufferLike, targetBuffer?: ArrayBufferLike) => ArrayBufferLike` |

Parameters:

* `buffer`: A buffer containing RGBA intensities, such as one backing
an ImageData instance.
* `targetBuffer`: A same-sized buffer to write converted RGBA intensities
to. If not provided, one will automatically be created. You can pass the
same buffer provided as input to convert in-place.



## :wrench: Constants

Expand Down
17 changes: 17 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,8 @@ export function grayscaleToTurbo(gray: Color) {
/**
* Convert a float in the range 0-1 to an integer in the range 0-255. This is
* not specific to Turbo.
*
* @param value - A number in the range 0-1.
*/
function normalizedToIntensity(value: number): number {
return Math.floor(value * 255);
Expand Down Expand Up @@ -270,6 +272,15 @@ export function convertTurboBufferToGrayscale(
* Given an ArrayBuffer-like `buffer` containing RGBA intensities, return a new
* ArrayBuffer (or the provided `targetBuffer`) with the RGB pixel values
* converted from arbitrary color to Turbo. The alpha channel is copied as-is.
*
* @param buffer A buffer containing RGBA intensities, such as one backing
* an ImageData instance.
* @param targetBuffer A same-sized buffer to write converted RGBA intensities
* to. If not provided, one will automatically be created. You can pass the
* same buffer provided as input to convert in-place.
* @param options.cache A Map to use as a lookup cache, to avoid repeated
* nearest-neighbor searches. If not provided, a temporary one will be used
* for each function call.
*/
export function convertColorBufferToTurbo(
buffer: ArrayBufferLike,
Expand All @@ -294,6 +305,12 @@ export function convertColorBufferToTurbo(
* Given an ArrayBuffer-like `buffer` containing RGBA intensities, return a new
* ArrayBuffer (or the provided `targetBuffer`) with the RGB pixel values
* converted from grayscale to Turbo. The alpha channel is copied as-is.
*
* @param buffer A buffer containing RGBA intensities, such as one backing
* an ImageData instance.
* @param targetBuffer A same-sized buffer to write converted RGBA intensities
* to. If not provided, one will automatically be created. You can pass the
* same buffer provided as input to convert in-place.
*/
export function convertGrayscaleBufferToTurbo(
buffer: ArrayBufferLike,
Expand Down

0 comments on commit ae6c70f

Please sign in to comment.