Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
bryt-lite
Advanced tools
Readme
Get colors by brightness.
bryt provides an API for getting all colors for a given brightness. A brightness is represented by
an integer between 0
and 255
. Some brightnesses have more colors than others.
Determining a color's brightness is a pretty simple calculation, but choosing a color by brightness is not. bryt-lite uses a pre-baked lookup table of brightnesses and their associated colors.
There are 16,777,216 possible 24-bit colors which takes up 66 MB. With some clever hacks and Brotli compression, we can squeeze this size down to a little over 3 MB, but this is still too big.
bryt-lite has reduced the number of colors per brightness that are similar to each other. Instead of 16 million colors, bryt-lite only has 7,204 colors and requires 66 KB on disk.
If you want the full lookup table and don't mind the 3MB size, you can always use bryt. The bryt-lite API is identical to bryt's API.
npm install bryt-lite
Get brightness info.
import * as bryt from 'bryt-lite';
const info = bryt.getBrightness(128);
console.log(`Brightness ${info.brightness} has ${info.count} colors`);
for (let i = 0; i < info.count; i++) {
console.log(`Color ${i + 1}) ${info.getColor(i)}`);
}
console.log('All colors:', info.getColors());
Get a specific color by brightness and index.
const color = bryt.getColor(200, 3);
Get all colors for a specific brightness. Note that this is not super performant.
const colors = bryt.getColors(187);
for (const color of colors) {
console.log(color);
}
Convert a integer color to an RGB array.
const color = bryt.getColor(200, 3);
const [ red, green, blue ] = bryt.toRGB(color);
console.log(`red: ${red}, green: ${green}, blue ${blue}`);
getBrightness(brightness)
brightness
(Number): A positive integer between 0 and 255.Returns Object
containing the brightness
, count
of colors, getColor(idx)
, and getColors()
.
getColor(brightness, idx)
brightness
(Number): A positive integer between 0 and 255.Returns Number
as a positive integer.
getColors(brightness)
brightness
(Number): A positive integer between 0 and 255.Returns Array<Number>
containing all colors (as integers).
toRGB(num)
num
(Number): A positive integer to split into red, green, and blue components.Returns Array<Number>
.
MIT
FAQs
Get colors by brightness.
The npm package bryt-lite receives a total of 4 weekly downloads. As such, bryt-lite popularity was classified as not popular.
We found that bryt-lite demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.