kopia lustrzana https://github.com/sepandhaghighi/samila
Html colors support (#117)
* add : HEX_COLOR_PATTERN added. * edit : filter_color edited so that hex color is supported now. * log : changes logged. (#116) * test : test added.pull/120/head
rodzic
168759083c
commit
b6558c5cd7
|
@ -6,6 +6,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|||
|
||||
## [Unreleased]
|
||||
### Changed
|
||||
- Hex color support for `color` and `bgcolor`
|
||||
- Test system modified
|
||||
- Random mode modified
|
||||
## [0.6] - 2022-04-13
|
||||
|
|
|
@ -4,12 +4,13 @@
|
|||
import requests
|
||||
import io
|
||||
import os
|
||||
import re
|
||||
import json
|
||||
import random
|
||||
import matplotlib
|
||||
from .params import DEFAULT_START, DEFAULT_STOP, DEFAULT_STEP, DEFAULT_COLOR, DEFAULT_IMAGE_SIZE, DEFAULT_DEPTH
|
||||
from .params import DEFAULT_BACKGROUND_COLOR, DEFAULT_SPOT_SIZE, DEFAULT_PROJECTION, DEFAULT_ALPHA, DEFAULT_LINEWIDTH
|
||||
from .params import Projection, VALID_COLORS, NFT_STORAGE_API, NFT_STORAGE_LINK, OVERVIEW
|
||||
from .params import Projection, VALID_COLORS, HEX_COLOR_PATTERN, NFT_STORAGE_API, NFT_STORAGE_LINK, OVERVIEW
|
||||
from .params import DATA_TYPE_ERROR, CONFIG_TYPE_ERROR, PLOT_DATA_ERROR, CONFIG_NO_STR_FUNCTION_ERROR
|
||||
from .params import NO_FIG_ERROR_MESSAGE, FIG_SAVE_SUCCESS_MESSAGE, NFT_STORAGE_SUCCESS_MESSAGE, SAVE_NO_DATA_ERROR
|
||||
from .params import DATA_SAVE_SUCCESS_MESSAGE, SEED_LOWER_BOUND, SEED_UPPER_BOUND
|
||||
|
@ -95,6 +96,8 @@ def filter_color(color):
|
|||
if isinstance(color, tuple):
|
||||
return color
|
||||
if isinstance(color, str):
|
||||
if re.match(HEX_COLOR_PATTERN, color):
|
||||
return color
|
||||
distance_list = list(map(lambda x: distance_calc(color, x),
|
||||
VALID_COLORS))
|
||||
min_distance = min(distance_list)
|
||||
|
|
|
@ -27,6 +27,7 @@ DEFAULT_PROJECTION = "rectilinear"
|
|||
SEED_LOWER_BOUND = 0
|
||||
SEED_UPPER_BOUND = 2**20
|
||||
VALID_COLORS = list(dict(mcolors.BASE_COLORS, **mcolors.CSS4_COLORS).keys())
|
||||
HEX_COLOR_PATTERN = r'^#(?:[0-9a-fA-F]{3}){1,2}$'
|
||||
NFT_STORAGE_API = "https://api.nft.storage/upload"
|
||||
NFT_STORAGE_LINK = "https://ipfs.io/ipfs/{}"
|
||||
NFT_STORAGE_SUCCESS_MESSAGE = "Everything seems good."
|
||||
|
|
|
@ -54,6 +54,7 @@ True
|
|||
True
|
||||
>>> from samila import GenerativeImage, Projection
|
||||
>>> g.plot(projection=Projection.POLAR, color='red', bgcolor='black')
|
||||
>>> g.plot(projection=Projection.POLAR, color="#EEE245", bgcolor="#000000")
|
||||
>>> g.plot(projection=Projection.POLAR, color=(.1, .2, .8))
|
||||
>>> g.plot(bgcolor=(.1, .2, .8), spot_size=0.1)
|
||||
>>> g.plot(size=(20, 20))
|
||||
|
|
Ładowanie…
Reference in New Issue