- Overview
- Installation
- Usage
- Mathematical Details
- Try Samila in Your Browser
- Issues & Bug Reports
- Dependencies
- Social Media
- Contribution
- References
- Acknowledgments
- Authors
- License
- Show Your Support
- Changelog
- Code of Conduct
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.
Open Hub | |
PyPI Counter | |
Github Stars |
Branch | master | dev |
CI |
Code Quality |
- Download Version 0.7 or Latest Source
- Run
pip install -r requirements.txt
orpip3 install -r requirements.txt
(Need root access) - Run
python3 setup.py install
orpython setup.py install
(Need root access)
- Check Python Packaging User Guide
- Run
pip install samila==0.7
orpip3 install samila==0.7
(Need root access)
- Run
easy_install --upgrade samila
(Need root access)
>>> import matplotlib.pyplot as plt
>>> from samila import GenerativeImage
>>> g = GenerativeImage()
>>> g.generate()
>>> g.plot()
>>> plt.show()
>>> import random
>>> import math
>>> def f1(x, y):
result = random.uniform(-1,1) * x**2 - math.sin(y**2) + abs(y-x)
return result
>>> def f2(x, y):
result = random.uniform(-1,1) * y**3 - math.cos(x**2) + 2*x
return result
>>> g = GenerativeImage(f1, f2)
>>> g.generate()
>>> g.plot()
>>> g.seed
188781
>>> plt.show()
>>> from samila import Projection
>>> g = GenerativeImage(f1, f2)
>>> g.generate()
>>> g.plot(projection=Projection.POLAR)
>>> g.seed
829730
>>> plt.show()
- Supported projections :
RECTILINEAR
,POLAR
,AITOFF
,HAMMER
,LAMBERT
,MOLLWEIDE
andRANDOM
- Default projection is
RECTILINEAR
>>> g = GenerativeImage(f1, f2)
>>> g.generate(start=-2*math.pi, step=0.01, stop=0)
>>> g.plot()
>>> g.seed
234752
>>> plt.show()
>>> g = GenerativeImage(f1, f2)
>>> g.generate()
>>> g.plot(color="yellow", bgcolor="black", projection=Projection.POLAR)
>>> g.seed
1018273
>>> plt.show()
-
Supported colors are available in
VALID_COLORS
list -
color
andbgcolor
parameters supported formats:- Color name (example:
yellow
) - RGB/RGBA (example:
(0.1,0.1,0.1)
,(0.1,0.1,0.1,0.1)
) - Hex (example:
#eeefff
) - Random (example:
random
)
- Color name (example:
>>> g = GenerativeImage(f1, f2)
>>> g.generate(seed=1018273)
>>> g.plot(projection=Projection.POLAR)
>>> plt.show()
Upload generated image directly to NFT.storage
>>> g.nft_storage(api_key="YOUR_API_KEY")
{'status': True, 'message': 'FILE_LINK'}
Save generated image
>>> g.save_image(file_adr="test.png")
{'status': True, 'message': 'FILE_PATH'}
Save generated image in higher resolutions
>>> g.save_image(file_adr="test.png", depth=5)
{'status': True, 'message': 'FILE_PATH'}
Save generated image data
>>> g.save_data(file_adr="data.json")
{'status': True, 'message': 'FILE_PATH'}
So you can load it into a GenerativeImage
instance later by
>>> g = GenerativeImage(data=open('data.json', 'r'))
Data structure:
{
"plot": {
"projection": "polar",
"bgcolor": "black",
"color": "snow",
"spot_size": 0.01
},
"matplotlib_version": "3.0.3",
"data1": [
0.3886741692042526,
22.57390286376703,
-0.1646310981668766,
66.23632344600155
],
"data2": [
-0.14588750183600108,
20.197945942677833,
0.5485453260942901,
-589.3284610518896
]
}
Save generated image config. It contains string formats of functions which is also human readable.
>>> g.save_config(file_adr="config.json")
{'status': True, 'message': 'FILE_PATH'}
So you can load it into a GenerativeImage
instance later by
>>> g = GenerativeImage(config=open('config.json', 'r'))
Config structure:
{
"matplotlib_version": "3.0.3",
"generate": {
"seed": 379184,
"stop": 3.141592653589793,
"step": 0.01,
"start": -3.141592653589793
},
"f2": "random.uniform(-1,1)*math.cos(x*(y**3))+random.uniform(-1,1)*math.ceil(y-x)",
"f1": "random.uniform(-1,1)*math.ceil(y)-random.uniform(-1,1)*y**2+random.uniform(-1,1)*abs(y-x)",
"plot": {
"color": "snow",
"bgcolor": "black",
"projection": "polar",
"spot_size": 0.01
}
}
Samila is simply a transformation between a square-shaped space from the Cartesian coordinate system to any arbitrary coordination like Polar coordinate system.
We have set of points in the first space (left square) which can be define as follow:
And bellow functions are used for transformation:
>>> def f1(x, y):
result = random.uniform(-1,1) * x**2 - math.sin(y**2) + abs(y-x)
return result
>>> def f2(x, y):
result = random.uniform(-1,1) * y**3 - math.cos(x**2) + 2*x
return result
here we uses Projection.POLAR
so later space will be the polar space and we have:
>>> g = GenerativeImage(f1, f2)
>>> g.generate(seed=10)
>>> g.plot(projection=Projection.POLAR)
Samila can be used online in interactive Jupyter Notebooks via the Binder or Colab services! Try it out now! :
- Check
examples
folder
Just fill an issue and describe it. We'll check it ASAP!
- Please complete the issue template
You can also join our discord server
master | dev |
1- Schönlieb, Carola-Bibiane, and Franz Schubert. "Random simulations for generative art construction–some examples." Journal of Mathematics and the Arts 7.1 (2013): 29-39.
2- Create Generative Art with R
3- NFT.storage : Free decentralized storage and bandwidth for NFTs
This project was funded through the Next Step Microgrant, a program established by Protocol Labs.
Give a ⭐️ if this project helped you!
If you do like our project and we hope that you do, can you please support us? Our project is not and is never going to be working for profit. We need the money just so we can continue doing what we do ;-) .
1KtNLEEeUbTEK9PdN6Ya3ZAKXaqoKUuxCy 0xcD4Db18B6664A9662123D4307B074aE968535388 Ldnz5gMcEeV8BAdsyf8FstWDC6uyYR6pgZ DDUnKpFQbBqLpFVZ9DfuVysBdr249HxVDh TCZxzPZLcJHr2qR3uPUB1tXB6L3FDSSAx7 rN7ZuRG7HDGHR5nof8nu5LrsbmSB61V1qq bnb1zglwcf0ac3d0s2f6ck5kgwvcru4tlctt4p5qef 0xcD4Db18B6664A9662123D4307B074aE968535388 Xd3Yn2qZJ7VE8nbKw2fS98aLxR5M6WUU3s GALPOLPISRHIYHLQER2TLJRGUSZH52RYDK6C3HIU4PSMNAV65Q36EGNL zil1knmz8zj88cf0exr2ry7nav9elehxfcgqu3c5e5![](https://github.com/sepandhaghighi/samila/raw/master/otherfiles/gitcoin_btn.png)