npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

color-re

v1.1.1

Published

Reason color converter

Downloads

11

Readme

Reasonml color converter

Reasonml port of color fully written in reasonml

Instalation

yarn add color-re or npm install color-re

And add package to bsconfig.json

{
  "bs-dependencies": ["color-re"]
}

Examples

/* Change the opacity */
Color.(fromRgb((200, 200, 200)) |> opacity(1.5) |> toString) |> Js.log
Color.(fromRgb((200, 200, 200)) |> toHsl |> fade(0.5) |> toString) |> Js.log
Color.(fromRgb((200, 200, 200)) |> toHsl |> opaquer(0.4) |> toString) |> Js.log

/* Color convertions */
Color.(fromRgb((200, 200, 200)) |> toHex |> toHsl |> toHsv |> toString) |> Js.log

/* Color properties */
Color.(fromRgb((200, 200, 200)) |> luminosity) |> Belt.Option.getExn |> Js.log
Color.(fromRgb((200, 200, 200)) |> contrast(fromHex("#aaafff"))) |> Belt.Option.getExn |> Js.log

Features

Pretty much every function has Aux caunterpart, which will work on pure color type.

Creation

Supported interfaces for creating color type

let fromHex: Js.String.t => option(Type.color); /* Can take in formats of #aaa #aaaaaa */
let fromRgba: ((int, int, int), float) => option(Type.color);
let fromRgb: ((int, int, int)) => option(Type.color);
let fromHsla: ((int, int, int), float) => option(Type.color);
let fromHsl: ((int, int, int)) => option(Type.color);
let fromHsv: ((int, int, int)) => option(Type.color);

Convertion

Supported interfaces from converting colors to different types. Each convertion function can take color type.

let toRgb: option(Type.color) => option(Type.color);
let toHsl: option(Type.color) => option(Type.color);
let toHex: option(Type.color) => option(Type.color);
let toHsv: option(Type.color) => option(Type.color);

Output

There currently is a single function for formatting the color If it receives None value it will return string "Failed"

let toString: option(Type.color) => string;

Modifiers

Support functions for modifying the colors. Can take any color type and will convert it back to original once modification is applied

let opacity: (float, option(Type.color)) => option(Type.color);
let opaquer: (float, option(Type.color)) => option(Type.color);
let fade: (float, option(Type.color)) => option(Type.color);
let negate: option(Type.color) => option(Type.color);
let lighten: (float, option(Type.color)) => option(Type.color);
let darken: (float, option(Type.color)) => option(Type.color);
let saturate: (float, option(Type.color)) => option(Type.color);
let desaturate: (float, option(Type.color)) => option(Type.color);
let grayscale: option(Type.color) => option(Type.color);
let rotate: (int, option(Type.color)) => option(Type.color);

Properties

Supported ways of retrieving color properties

let luminocityChannel: float => float;
let luminosity: option(Type.color) => option(float);
let contrast: (option(Type.color), option(Type.color)) => option(float);
let isDark: option(Type.color) => option(bool);
let isLight: option(Type.color) => option(bool);
let getOpacity: option(Type.color) => option(float);
let getHue: option(Type.color) => option(int);
let getLightness: option(Type.color) => option(int);
let getSaturation: option(Type.color) => option(int);