Coder Social home page Coder Social logo

remiscan / colori Goto Github PK

View Code? Open in Web Editor NEW
7.0 3.0 0.0 1.48 MB

Color manipulation and conversion (to CSS-supported formats and more). Available as a JavaScript module or in PHP.

Home Page: https://remiscan.fr/colori/

License: MIT License

JavaScript 0.44% PHP 48.14% TypeScript 51.39% Shell 0.04%
javascript php css-colors colors color-conversion color-manipulation rgb hsl hwb es-module

colori's Introduction

This repository is for the colori module. There's a separate one for the colori-demo website.

colori

colori is a module to manipulate colors. It started as a way for me to use color formats that were not supported in CSS yet (like LCH and OKLAB), but grew as I added more features.

I mostly wrote it with my own needs in mind, but if you think there's something for you here, have fun with it!

Features

  • color conversion: supported CSS formats are RGB (hexadecimal or functional), HSL, HWB, LAB, LCH, OKLAB, OKLCH and the color() function. Convert any color from any of these formats to any other with ease.
  • color blending: overlay multiple colors over each other and compute the resulting visible color with alpha blending. Colors can also be unblended.
  • contrast computing: calculate the contrast between two colors. Automatically modify a color to improve its contrast with another.
  • gradients: create beautiful gradients in any supported color space, avoiding the desaturated zone of native CSS gradients.
  • and more: clamp a color to a color space, compute the distance between two colors...

Check out the wiki to discover all of colori's capabilities!

How to use

JavaScript

Import the colori.min.js file at the top of your module script, and you're good to go!

import Couleur from './colori.min.js';

// Let's find the RGB expression of blue:
const color = new Couleur('blue');
console.log(color.rgb); // logs 'rgb(0, 0, 255)'

PHP

Include the colori.php file in your script, import the colori\Couleur class, and that's it!

require_once 'colori.php';
use colori\Couleur as Couleur;

// Let's find the RGB expression of blue:
$color = new Couleur('blue');
echo $color->rgb(); // prints 'rgb(0, 0, 255)'

How to build

JavaScript

To build colori.js and colori.min.js, install deno and run this in a terminal:

deno run --allow-run --allow-read --allow-write=./dist --allow-net=deno.land --allow-env build/js/build.js

If the [auto] bundle colori.js on file change task is running in VS Code, any change to any file in src/ts will automatically trigger a build.

PHP

To build colori.php, install PHP 8.1+ and run this in a terminal:

php build/php/build.php

If the [auto] bundle colori.php on file change task is running in VS Code and deno is installed, any change to any file in src/php will automatically trigger a build.

colori's People

Contributors

remiscan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

colori's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.