Giter VIP home page Giter VIP logo

colorgetter's Introduction

colorgetter

Python color getter (being able to get random/complementary/lighter/darker color, convert between rgb/hex)

Setup

python -m pip install colorgetter

Method Overview

  • get_random_color() -> tuple
  • get_color_from_stylesheet(code: str) -> None
  • get_comp_color(r: int, g: int, b: int) -> tuple
  • rgb_to_hex(r: int, g: int, b: int, digit_cnt: int = 6) -> str - Argument digit_cnt is digit count of hex color user want to get. The value of digit_cnt should be 3 or 6. It is set to 6 by default.
  • hex_to_rgb(hex: str) -> tuple - Argument hex should be 3 or 6 digit hex colors like #DDD, #ABABAB.
  • lighter(r: int, g: int, b: int) -> tuple
  • darker(r: int, g: int, b: int) -> tuple

Example

Code Sample

print(get_random_color())
print(get_comp_color(255, 0, 0))
print(hex_to_rgb('#2c2c2c'))
r, g, b = 44, 44, 44
print(rgb_to_hex(r, g, b))
light_r, light_g, light_b = lighter(r, g, b)
print(rgb_to_hex(light_r, light_g, light_b))
dark_r, dark_g, dark_b = darker(r, g, b)
print(rgb_to_hex(dark_r, dark_g, dark_b))

Result

(211, 195, 123)
(0, 255, 255)
(44, 44, 44)
#2c2c2c
#3d3d3d
#1b1b1b

colorgetter's People

Contributors

yjg30737 avatar

Stargazers

 avatar  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.