kopia lustrzana https://github.com/sepandhaghighi/samila
109 wiersze
3.4 KiB
Python
109 wiersze
3.4 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""Samila params."""
|
|
import math
|
|
from enum import Enum
|
|
from matplotlib import colors as mcolors
|
|
|
|
SAMILA_VERSION = "0.8" # pragma: no cover
|
|
|
|
OVERVIEW = '''
|
|
Samila is a generative art generator written in Python, Samila let's you
|
|
create arts based on many thousand points. The position of every single
|
|
point is calculated by a formula, which has random parameters.
|
|
Because of the random numbers, every image looks different.
|
|
'''
|
|
|
|
DEFAULT_START = -1 * math.pi
|
|
DEFAULT_STOP = math.pi
|
|
DEFAULT_STEP = 0.01
|
|
DEFAULT_COLOR = "black"
|
|
DEFAULT_BACKGROUND_COLOR = "white"
|
|
DEFAULT_ALPHA = 0.1
|
|
DEFAULT_LINEWIDTH = 1.5
|
|
DEFAULT_IMAGE_SIZE = (10, 10)
|
|
DEFAULT_SPOT_SIZE = 0.01
|
|
DEFAULT_DEPTH = 1
|
|
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."
|
|
FIG_SAVE_SUCCESS_MESSAGE = "Everything seems good."
|
|
DATA_SAVE_SUCCESS_MESSAGE = "Everything seems good."
|
|
NO_FIG_ERROR_MESSAGE = "No figure was found. First run `generate` and `plot` methods."
|
|
DATA_TYPE_ERROR = "Provided data file is not supported. It should be either file or io.IOBase."
|
|
CONFIG_TYPE_ERROR = "Provided config file is not supported. It should be either file or io.IOBase."
|
|
CONFIG_NO_STR_FUNCTION_ERROR = "Config file can't be saved. At least one of the function1_str or function2_str is None."
|
|
PLOT_DATA_ERROR = "Plotting process can't be Done because data{0} is empty. Use generate method first."
|
|
SAVE_NO_DATA_ERROR = "Data file can't be saved. At least one of the data1 or data2 is None."
|
|
INVALID_COLOR_TYPE_ERROR = "Given color/bgcolor type is not supported."
|
|
MATPLOTLIB_VERSION_WARNING = "Source matplotlib version({0}) is different from yours, plots may be different."
|
|
CALCULATION_EXCEPTION_WARNING = "The given functions are undefined at some points. Your plot may not be complete."
|
|
BOTH_COLOR_COMPLEMENT_WARNING = "It is not possible to set color and bgcolor to 'complement' at the same time! Both are automatically set to the previous or default selection."
|
|
COLOR_NOT_FOUND_WARNING = "color '{0}' not found. Replacing it with '{1}'"
|
|
|
|
|
|
class Projection(Enum):
|
|
"""
|
|
Samila Projection type class.
|
|
|
|
>>> projection = samila.Projection.POLAR
|
|
"""
|
|
|
|
DEFAULT = DEFAULT_PROJECTION
|
|
POLAR = "polar"
|
|
AITOFF = "aitoff"
|
|
HAMMER = "hammer"
|
|
LAMBERT = "lambert"
|
|
MOLLWEIDE = "mollweide"
|
|
RECTILINEAR = "rectilinear"
|
|
RANDOM = "random"
|
|
|
|
|
|
RANDOM_COEF_LIST = [
|
|
"random.uniform(-1,1)",
|
|
"random.gauss(0,1)",
|
|
"random.betavariate(1,1)",
|
|
"random.gammavariate(1,1)",
|
|
"random.lognormvariate(0,1)"]
|
|
|
|
ELEMENTS_LIST = [
|
|
"{0}*math.atan({1})",
|
|
"{0}*math.asinh({1})",
|
|
"{0}*math.acosh(abs({1})+1)",
|
|
"{0}*math.erf({1})",
|
|
"{0}*math.sqrt(abs({1}))",
|
|
"{0}*math.log(abs({1})+1)",
|
|
"{0}*math.tanh({1})",
|
|
"{0}*math.cos({1})",
|
|
"{0}*math.sin({1})",
|
|
"{0}*{1}",
|
|
"{0}*abs({1})",
|
|
"{0}*math.ceil({1})",
|
|
"{0}*math.floor({1})"]
|
|
|
|
ARGUMENTS_LIST = [
|
|
"x*y",
|
|
"x",
|
|
"y",
|
|
"y-x",
|
|
"x-y",
|
|
"x+y",
|
|
"x**3",
|
|
"y**3",
|
|
"x**2",
|
|
"y**2",
|
|
"(x**2)*y",
|
|
"(y**2)*x",
|
|
"(y**2)+(x**2)",
|
|
"(y**2)-(x**2)",
|
|
"(x**2)*(y**3)",
|
|
"(x**3)*(y**2)",
|
|
"x*(y**3)",
|
|
"y*(x**3)"]
|
|
|
|
OPERATORS_LIST = ["+", "-", "*", "/"]
|