Skip to content

A powerful python module to set console color

Notifications You must be signed in to change notification settings

hushra/colorfan

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 

Repository files navigation

Colorfan

Colorfan is a powerful Python module that allows you to set console colors in your Python applications. With this module, you can add color and style to the text displayed on the terminal/command prompt.

This module was created by Hamidreza Ahmadi and is available on his GitHub page under the username hushra. You can find the source code, documentation, and examples on his page.

Installation

To install Colorfan, you can use pip:

pip install colorfan

Usage

To use Colorfan, you can import the module and use its functions as shown in the following example:

import colorfan print(colorfan.colorize(255, [100],1) + "hi")

In this example, the colorize() function is used to print "hi" in a specific color with a weight of 1. The fgcolor() and bgcolor() functions can also be used to set the foreground and background colors separately, and the uncolor() function can be used to reset the console color to its default setting.

Functions

The following functions are available in the Colorfan module:

  • colorize(fgcolor, bgcolor, weight=0): Returns the color code for a specific combination of foreground and background colors with a specified weight.
  • fgcolor(fgcolor): Returns the color code for a specific foreground color.
  • bgcolor(bgcolor): Returns the color code for a specific background color.
  • uncolor(): Resets the console color to its default setting.

Input Formats

The following functions are available in this module:

  • colorize
  • fgcolor
  • bgcolor
  • uncolor

colorize

The colorize function takes three arguments: fgcolor, bgcolor, and weight.

The fgcolor and bgcolor arguments specify the foreground and background colors for the output text, respectively. These arguments can be either RGB values or color names.

Accepted RGB values are arrays of three integers representing the red, green, and blue values for the desired color.

The weight argument specifies the weight (or intensity) of the text. It should be an integer between 0 and 99, with higher values indicating bolder text. The default value is 0.

fgcolor and bgcolor

These functions are simpler versions of colorize. They each take one argument, which is the color for the foreground or background, respectively. The format of this argument is the same as for fgcolor and bgcolor in colorize.

uncolor

The uncolor function returns the escape code to reset the terminal color back to its default value.

  • colorize
  • fgcolor
  • bgcolor
  • uncolor

Predetermined color

These variables are values that you can call predefined colors by calling them inner colorize(), fgcolor() & bgcolor():

  • red = [205,0,0]
  • green = (0,205,0)
  • white = (255,255,255)
  • black = (0,0,0)
  • gray = (50,50,50)
  • blue = (0,0,205)
  • yellow = (255, 230, 0)
  • magenra = (255,0,255)
  • cyan = (0,255,255)

For more information on how to use these functions, please refer to the documentation on Hamidreza Ahmadi's GitHub page.

Conclusion

With Colorfan, you can easily add color and style to the text displayed on the terminal/command prompt in your Python applications. This module is easy to use and highly customizable, making it a great choice for developers who want to create eye-catching console interfaces.

About

A powerful python module to set console color

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages