Compare commits
31 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 92623417f9 | |||
| 47e8a4b6ae | |||
| ce787650ff | |||
| f38da1da7b | |||
| aa2a46c307 | |||
| 249d88968a | |||
| 47ad86c1b3 | |||
| 3358918a96 | |||
| d210e8b717 | |||
| 2a0e05e228 | |||
| f80262b615 | |||
| 7aa46cb623 | |||
| 2a4242c57a | |||
| 8d3a3cc7f0 | |||
| bee34b6262 | |||
| f4b91ddb9a | |||
| 348c6d4dcc | |||
| d9a46c97c8 | |||
| 06d299f2f7 | |||
| cd0f55cd92 | |||
| 5f31542362 | |||
| edd5d39f73 | |||
| 73bf1e7fdf | |||
| a511742239 | |||
| abed2f36e0 | |||
| 7682408554 | |||
| 9e85fbc151 | |||
| 10408af1a2 | |||
| 23814863f1 | |||
| 8d65521fad | |||
| 707eac5087 |
@@ -19,10 +19,21 @@ pip install hyfetch
|
|||||||
Currently, these distributions have existing packages for HyFetch:
|
Currently, these distributions have existing packages for HyFetch:
|
||||||
|
|
||||||
* ArchLinux: `yay -S hyfetch` (Thanks to @ Aleksana)
|
* ArchLinux: `yay -S hyfetch` (Thanks to @ Aleksana)
|
||||||
* NixOS: `nix-env -i hyfetch` ([In Progress](https://github.com/NixOS/nixpkgs/pull/170309))
|
* Nix (Nixpkgs): `nix-env -i hyfetch` ([In Progress](https://github.com/NixOS/nixpkgs/pull/170309))
|
||||||
* Guix: [In progress](https://issues.guix.gnu.org/54847#8-lineno27)
|
* Nix (NUR): ([In Progress](https://github.com/nix-community/NUR/pull/467))
|
||||||
|
* Guix: `guix install hyfetch` (Thanks to @ WammKD)
|
||||||
|
|
||||||
Currently, if you're using NixOS, you can use HyFetch with `nix-env -if https://github.com/hykilpikonna/hyfetch/tarball/master -A hyfetch`
|
Currently, if you're using Nix the package manager or NixOS, you can use HyFetch with `nix-env -if https://github.com/hykilpikonna/hyfetch/tarball/master -A hyfetch`
|
||||||
|
|
||||||
|
> Now `hyfetch` is available in our NixOS-CN's flake. You can add [NixOS-CN](https://github.com/nixos-cn/flakes) in your [Nix Flake](https://nixos.org/manual/nix/unstable/command-ref/new-cli/nix3-flake.html) at first, then install package `hyfetch`.
|
||||||
|
> ```
|
||||||
|
> #flake.nix
|
||||||
|
>
|
||||||
|
> environment.systemPackages =
|
||||||
|
> [ nixos-cn.legacyPackages.${system}.hyfetch ];
|
||||||
|
>
|
||||||
|
> ```
|
||||||
|
> (Thanks to @ YisuiDenghua and @ linyinfeng )
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
@@ -48,8 +59,24 @@ Feel free to experiment with it!
|
|||||||
|
|
||||||
### TODO
|
### TODO
|
||||||
|
|
||||||
* [ ] Add interactive configurator for adjusting brightness
|
|
||||||
* [ ] Add configuration to emphasize certain parts of the original ASCII art (to make icons like Fedora and Ubuntu look nicer)
|
* [ ] Add configuration to emphasize certain parts of the original ASCII art (to make icons like Fedora and Ubuntu look nicer)
|
||||||
|
* [ ] Paginate flags
|
||||||
|
|
||||||
|
### 1.1.2
|
||||||
|
|
||||||
|
* Add more flags ([#5](https://github.com/hykilpikonna/hyfetch/pull/5))
|
||||||
|
* Removed `numpy` dependency that was used in 1.1.0
|
||||||
|
|
||||||
|
### 1.1.0
|
||||||
|
|
||||||
|
* Refactored a lot of things
|
||||||
|
* Added Beiyang flag xD
|
||||||
|
* Added interactive configurator for brightness adjustment
|
||||||
|
* Added dark/light mode selection
|
||||||
|
* Added color bar preview for RGB/8bit mode selection
|
||||||
|
* Added random color arrangement feature (for NixOS)
|
||||||
|
|
||||||
|
<img src="https://user-images.githubusercontent.com/22280294/180901539-014f036e-c926-4470-ac72-a6d6dcf30672.png" width="100px" />
|
||||||
|
|
||||||
### 1.0.7
|
### 1.0.7
|
||||||
|
|
||||||
|
|||||||
+26
-21
@@ -1,66 +1,71 @@
|
|||||||
|
"""
|
||||||
|
This version of color_scale is a special version made without numpy dependency. The numpy version
|
||||||
|
would be faster, but numpy is 11 MB large. In comparison, hyfetch 1.0.7 is only 105 kB, so it's not
|
||||||
|
a good idea to depend on numpy.
|
||||||
|
"""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import numpy as np
|
|
||||||
from numpy import ndarray
|
|
||||||
|
|
||||||
from .color_util import RGB
|
from .color_util import RGB
|
||||||
|
|
||||||
|
|
||||||
def create_gradient_hex(colors: list[str], resolution: int = 300) -> ndarray:
|
def create_gradient_hex(colors: list[str], resolution: int = 300) -> list[RGB]:
|
||||||
"""
|
"""
|
||||||
Create gradient array from hex
|
Create gradient array from hex
|
||||||
"""
|
"""
|
||||||
colors = np.array([RGB.from_hex(s) for s in colors])
|
colors = [RGB.from_hex(s) for s in colors]
|
||||||
return create_gradient(colors, resolution)
|
return create_gradient(colors, resolution)
|
||||||
|
|
||||||
|
|
||||||
def create_gradient(colors: ndarray, resolution: int) -> ndarray:
|
def create_gradient(colors: list[RGB], resolution: int) -> list[RGB]:
|
||||||
"""
|
"""
|
||||||
Create gradient 2d array.
|
Create gradient array
|
||||||
|
|
||||||
Usage: arr[ratio / len(arr), :] = Scaled gradient color at that point
|
Usage: arr[ratio / len(arr)] = Scaled gradient color at that point
|
||||||
"""
|
"""
|
||||||
result = np.zeros((resolution * (len(colors) - 1), 3), dtype='uint8')
|
result = []
|
||||||
|
|
||||||
# Create gradient mapping
|
# Create gradient mapping
|
||||||
for i in range(len(colors) - 1):
|
for i in range(len(colors) - 1):
|
||||||
c1 = colors[i, :]
|
c1 = colors[i]
|
||||||
c2 = colors[i + 1, :]
|
c2 = colors[i + 1]
|
||||||
bi = i * resolution
|
bi = i * resolution
|
||||||
|
|
||||||
for r in range(resolution):
|
for ri in range(resolution):
|
||||||
ratio = r / resolution
|
ratio = ri / resolution
|
||||||
result[bi + r, :] = c2 * ratio + c1 * (1 - ratio)
|
r = int(c2.r * ratio + c1.r * (1 - ratio))
|
||||||
|
g = int(c2.g * ratio + c1.g * (1 - ratio))
|
||||||
|
b = int(c2.b * ratio + c1.b * (1 - ratio))
|
||||||
|
result.append(RGB(r, g, b))
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
def get_raw(gradient: ndarray, ratio: float) -> ndarray:
|
def get_raw(gradient: list[RGB], ratio: float) -> RGB:
|
||||||
"""
|
"""
|
||||||
:param gradient: Gradient array (2d)
|
:param gradient: Gradient array (2d)
|
||||||
:param ratio: Between 0-1
|
:param ratio: Between 0-1
|
||||||
:return: RGB subarray (1d, has 3 values)
|
:return: RGB subarray (1d, has 3 values)
|
||||||
"""
|
"""
|
||||||
if ratio == 1:
|
if ratio == 1:
|
||||||
return gradient[-1, :]
|
return gradient[-1]
|
||||||
|
|
||||||
i = int(ratio * len(gradient))
|
i = int(ratio * len(gradient))
|
||||||
return gradient[i, :]
|
return gradient[i]
|
||||||
|
|
||||||
|
|
||||||
class Scale:
|
class Scale:
|
||||||
colors: ndarray
|
colors: list[RGB]
|
||||||
rgb: ndarray
|
rgb: list[RGB]
|
||||||
|
|
||||||
def __init__(self, scale: list[str], resolution: int = 300):
|
def __init__(self, scale: list[str], resolution: int = 300):
|
||||||
self.colors = np.array([RGB.from_hex(s) for s in scale])
|
self.colors = [RGB.from_hex(s) for s in scale]
|
||||||
self.rgb = create_gradient(self.colors, resolution)
|
self.rgb = create_gradient(self.colors, resolution)
|
||||||
|
|
||||||
def __call__(self, ratio: float) -> RGB:
|
def __call__(self, ratio: float) -> RGB:
|
||||||
"""
|
"""
|
||||||
:param ratio: Between 0-1
|
:param ratio: Between 0-1
|
||||||
"""
|
"""
|
||||||
return RGB(*get_raw(self.rgb, ratio))
|
return get_raw(self.rgb, ratio)
|
||||||
|
|
||||||
|
|
||||||
def test_color_scale():
|
def test_color_scale():
|
||||||
|
|||||||
@@ -0,0 +1,71 @@
|
|||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import numpy as np
|
||||||
|
from numpy import ndarray
|
||||||
|
|
||||||
|
from .color_util import RGB
|
||||||
|
|
||||||
|
|
||||||
|
def create_gradient_hex(colors: list[str], resolution: int = 300) -> ndarray:
|
||||||
|
"""
|
||||||
|
Create gradient array from hex
|
||||||
|
"""
|
||||||
|
colors = np.array([RGB.from_hex(s) for s in colors])
|
||||||
|
return create_gradient(colors, resolution)
|
||||||
|
|
||||||
|
|
||||||
|
def create_gradient(colors: ndarray, resolution: int) -> ndarray:
|
||||||
|
"""
|
||||||
|
Create gradient 2d array.
|
||||||
|
|
||||||
|
Usage: arr[ratio / len(arr), :] = Scaled gradient color at that point
|
||||||
|
"""
|
||||||
|
result = np.zeros((resolution * (len(colors) - 1), 3), dtype='uint8')
|
||||||
|
|
||||||
|
# Create gradient mapping
|
||||||
|
for i in range(len(colors) - 1):
|
||||||
|
c1 = colors[i, :]
|
||||||
|
c2 = colors[i + 1, :]
|
||||||
|
bi = i * resolution
|
||||||
|
|
||||||
|
for r in range(resolution):
|
||||||
|
ratio = r / resolution
|
||||||
|
result[bi + r, :] = c2 * ratio + c1 * (1 - ratio)
|
||||||
|
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
def get_raw(gradient: ndarray, ratio: float) -> ndarray:
|
||||||
|
"""
|
||||||
|
:param gradient: Gradient array (2d)
|
||||||
|
:param ratio: Between 0-1
|
||||||
|
:return: RGB subarray (1d, has 3 values)
|
||||||
|
"""
|
||||||
|
if ratio == 1:
|
||||||
|
return gradient[-1, :]
|
||||||
|
|
||||||
|
i = int(ratio * len(gradient))
|
||||||
|
return gradient[i, :]
|
||||||
|
|
||||||
|
|
||||||
|
class Scale:
|
||||||
|
colors: ndarray
|
||||||
|
rgb: ndarray
|
||||||
|
|
||||||
|
def __init__(self, scale: list[str], resolution: int = 300):
|
||||||
|
self.colors = np.array([RGB.from_hex(s) for s in scale])
|
||||||
|
self.rgb = create_gradient(self.colors, resolution)
|
||||||
|
|
||||||
|
def __call__(self, ratio: float) -> RGB:
|
||||||
|
"""
|
||||||
|
:param ratio: Between 0-1
|
||||||
|
"""
|
||||||
|
return RGB(*get_raw(self.rgb, ratio))
|
||||||
|
|
||||||
|
|
||||||
|
def test_color_scale():
|
||||||
|
scale = Scale(['#232323', '#4F1879', '#B43A78', '#F98766', '#FCFAC0'])
|
||||||
|
|
||||||
|
colors = 100
|
||||||
|
for i in range(colors + 1):
|
||||||
|
print(scale(i / colors).to_ansi_rgb(False), end=' ')
|
||||||
@@ -7,7 +7,7 @@ from pathlib import Path
|
|||||||
from typing_extensions import Literal
|
from typing_extensions import Literal
|
||||||
|
|
||||||
CONFIG_PATH = Path.home() / '.config/hyfetch.json'
|
CONFIG_PATH = Path.home() / '.config/hyfetch.json'
|
||||||
VERSION = '1.1.0'
|
VERSION = '1.1.2'
|
||||||
|
|
||||||
# Obtain terminal size
|
# Obtain terminal size
|
||||||
try:
|
try:
|
||||||
|
|||||||
+4
-1
@@ -27,7 +27,10 @@ def check_config() -> Config:
|
|||||||
:return: Config object
|
:return: Config object
|
||||||
"""
|
"""
|
||||||
if CONFIG_PATH.is_file():
|
if CONFIG_PATH.is_file():
|
||||||
return Config.from_dict(json.loads(CONFIG_PATH.read_text('utf-8')))
|
try:
|
||||||
|
return Config.from_dict(json.loads(CONFIG_PATH.read_text('utf-8')))
|
||||||
|
except KeyError:
|
||||||
|
return create_config()
|
||||||
|
|
||||||
return create_config()
|
return create_config()
|
||||||
|
|
||||||
|
|||||||
@@ -201,6 +201,30 @@ PRESETS: dict[str, ColorProfile] = {
|
|||||||
'#1AB3FF'
|
'#1AB3FF'
|
||||||
]),
|
]),
|
||||||
|
|
||||||
|
'polysexual': ColorProfile([
|
||||||
|
'#F714BA',
|
||||||
|
'#01D66A',
|
||||||
|
'#1594F6',
|
||||||
|
]),
|
||||||
|
|
||||||
|
# omnisexual sorced from https://www.flagcolorcodes.com/omnisexual
|
||||||
|
'omnisexual': ColorProfile([
|
||||||
|
'#FE9ACE',
|
||||||
|
'#FF53BF',
|
||||||
|
'#200044',
|
||||||
|
'#6760FE',
|
||||||
|
'#8EA6FF',
|
||||||
|
]),
|
||||||
|
|
||||||
|
# gay men sourced from https://www.flagcolorcodes.com/gay-men
|
||||||
|
'gay-men': ColorProfile([
|
||||||
|
'#078D70',
|
||||||
|
'#98E8C1',
|
||||||
|
'#FFFFFF',
|
||||||
|
'#7BADE2',
|
||||||
|
'#3D1A78'
|
||||||
|
]),
|
||||||
|
|
||||||
'lesbian': ColorProfile([
|
'lesbian': ColorProfile([
|
||||||
'#D62800',
|
'#D62800',
|
||||||
'#FF9B56',
|
'#FF9B56',
|
||||||
@@ -209,6 +233,16 @@ PRESETS: dict[str, ColorProfile] = {
|
|||||||
'#A40062'
|
'#A40062'
|
||||||
]),
|
]),
|
||||||
|
|
||||||
|
# abrosexual used colorpicker to source from
|
||||||
|
# https://fyeahaltpride.tumblr.com/post/151704251345/could-you-guys-possibly-make-an-abrosexual-pride
|
||||||
|
'abrosexual': ColorProfile([
|
||||||
|
'#46D294',
|
||||||
|
'#A3E9CA',
|
||||||
|
'#FFFFFF',
|
||||||
|
'#F78BB3',
|
||||||
|
'#EE1766',
|
||||||
|
]),
|
||||||
|
|
||||||
'asexual': ColorProfile([
|
'asexual': ColorProfile([
|
||||||
'#000000',
|
'#000000',
|
||||||
'#A4A4A4',
|
'#A4A4A4',
|
||||||
@@ -224,6 +258,35 @@ PRESETS: dict[str, ColorProfile] = {
|
|||||||
'#000000'
|
'#000000'
|
||||||
]),
|
]),
|
||||||
|
|
||||||
|
# aroace1 sourced from https://flag.library.lgbt/flags/aroace/
|
||||||
|
'aroace1': ColorProfile([
|
||||||
|
'#E28C00',
|
||||||
|
'#ECCD00',
|
||||||
|
'#FFFFFF',
|
||||||
|
'#62AEDC',
|
||||||
|
'#203856'
|
||||||
|
]),
|
||||||
|
|
||||||
|
'aroace2': ColorProfile([
|
||||||
|
'#000000',
|
||||||
|
'#810081',
|
||||||
|
'#A4A4A4',
|
||||||
|
'#FFFFFF',
|
||||||
|
'#A8D47A',
|
||||||
|
'#3BA740'
|
||||||
|
]),
|
||||||
|
|
||||||
|
'aroace3': ColorProfile([
|
||||||
|
'#3BA740',
|
||||||
|
'#A8D47A',
|
||||||
|
'#FFFFFF',
|
||||||
|
'#ABABAB',
|
||||||
|
'#000000',
|
||||||
|
'#A4A4A4',
|
||||||
|
'#FFFFFF',
|
||||||
|
'#810081'
|
||||||
|
]),
|
||||||
|
|
||||||
# below sourced from https://www.flagcolorcodes.com/flags/pride
|
# below sourced from https://www.flagcolorcodes.com/flags/pride
|
||||||
# goto f"https://www.flagcolorcodes.com/{preset}" for info
|
# goto f"https://www.flagcolorcodes.com/{preset}" for info
|
||||||
# todo: sane sorting
|
# todo: sane sorting
|
||||||
@@ -260,6 +323,51 @@ PRESETS: dict[str, ColorProfile] = {
|
|||||||
'#000000',
|
'#000000',
|
||||||
]),
|
]),
|
||||||
|
|
||||||
|
# bigender sourced from https://www.flagcolorcodes.com/bigender
|
||||||
|
'bigender': ColorProfile([
|
||||||
|
'#C479A2',
|
||||||
|
'#EDA5CD',
|
||||||
|
'#D6C7E8',
|
||||||
|
'#FFFFFF',
|
||||||
|
'#D6C7E8',
|
||||||
|
'#9AC7E8',
|
||||||
|
'#6D82D1',
|
||||||
|
]),
|
||||||
|
|
||||||
|
# demigender yellow sourced from https://lgbtqia.fandom.com/f/p/4400000000000041031
|
||||||
|
# other colors sourced from demiboy and demigirl flags
|
||||||
|
'demigender': ColorProfile([
|
||||||
|
'#7F7F7F',
|
||||||
|
'#C4C4C4',
|
||||||
|
'#FBFF75',
|
||||||
|
'#FFFFFF',
|
||||||
|
'#FBFF75',
|
||||||
|
'#C4C4C4',
|
||||||
|
'#7F7F7F',
|
||||||
|
]),
|
||||||
|
|
||||||
|
# demiboy sourced from https://www.flagcolorcodes.com/demiboy
|
||||||
|
'demiboy': ColorProfile([
|
||||||
|
'#7F7F7F',
|
||||||
|
'#C4C4C4',
|
||||||
|
'#9DD7EA',
|
||||||
|
'#FFFFFF',
|
||||||
|
'#9DD7EA',
|
||||||
|
'#C4C4C4',
|
||||||
|
'#7F7F7F',
|
||||||
|
]),
|
||||||
|
|
||||||
|
# demigirl sourced from https://www.flagcolorcodes.com/demigirl
|
||||||
|
'demigirl': ColorProfile([
|
||||||
|
'#7F7F7F',
|
||||||
|
'#C4C4C4',
|
||||||
|
'#FDADC8',
|
||||||
|
'#FFFFFF',
|
||||||
|
'#FDADC8',
|
||||||
|
'#C4C4C4',
|
||||||
|
'#7F7F7F',
|
||||||
|
]),
|
||||||
|
|
||||||
'transmasculine': ColorProfile([
|
'transmasculine': ColorProfile([
|
||||||
'#FF8ABD',
|
'#FF8ABD',
|
||||||
'#CDF5FE',
|
'#CDF5FE',
|
||||||
@@ -270,6 +378,29 @@ PRESETS: dict[str, ColorProfile] = {
|
|||||||
'#FF8ABD',
|
'#FF8ABD',
|
||||||
]),
|
]),
|
||||||
|
|
||||||
|
# transfeminine used colorpicker to source from https://www.deviantart.com/pride-flags/art/Trans-Woman-Transfeminine-1-543925985
|
||||||
|
# linked from https://gender.fandom.com/wiki/Transfeminine
|
||||||
|
'transfeminine': ColorProfile([
|
||||||
|
'#73DEFF',
|
||||||
|
'#FFE2EE',
|
||||||
|
'#FFB5D6',
|
||||||
|
'#FF8DC0',
|
||||||
|
'#FFB5D6',
|
||||||
|
'#FFE2EE',
|
||||||
|
'#73DEFF',
|
||||||
|
]),
|
||||||
|
|
||||||
|
# genderfaun sourced from https://www.flagcolorcodes.com/genderfaun
|
||||||
|
'genderfaun': ColorProfile([
|
||||||
|
'#FCD689',
|
||||||
|
'#FFF09B',
|
||||||
|
'#FAF9CD',
|
||||||
|
'#FFFFFF',
|
||||||
|
'#8EDED9',
|
||||||
|
'#8CACDE',
|
||||||
|
'#9782EC',
|
||||||
|
]),
|
||||||
|
|
||||||
'demifaun': ColorProfile([
|
'demifaun': ColorProfile([
|
||||||
'#7F7F7F',
|
'#7F7F7F',
|
||||||
'#7F7F7F',
|
'#7F7F7F',
|
||||||
@@ -286,6 +417,34 @@ PRESETS: dict[str, ColorProfile] = {
|
|||||||
'#7F7F7F',
|
'#7F7F7F',
|
||||||
]),
|
]),
|
||||||
|
|
||||||
|
# genderfae sourced from https://www.flagcolorcodes.com/genderfae
|
||||||
|
'genderfae': ColorProfile([
|
||||||
|
'#97C3A5',
|
||||||
|
'#C3DEAE',
|
||||||
|
'#F9FACD',
|
||||||
|
'#FFFFFF',
|
||||||
|
'#FCA2C4',
|
||||||
|
'#DB8AE4',
|
||||||
|
'#A97EDD',
|
||||||
|
]),
|
||||||
|
|
||||||
|
# demifae used colorpicker to source form https://www.deviantart.com/pride-flags/art/Demifae-870194777
|
||||||
|
'demifae': ColorProfile([
|
||||||
|
'#7F7F7F',
|
||||||
|
'#7F7F7F',
|
||||||
|
'#C5C5C5',
|
||||||
|
'#C5C5C5',
|
||||||
|
'#97C3A4',
|
||||||
|
'#C4DEAE',
|
||||||
|
'#FFFFFF',
|
||||||
|
'#FCA2C5',
|
||||||
|
'#AB7EDF',
|
||||||
|
'#C5C5C5',
|
||||||
|
'#C5C5C5',
|
||||||
|
'#7F7F7F',
|
||||||
|
'#7F7F7F',
|
||||||
|
]),
|
||||||
|
|
||||||
'neutrois': ColorProfile([
|
'neutrois': ColorProfile([
|
||||||
'#FFFFFF',
|
'#FFFFFF',
|
||||||
'#1F9F00',
|
'#1F9F00',
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ setup(
|
|||||||
packages=['hyfetch'],
|
packages=['hyfetch'],
|
||||||
package_data={'hyfetch': ['hyfetch/*']},
|
package_data={'hyfetch': ['hyfetch/*']},
|
||||||
include_package_data=True,
|
include_package_data=True,
|
||||||
install_requires=['setuptools', 'typing_extensions', 'numpy'],
|
install_requires=['setuptools', 'typing_extensions'],
|
||||||
entry_points={
|
entry_points={
|
||||||
"console_scripts": [
|
"console_scripts": [
|
||||||
"hyfetch=hyfetch.main:run",
|
"hyfetch=hyfetch.main:run",
|
||||||
|
|||||||
Reference in New Issue
Block a user