Giter Site home page Giter Site logo

euotiniel / emoji-palette Goto Github PK

View Code? Open in Web Editor NEW

This project forked from anubra266/emoji-palette

1.0 0.0 0.0 675 KB

๐Ÿ‡ Get color palettes from emojis

Home Page: https://anubra266.github.io/emoji-palette/

License: MIT License

TypeScript 82.72% CSS 13.06% HTML 4.22%

emoji-palette's Introduction


๐Ÿ‡
emoji-palette



npm package npm  downloads NPM

GitHub Repo stars


Get color palettes for emojis.




npm i emoji-palette





Install

npm i --save emoji-palette
#or
yarn add emoji-palette
#or
pnpm add emoji-palette
CleanShot 2023-01-24 at 14 50 44@2x CleanShot 2023-01-24 at 14 50 29@2x CleanShot 2023-01-24 at 14 50 15@2x

About

Came across some tweets by Shayan about LogSnag. He put up this amazing UI where gradients were formed based on a selected emoji. I scourged the comments for any hint on how he achieved this, found none, so I decided to create mine.

How does it work

When you pass in an emoji as a string, it gets drawn unto an html canvas. This allows us to get the image back as a base64 encoded image. From this, we're able to move through the pixels in the image to get all the relevant colors.

Usage

// import generatePalette
import { generatePalette } from "emoji-palette";

// Pass your emoji to this method
const palette = generatePalette("๐Ÿ‘");

The method returns an array of colors, in their order of luminance. So you can get the median color in the palette if you need one.

const dominantColor = palette[Math.floor(palette.length / 2)];

Colors are returned as rgb strings.

You can see a live demo here Codesandbox example here

Sponsors โœจ

Thanks goes to these wonderful people

emoji-palette's People

Contributors

anubra266 avatar dependabot[bot] avatar euotiniel avatar renovate[bot] avatar

Stargazers

Denizia Fernanda  avatar

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.