Code Monkey home page Code Monkey logo

fabisschomagut's Introduction

Converts back and forth between different color formats [(255,0,0),#ff0000, 16711680,(255,0,255) ... ]

pip install fabisschomagut

Tested against Windows 10 / Python 3.10 / Anaconda

How to use it

# Converting from one color format to another

from fabisschomagut import subtract_color,add_color,to_rgb_hex,to_rgba_hex,to_rgba_tuple,to_rgb_tuple

print(to_rgb_tuple(color="red"))
print(to_rgba_tuple(color=(255, 0, 0)))
print(to_rgb_hex(color="#ff0000"))
print(to_rgba_hex(color="0xFF0000"))


print(to_rgb_tuple(color=0xFF0000, invert=True))
print(to_rgba_tuple(color="red", invert=True))
print(to_rgb_hex(color="red", invert=True))
print(to_rgba_hex(color=(255, 0, 0), invert=True))


print(to_rgb_tuple(color="blue", invert=True))
print(to_rgba_tuple(color=(0, 255, 0), invert=True))
print(to_rgb_hex(color="ff0000", invert=False))
print(to_rgba_hex(color="#FFF000", invert=False))
print(to_rgb_tuple(color="BLUE", invert=False))
print(add_color(color1="BLUE", color2=(0, 255, 0), invert=False))

print(subtract_color(color1="pink", color2="#200000", invert=False))
print(to_rgb_hex(color=16746513, invert=False))

print(subtract_color(color1="pink", color2="0x200000", invert=False))
print(subtract_color(color1="ffc0cb", color2=0x200000, invert=False))
print(subtract_color(color1=0xFFC0CB, color2="#200000", invert=True))
print(to_rgb_hex(subtract_color(color1="pink", color2="200000", invert=True)))


# (255, 0, 0)
# (255, 0, 0, 255)
# 0xff0000
# (255, 0, 0, 255)
# 0xff0000ff
# #FF0000
# (0, 0, 255)
# (0, 0, 255, 255)
# 0x0000ff
# (0, 0, 255, 255)
# 0x0000ffff
# (255, 0, 0)
# (0, 255, 0, 255)
# 0xff0000
# (255, 240, 0, 255)
# 0xfff000ff
# (0, 0, 255)
# (0, 255, 255)
# (223, 192, 203)
# #FF8811
# 0xff8811
# (223, 192, 203)
# #200000
# (223, 192, 203)
# #FFC0CB
# (203, 192, 223)
# 0xcbc0df

fabisschomagut's People

Contributors

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