-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit d561d46
Showing
14 changed files
with
1,820 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
name: Publish Python 🐍 distributions 📦 to PyPI | ||
|
||
on: | ||
push: | ||
tags: | ||
- '*' | ||
|
||
jobs: | ||
build-n-publish: | ||
name: Build and publish Python 🐍 distributions 📦 to PyPI | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@master | ||
- name: Set up Python 3.12 | ||
uses: actions/setup-python@v3 | ||
with: | ||
python-version: '3.12' | ||
- name: Install pypa/setuptools | ||
run: >- | ||
python -m | ||
pip install setuptools wheel | ||
- name: Extract tag name | ||
id: tag | ||
run: echo ::set-output name=TAG_NAME::$(echo $GITHUB_REF | cut -d / -f 3) | ||
- name: Update version in setup.py | ||
run: >- | ||
sed -i "s/{{VERSION_PLACEHOLDER}}/${{ steps.tag.outputs.TAG_NAME }}/g" setup.py | ||
- name: Build a binary wheel | ||
run: >- | ||
python setup.py sdist bdist_wheel | ||
- name: Publish distribution 📦 to PyPI | ||
uses: pypa/gh-action-pypi-publish@master | ||
with: | ||
password: ${{ secrets.PYPI_API_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
__pycache__ | ||
*.pyc | ||
dist/ | ||
build/ | ||
venv/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
MIT License (Modified) | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to make derivative works based on the Software, provided that any substantial changes to the Software are clearly distinguished from the original work and are distributed under a different name. | ||
|
||
The original copyright notice and disclaimer must be retained in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS," WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES, OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT, OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
from hued.analysis import is_neutral, brightness, is_pastel, is_muted, is_vibrant | ||
|
||
def test_is_neutral(): | ||
print("Testing Neutral Color Check...") | ||
neutral_color = (128, 128, 128) # Gray | ||
non_neutral_color = (255, 0, 0) # Red | ||
assert is_neutral(neutral_color) == True, "Expected neutral color to return True." | ||
assert is_neutral(non_neutral_color) == False, "Expected non-neutral color to return False." | ||
print(f"Neutral Color Test Passed: {neutral_color} is neutral.") | ||
|
||
def test_brightness(): | ||
print("Testing Brightness Calculation...") | ||
color = (255, 255, 255) # White | ||
expected_brightness = 1.0 # Fully bright | ||
result = brightness(color) | ||
assert result == expected_brightness, f"Expected brightness {expected_brightness}, but got {result}." | ||
print(f"Brightness of {color}: {result}") | ||
|
||
def test_is_pastel(): | ||
print("Testing Pastel Color Check...") | ||
pastel_color = (255, 200, 200) # Light red | ||
non_pastel_color = (255, 0, 0) # Red | ||
assert is_pastel(pastel_color) == True, "Expected pastel color to return True." | ||
assert is_pastel(non_pastel_color) == False, "Expected non-pastel color to return False." | ||
print(f"Pastel Color Test Passed: {pastel_color} is pastel.") | ||
|
||
def test_is_muted(): | ||
print("Testing Muted Color Check...") | ||
muted_color = (100, 100, 100) # Dark gray | ||
non_muted_color = (255, 0, 0) # Red | ||
assert is_muted(muted_color) == True, "Expected muted color to return True." | ||
assert is_muted(non_muted_color) == False, "Expected non-muted color to return False." | ||
print(f"Muted Color Test Passed: {muted_color} is muted.") | ||
|
||
def test_is_vibrant(): | ||
print("Testing Vibrant Color Check...") | ||
vibrant_color = (0, 255, 0) # Green | ||
non_vibrant_color = (128, 128, 128) # Gray | ||
assert is_vibrant(vibrant_color) == True, "Expected vibrant color to return True." | ||
assert is_vibrant(non_vibrant_color) == False, "Expected non-vibrant color to return False." | ||
print(f"Vibrant Color Test Passed: {vibrant_color} is vibrant.") | ||
|
||
def run_tests(): | ||
test_is_neutral() | ||
test_brightness() | ||
test_is_pastel() | ||
test_is_muted() | ||
test_is_vibrant() | ||
print("All tests passed!") | ||
|
||
if __name__ == "__main__": | ||
run_tests() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
from hued.colors import ColorManager | ||
|
||
# Initialize the ColorManager | ||
color_manager = ColorManager() | ||
|
||
def test_hex_to_rgb(): | ||
print("Testing HEX to RGB...") | ||
hex_value = "#FF5733" # A sample hex color | ||
expected_rgb = (255, 87, 51) | ||
result = color_manager.hex_to_rgb(hex_value) | ||
assert result == expected_rgb, f"Expected {expected_rgb}, but got {result}" | ||
print(f"HEX {hex_value} -> RGB: {result}") | ||
|
||
def test_rgb_to_hex(): | ||
print("Testing RGB to HEX...") | ||
r, g, b = 0, 128, 0 # Green | ||
expected_hex = "#008000" | ||
result = color_manager.rgb_to_hex(r, g, b) | ||
assert result == expected_hex, f"Expected {expected_hex}, but got {result}" | ||
print(f"RGB({r}, {g}, {b}) -> HEX: {result}") | ||
|
||
def test_closest_color_name(): | ||
print("Testing Closest Color Name...") | ||
hex_value = "#FF0000" # Red | ||
expected_name = "Red" | ||
result = color_manager.closest_color_name(hex_value) | ||
assert result == expected_name, f"Expected {expected_name}, but got {result}" | ||
print(f"Closest color to {hex_value} is {result}") | ||
|
||
def test_get_color_by_name(): | ||
print("Testing Get Color by Name...") | ||
color_name = "Blue" | ||
expected_result = { | ||
'Name': "Blue", | ||
'Hex': "#0000FF", | ||
'RGB': (0, 0, 255) | ||
} | ||
result = color_manager.get_color_by_name(color_name) | ||
assert result == expected_result, f"Expected {expected_result}, but got {result}" | ||
print(f"{color_name} -> {result}") | ||
|
||
def run_tests(): | ||
test_hex_to_rgb() | ||
test_rgb_to_hex() | ||
test_closest_color_name() | ||
test_get_color_by_name() | ||
print("All tests passed!") | ||
|
||
if __name__ == "__main__": | ||
run_tests() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
from hued.conversions import * | ||
|
||
def test_rgb_to_hex(): | ||
print("Testing RGB to HEX...") | ||
r, g, b = 255, 0, 0 # Red | ||
expected_hex = "#FF0000" | ||
result = rgb_to_hex(r, g, b) | ||
assert result == expected_hex, f"Expected {expected_hex}, but got {result}" | ||
print(f"RGB({r}, {g}, {b}) -> HEX: {result}") | ||
|
||
def test_hex_to_rgb(): | ||
print("Testing HEX to RGB...") | ||
hex_value = "#00FF00" # Green | ||
expected_rgb = (0, 255, 0) | ||
result = hex_to_rgb(hex_value) | ||
assert result == expected_rgb, f"Expected {expected_rgb}, but got {result}" | ||
print(f"HEX {hex_value} -> RGB: {result}") | ||
|
||
def test_rgb_to_hsl(): | ||
print("Testing RGB to HSL...") | ||
r, g, b = 0, 0, 255 # Blue | ||
expected_hsl = (240, 1, 0.5) | ||
result = rgb_to_hsl(r, g, b) | ||
assert result == expected_hsl, f"Expected {expected_hsl}, but got {result}" | ||
print(f"RGB({r}, {g}, {b}) -> HSL: {result}") | ||
|
||
def test_hsl_to_rgb(): | ||
print("Testing HSL to RGB...") | ||
h, s, l = 240, 1, 0.5 # Blue in HSL | ||
expected_rgb = (0, 0, 255) | ||
result = hsl_to_rgb(h, s, l) | ||
assert result == expected_rgb, f"Expected {expected_rgb}, but got {result}" | ||
print(f"HSL({h}, {s}, {l}) -> RGB: {result}") | ||
|
||
def test_rgb_to_hsv(): | ||
print("Testing RGB to HSV...") | ||
r, g, b = 255, 255, 0 # Yellow | ||
expected_hsv = (60, 1, 1) | ||
result = rgb_to_hsv(r, g, b) | ||
assert result == expected_hsv, f"Expected {expected_hsv}, but got {result}" | ||
print(f"RGB({r}, {g}, {b}) -> HSV: {result}") | ||
|
||
def test_hsv_to_rgb(): | ||
print("Testing HSV to RGB...") | ||
h, s, v = 60, 1, 1 # Yellow in HSV | ||
expected_rgb = (255, 255, 0) | ||
result = hsv_to_rgb(h, s, v) | ||
assert result == expected_rgb, f"Expected {expected_rgb}, but got {result}" | ||
print(f"HSV({h}, {s}, {v}) -> RGB: {result}") | ||
|
||
def test_rgb_to_cmyk(): | ||
print("Testing RGB to CMYK...") | ||
r, g, b = 0, 255, 255 # Cyan | ||
expected_cmyk = (1.0, 0.0, 0.0, 0.0) | ||
result = rgb_to_cmyk(r, g, b) | ||
assert result == expected_cmyk, f"Expected {expected_cmyk}, but got {result}" | ||
print(f"RGB({r}, {g}, {b}) -> CMYK: {result}") | ||
|
||
def test_cmyk_to_rgb(): | ||
print("Testing CMYK to RGB...") | ||
c, m, y, k = 0, 1, 1, 0 # Red in CMYK | ||
expected_rgb = (255, 0, 0) | ||
result = cmyk_to_rgb(c, m, y, k) | ||
assert result == expected_rgb, f"Expected {expected_rgb}, but got {result}" | ||
print(f"CMYK({c}, {m}, {y}, {k}) -> RGB: {result}") | ||
|
||
def run_tests(): | ||
test_rgb_to_hex() | ||
test_hex_to_rgb() | ||
test_rgb_to_hsl() | ||
test_hsl_to_rgb() | ||
test_rgb_to_hsv() | ||
test_hsv_to_rgb() | ||
test_rgb_to_cmyk() | ||
test_cmyk_to_rgb() | ||
print("All tests passed!") | ||
|
||
if __name__ == "__main__": | ||
run_tests() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
from hued.palettes import ColorPalette | ||
|
||
def test_generate_complementary(): | ||
print("Testing Complementary Palette...") | ||
base_color = (255, 60, 52) # Red | ||
palette = ColorPalette(base_color) | ||
expected_complementary = [(255, 60, 52), (51, 247, 255)] # Adjust as needed | ||
result = palette.generate_complementary() | ||
assert result == expected_complementary, f"Expected {expected_complementary}, but got {result}" | ||
print(f"Complementary Palette: {result}") | ||
|
||
def test_generate_analogous(): | ||
print("Testing Analogous Palette...") | ||
base_color = (255, 60, 52) # Red | ||
palette = ColorPalette(base_color) | ||
expected_analogous = [(255, 51, 145), (255, 60, 52), (255, 161, 51)] # Adjust as needed | ||
result = palette.generate_analogous() | ||
assert result == expected_analogous, f"Expected {expected_analogous}, but got {result}" | ||
print(f"Analogous Palette: {result}") | ||
|
||
def test_generate_triadic(): | ||
print("Testing Triadic Palette...") | ||
base_color = (255, 60, 52) # Red | ||
palette = ColorPalette(base_color) | ||
expected_triadic = [(255, 60, 52), (51, 255, 59), (59, 51, 255)] # Adjust as needed | ||
result = palette.generate_triadic() | ||
assert result == expected_triadic, f"Expected {expected_triadic}, but got {result}" | ||
print(f"Triadic Palette: {result}") | ||
|
||
def test_generate_monochromatic(): | ||
print("Testing Monochromatic Palette...") | ||
base_color = (255, 60, 52) # Red | ||
palette = ColorPalette(base_color) | ||
expected_monochromatic = [(51, 2, 0), (73, 3, 0), (95, 4, 0), (118, 5, 0), | ||
(140, 5, 0), (162, 6, 0), (184, 7, 0), (206, 8, 0), | ||
(228, 9, 0), (251, 10, 0), (255, 27, 18), (255, 48, 40), | ||
(255, 70, 62), (255, 91, 84), (255, 112, 106), | ||
(255, 134, 129), (255, 155, 151), (255, 176, 173), | ||
(255, 197, 195), (255, 219, 217), (255, 240, 239), | ||
(255, 255, 255)] # Adjust as needed | ||
result = palette.generate_monochromatic() | ||
assert result == expected_monochromatic, f"Expected {expected_monochromatic}, but got {result}" | ||
print(f"Monochromatic Palette: {result}") | ||
|
||
def test_palette_to_hex(): | ||
print("Testing Palette to HEX conversion...") | ||
base_color = (255, 60, 52) # Red | ||
palette = ColorPalette(base_color) | ||
palette.generate_monochromatic() # Generate to test conversion | ||
expected_hex = ['#330200', '#490300', '#5F0400', '#760500', | ||
'#8C0500', '#A20600', '#B80700', '#CE0800', | ||
'#E40900', '#FB0A00', '#FF1B12', '#FF3028', | ||
'#FF463E', '#FF5B54', '#FF706A', '#FF8681', | ||
'#FF9B97', '#FFB0AD', '#FFC5C3', '#FFDBD9', | ||
'#FFF0EF', '#FFFFFF'] # Adjust as needed | ||
result = palette.palette_to_hex() | ||
assert result == expected_hex, f"Expected {expected_hex}, but got {result}" | ||
print(f"Palette in HEX: {result}") | ||
|
||
def test_generate_random_palette(): | ||
print("Testing Random Palette Generation...") | ||
palette = ColorPalette((0, 0, 0)) # Base color not used in random generation | ||
result = palette.generate_random_palette() | ||
assert isinstance(result, dict), "Expected a dictionary for the random palette." | ||
print("Random Palette:", result) | ||
|
||
def run_tests(): | ||
test_generate_complementary() | ||
test_generate_analogous() | ||
test_generate_triadic() | ||
test_generate_monochromatic() | ||
test_palette_to_hex() | ||
test_generate_random_palette() | ||
print("All tests passed!") | ||
|
||
if __name__ == "__main__": | ||
run_tests() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
from hued.colors import ColorManager | ||
from hued.analysis import get_temperature, is_neutral, brightness, is_pastel, is_muted, is_vibrant | ||
from hued.conversions import rgb_to_hex, hex_to_rgb, rgb_to_hsl, hsl_to_rgb, rgb_to_hsv, hsv_to_rgb, rgb_to_cmyk, cmyk_to_rgb | ||
from hued.palettes import ColorPalette |
Oops, something went wrong.