Socket
Socket
Sign inDemoInstall

led-server-utilities

Package Overview
Dependencies
137
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    led-server-utilities

Moved some utility function (interpolations & blendings) from JavaScript to a node native add-on (which will _hopefully_ speed up some of the calculations of the LED server that happen pretty often).


Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

Led Server Utilities

Moved some utility function (interpolations & blendings) from JavaScript to a node native add-on (which will hopefully speed up some of the calculations of the LED server that happen pretty often).

Functions

  • interpolatePixels - interpolates between two colors - don't use this in practice, it's slower than the JS/TS equivalent
  • interpolateTwoLayers - interpolates two layers pixel by pixel
  • applyKernelToLayer - applies a kernel to a layer
  • dimLayer - dims a layer
  • blendPixels - blends an array of pixels
  • blendTwoPixels - blends two colors
  • blendLayers - blends an array of layers pixel by pixel

Interpolations

  • Linear
  • EaseIn
  • EaseOut
  • EaseInOut

Blend Modes

Add, Subtract, Multiply, Screen, Overlay, HardLight, SoftLight, Divide, Difference, Darken, Lighten, Replace, Dissolve

Examples

const white = {r: 1, g: 1, b: 1, n: 1};
const black = {r: 0, g: 0, b: 0, n: 1};
const red = {r: 1, g: 0, b: 0, n: 1};
const green = {r: 0, g: 1, b: 0, n: 1};

interpolatePixels(white, black, 0.3);
interpolatePixels(null, black, 0.3);
interpolatePixels(null, null, 0.3);

interpolateTwoLayers(null, null, 0.3);
interpolateTwoLayers([white], [black], 0.3);
interpolateTwoLayers([white, black], [black, white], 0.3);
interpolateTwoLayers([white], [black, white], 0.3);
interpolateTwoLayers(null, [black, white], 0.3);

blendTwoPixels(red, green, 'Replace');
blendTwoPixels(red, green, 'Add');
blendTwoPixels(red, green, 'Difference', true);
blendTwoPixels(white, red, 'Multiply');

blendPixels([white, red, green], 'Difference');
blendPixels([red, green], 'Add');

blendLayers(
    [
        [white, black, red, green],
        [red, red],
        [null, null, green]
    ],
    'Replace'
);
blendLayers(
    [
        [white, black, red, green],
        [red, red],
        [null, null, green]
    ],
    'Add'
);
blendLayers(
    [
        [white, black, red, green],
        [red, red],
        [null, null, green]
    ],
    'Dissolve'
);

FAQs

Last updated on 04 Jan 2019

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc