Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added mirror and reverse feature, updated readme.md and fix some whitespaces #23

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,28 @@ Clr.delPrevLine(5)
> ```
> ###### Paint your letters in a repeating pattern, by specifying an unlimited amount of Clr codes!

<br />

#### :mirror: Clr.mirror()
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (llm): The image URLs in the README for the mirror and reverse methods seem to have a typo in the repository path ('nonepork' instead of 'KennyOliver'). This will lead to broken image links in the documentation.


<img src="https://github.com/nonepork/VividHues/assets/59335048/04119e77-cf52-4c3c-86d5-c9d5922bc28e" width="40%" align="right" />

> ```python
> print( Clr.mirror(string) )
> ```
> ###### Upside down your string.

<br />

#### 🔄 Clr.reverse()

<img src="https://github.com/nonepork/VividHues/assets/59335048/a80c8f20-9e53-42a5-baed-fef1c6583913" width="40%" align="right" />

> ```python
> print( Clr.reverse(string) )
> ```
> ###### Flip and upside down your string.

<br />
<br /><br />

Expand Down
115 changes: 102 additions & 13 deletions VividHues/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def dunders() -> None:
__homepage__ = "https://github.com/KennyOliver/VividHues"
__package__ = "VividHues"
__pypi__ = "https://pypi.org/project/VividHues/"
__version__ = "5.9.2"
__version__ = "5.10.2"


class Clr:
Expand All @@ -51,19 +51,83 @@ class Clr:
LIME = "\033[92m"
YELLOW = "\033[93m"
PINK = "\033[95m"

UNDERLINE = "\033[4m"
UL = UNDERLINE
BOLD = "\033[01m"
BO = BOLD
RESET = "\033[0m"
RS = RESET


MIRROR_DICT = {
nonepork marked this conversation as resolved.
Show resolved Hide resolved
"A": "Ɐ",
"B": "B",
"C": "C",
"D": "D",
"E": "E",
"F": "ᖶ",
"G": "ᘓ",
"H": "H",
"I": "I",
"J": "ᒉ",
"K": "K",
"L": "Γ",
"M": "W",
"N": "И",
"O": "O",
"P": "b",
"Q": "⥀",
"R": "ᖉ",
"S": "Ƨ",
"T": "ꓕ",
"U": "ꓵ",
"V": "Λ",
"W": "M",
"X": "X",
"Y": "⅄",
"Z": "Z",
"a": "ɐ",
"b": "q",
"c": "ɔ",
"d": "p",
"e": "ǝ",
"f": "ɟ",
"g": "ƃ",
"h": "ɥ",
"i": "ᴉ",
"j": "ɾ",
"k": "ʞ",
"l": "l",
"m": "ɯ",
"n": "u",
"o": "o",
"p": "d",
"q": "b",
"r": "ɹ",
"s": "s",
"t": "ʇ",
"u": "n",
"v": "ʌ",
"w": "ʍ",
"x": "x",
"y": "ʎ",
"z": "z",
"0": "0",
"1": "Ɩ",
"2": "ᄅ",
"3": "Ɛ",
"4": "ㄣ",
"5": "ϛ",
"6": "9",
"7": "ㄥ",
"8": "8",
"9": "6",
}

@classmethod
def random_color(cls) -> str:
""" returns a random Clr code """

colors = [] # List of all the colors in the class Clr
for key in Clr.__dict__.keys():
if key == "UNDERLINE": # Once we got to UNDERLINE, there is no more color
Expand All @@ -77,14 +141,14 @@ def random_color(cls) -> str:
@classmethod
def random(cls, string_to_color: str) -> str:
""" chooses a random Clr code """

return f'{Clr.random_color()}' + string_to_color + Clr.RS


@classmethod
def jazzy(cls, string_to_color: str) -> str:
""" gives each letter a random color """

jazzy_str = ""

for letter in string_to_color:
Expand All @@ -96,7 +160,7 @@ def jazzy(cls, string_to_color: str) -> str:
@classmethod
def rainbow(cls, string_to_color: str) -> str:
""" colors each letter in a rainbow pattern """

rainbow_colors = [Clr.RED, Clr.ORANGE, Clr.YELLOW, Clr.GREEN, Clr.LIME, Clr.CYAN, Clr.BLUE, Clr.PURPLE, Clr.PINK]

rainbow_str = ""
Expand All @@ -109,9 +173,10 @@ def rainbow(cls, string_to_color: str) -> str:
colors_index += 1
if colors_index == 9:
colors_index = 0

return rainbow_str + Clr.RS



@classmethod
def pattern(cls, string_to_color: str, *chosen_clrs) -> str:
""" allow custom definitions of Clr patterns """
Expand All @@ -122,7 +187,7 @@ def pattern(cls, string_to_color: str, *chosen_clrs) -> str:
+ f"Expected some Clr codes, but was povided {len(chosen_clrs)}!"
+ Clr.RS
)

pattern_str = ""
string_index = 0
colors_index = 0
Expand All @@ -133,10 +198,34 @@ def pattern(cls, string_to_color: str, *chosen_clrs) -> str:
string_index += 1
if colors_index == len(chosen_clrs):
colors_index = 0

return pattern_str + Clr.RS



@classmethod
def mirror(cls, string_to_color: str) -> str:
nonepork marked this conversation as resolved.
Show resolved Hide resolved
""" flip all letters upside down """

mirror_str = ""

for letter in string_to_color:
try:
mirror_str += Clr.MIRROR_DICT[letter]
except KeyError:
mirror_str += letter

return mirror_str


@classmethod
def reverse(cls, string_to_color: str) -> str:
""" flip and reverse all letters upside down """

reverse_str = Clr.mirror(string_to_color)[::-1]

return reverse_str


def delPrevLine(repeat: int = 1) -> None:
''' erases the previous line in the CLI '''

Expand All @@ -148,7 +237,7 @@ def delPrevLine(repeat: int = 1) -> None:
)

import sys

CURSOR_UP_ONE = '\x1b[1A'
ERASE_LINE = '\x1b[2K'
for _ in range(int(repeat)):
Expand Down
Binary file added VividHues/__pycache__/__init__.cpython-312.pyc
Binary file not shown.
Binary file removed VividHues/__pycache__/__init__.cpython-39.pyc
Binary file not shown.