parent
7d64a1fe25
commit
2e15e10fd5
24 changed files with 1196 additions and 1026 deletions
1
packages/coloryou/LICENSE
Normal file
1
packages/coloryou/LICENSE
Normal file
File diff suppressed because one or more lines are too long
45
packages/coloryou/coloryou.py
Executable file
45
packages/coloryou/coloryou.py
Executable file
|
@ -0,0 +1,45 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
"""
|
||||
The original script:
|
||||
https://github.com/dharmx/vile/blob/7d486c128c7e553912673755f97b118aaab0193d/src/shell/playerctl.py#L2
|
||||
"""
|
||||
|
||||
import argparse
|
||||
import json
|
||||
from material_color_utilities_python import themeFromImage, hexFromArgb, Image
|
||||
|
||||
def range_type(value_string):
|
||||
value = int(value_string)
|
||||
if value not in range(0, 101):
|
||||
raise argparse.ArgumentTypeError("%s is out of range, choose in [0-100]" % value)
|
||||
return value
|
||||
|
||||
parser = argparse.ArgumentParser(
|
||||
prog='coloryou',
|
||||
description='This program extract Material You colors from an image. It returns them as a JSON object for scripting.')
|
||||
|
||||
parser.add_argument("image_path", help="A full path to your image", type=str)
|
||||
parser.add_argument('-i', '--image', dest='image', default=40, type=range_type, metavar='i', choices=range(0,101), help="Value should be within [0, 100] (default: %(default)s). Set the tone for the main image accent.")
|
||||
|
||||
parser.add_argument('-b', '--button', dest='button', default=90, type=range_type, metavar='i', choices=range(0,101), help="Value should be within [0, 100] (default: %(default)s). Set the tone for the button accent.")
|
||||
|
||||
parser.add_argument('-t', '--text', dest='text', default=10, type=range_type, metavar='i', choices=range(0,101), help="Value should be within [0, 100] (default: %(default)s). Set the tone for the button text accent.")
|
||||
|
||||
parser.add_argument('-o', '--hover', dest='hover', default=80, type=range_type, metavar='i', choices=range(0,101), help="Value should be within [0, 100] (default: %(default)s). Set the tone for the hovering effect accent.")
|
||||
args = parser.parse_args()
|
||||
|
||||
|
||||
img = Image.open(args.image_path)
|
||||
basewidth = 64
|
||||
wpercent = (basewidth/float(img.size[0]))
|
||||
hsize = int((float(img.size[1])*float(wpercent)))
|
||||
img = img.resize((basewidth,hsize),Image.Resampling.LANCZOS)
|
||||
|
||||
theme = themeFromImage(img).get("palettes").get("primary")
|
||||
parsed_colors = {"imageAccent": hexFromArgb(theme.tone(args.image)),
|
||||
"buttonAccent": hexFromArgb(theme.tone(args.button)),
|
||||
"buttonText": hexFromArgb(theme.tone(args.text)),
|
||||
"hoverAccent": hexFromArgb(theme.tone(args.hover))}
|
||||
|
||||
print(json.dumps(parsed_colors))
|
1
packages/coloryou/coloryou/LICENSE
Normal file
1
packages/coloryou/coloryou/LICENSE
Normal file
File diff suppressed because one or more lines are too long
45
packages/coloryou/coloryou/coloryou.py
Executable file
45
packages/coloryou/coloryou/coloryou.py
Executable file
|
@ -0,0 +1,45 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
"""
|
||||
The original script:
|
||||
https://github.com/dharmx/vile/blob/7d486c128c7e553912673755f97b118aaab0193d/src/shell/playerctl.py#L2
|
||||
"""
|
||||
|
||||
import argparse
|
||||
import json
|
||||
from material_color_utilities_python import themeFromImage, hexFromArgb, Image
|
||||
|
||||
def range_type(value_string):
|
||||
value = int(value_string)
|
||||
if value not in range(0, 101):
|
||||
raise argparse.ArgumentTypeError("%s is out of range, choose in [0-100]" % value)
|
||||
return value
|
||||
|
||||
parser = argparse.ArgumentParser(
|
||||
prog='coloryou',
|
||||
description='This program extract Material You colors from an image. It returns them as a JSON object for scripting.')
|
||||
|
||||
parser.add_argument("image_path", help="A full path to your image", type=str)
|
||||
parser.add_argument('-i', '--image', dest='image', default=40, type=range_type, metavar='i', choices=range(0,101), help="Value should be within [0, 100] (default: %(default)s). Set the tone for the main image accent.")
|
||||
|
||||
parser.add_argument('-b', '--button', dest='button', default=90, type=range_type, metavar='i', choices=range(0,101), help="Value should be within [0, 100] (default: %(default)s). Set the tone for the button accent.")
|
||||
|
||||
parser.add_argument('-t', '--text', dest='text', default=10, type=range_type, metavar='i', choices=range(0,101), help="Value should be within [0, 100] (default: %(default)s). Set the tone for the button text accent.")
|
||||
|
||||
parser.add_argument('-o', '--hover', dest='hover', default=80, type=range_type, metavar='i', choices=range(0,101), help="Value should be within [0, 100] (default: %(default)s). Set the tone for the hovering effect accent.")
|
||||
args = parser.parse_args()
|
||||
|
||||
|
||||
img = Image.open(args.image_path)
|
||||
basewidth = 64
|
||||
wpercent = (basewidth/float(img.size[0]))
|
||||
hsize = int((float(img.size[1])*float(wpercent)))
|
||||
img = img.resize((basewidth,hsize),Image.Resampling.LANCZOS)
|
||||
|
||||
theme = themeFromImage(img).get("palettes").get("primary")
|
||||
parsed_colors = {"imageAccent": hexFromArgb(theme.tone(args.image)),
|
||||
"buttonAccent": hexFromArgb(theme.tone(args.button)),
|
||||
"buttonText": hexFromArgb(theme.tone(args.text)),
|
||||
"hoverAccent": hexFromArgb(theme.tone(args.hover))}
|
||||
|
||||
print(json.dumps(parsed_colors))
|
20
packages/coloryou/coloryou/default.nix
Normal file
20
packages/coloryou/coloryou/default.nix
Normal file
|
@ -0,0 +1,20 @@
|
|||
{ python3Packages }:
|
||||
|
||||
python3Packages.buildPythonPackage rec {
|
||||
pname = "coloryou";
|
||||
version = "0.0.1";
|
||||
|
||||
src = ./.;
|
||||
|
||||
propagatedBuildInputs = with python3Packages; [ utils material-color-utilities ];
|
||||
|
||||
postInstall = ''
|
||||
mv -v $out/bin/coloryou.py $out/bin/coloryou
|
||||
'';
|
||||
|
||||
meta = {
|
||||
description = ''
|
||||
Get Material You colors from an image.
|
||||
'';
|
||||
};
|
||||
}
|
2
packages/coloryou/coloryou/requirements.txt
Normal file
2
packages/coloryou/coloryou/requirements.txt
Normal file
|
@ -0,0 +1,2 @@
|
|||
material-color-utilities
|
||||
utils
|
7
packages/coloryou/coloryou/setup.py
Normal file
7
packages/coloryou/coloryou/setup.py
Normal file
|
@ -0,0 +1,7 @@
|
|||
from distutils.core import setup
|
||||
|
||||
setup(
|
||||
name='coloryou',
|
||||
version='0.0.1',
|
||||
scripts=['coloryou.py',],
|
||||
)
|
8
packages/coloryou/coloryou/shell.nix
Normal file
8
packages/coloryou/coloryou/shell.nix
Normal file
|
@ -0,0 +1,8 @@
|
|||
with import <nixpkgs> {};
|
||||
with pkgs.python311Packages;
|
||||
|
||||
buildPythonPackage rec {
|
||||
name = "coloryou";
|
||||
src = ./.;
|
||||
propagatedBuildInputs = [ material-color-utilities utils ];
|
||||
}
|
20
packages/coloryou/default.nix
Normal file
20
packages/coloryou/default.nix
Normal file
|
@ -0,0 +1,20 @@
|
|||
{ python3Packages }:
|
||||
|
||||
python3Packages.buildPythonPackage rec {
|
||||
pname = "coloryou";
|
||||
version = "0.0.1";
|
||||
|
||||
src = ./.;
|
||||
|
||||
propagatedBuildInputs = with python3Packages; [ utils material-color-utilities ];
|
||||
|
||||
postInstall = ''
|
||||
mv -v $out/bin/coloryou.py $out/bin/coloryou
|
||||
'';
|
||||
|
||||
meta = {
|
||||
description = ''
|
||||
Get Material You colors from an image.
|
||||
'';
|
||||
};
|
||||
}
|
2
packages/coloryou/requirements.txt
Normal file
2
packages/coloryou/requirements.txt
Normal file
|
@ -0,0 +1,2 @@
|
|||
material-color-utilities
|
||||
utils
|
7
packages/coloryou/setup.py
Normal file
7
packages/coloryou/setup.py
Normal file
|
@ -0,0 +1,7 @@
|
|||
from distutils.core import setup
|
||||
|
||||
setup(
|
||||
name='coloryou',
|
||||
version='0.0.1',
|
||||
scripts=['coloryou.py',],
|
||||
)
|
8
packages/coloryou/shell.nix
Normal file
8
packages/coloryou/shell.nix
Normal file
|
@ -0,0 +1,8 @@
|
|||
with import <nixpkgs> {};
|
||||
with pkgs.python311Packages;
|
||||
|
||||
buildPythonPackage rec {
|
||||
name = "coloryou";
|
||||
src = ./.;
|
||||
propagatedBuildInputs = [ material-color-utilities utils ];
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue