Code Monkey home page Code Monkey logo

texticon's Introduction

texticon

TextIcon generates icons based on the initials of a name.

Features

  • Full CSS font customization
  • The letters are visually centered
  • The background can be a circle or a square
  • The hue is generated based on the name
    • A randomSeed can be provided to the hue algorithm

Installation

npm install texticon

Example

import TextIcon from "texticon";

const name = "Awesome Name";
const icon = document.querySelector("#icon");
icon.src = TextIcon(name, {
    circle: true,
    size: 256,
    font: "128px Helvetica",
    randomSeed: 1234,
    foreground: {
        lightness: 0.5
    },
    background: {
        saturation: 0.2,
        lightness: 0.9
    }
});

Options

size

The size of the image in pixels. Default is 256.

font

The CSS font value. Default is "128px sans-serif".

circle

Whether to render the background as a circle or not. Default is false.

randomSeed

A seed used when generating the color of the icon based on its name. Randomize this value at each call if you want the same name to have different colors each time. Default is 0.

background

These parameters adjust how the background color looks. The following values range from 0 to 1.

  • saturation: The saturation of the background color. Default is 0.5.
  • lightness: The lightness of the background color. Default is 0.8.
  • alpha: The opacity of the background color. Default is 1.

foreground

The properties from background can also be used for adjusting the text color.

  • saturation: Default is 0.5.
  • lightness: Default is 0.5.
  • alpha: Default is 1.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Thank you

texticon's People

Stargazers

 avatar

Watchers

 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.