Samila


built with Python3 PyPI version Discord Channel
---------- ## Table of contents * [Overview](https://github.com/sepandhaghighi/samila#overview) * [Installation](https://github.com/sepandhaghighi/samila#installation) * [Usage](https://github.com/sepandhaghighi/samila#usage) * [Mathematical Details](https://github.com/sepandhaghighi/samila#mathematical-details) * [Issues & Bug Reports](https://github.com/sepandhaghighi/samila#issues--bug-reports) * [Dependencies](https://github.com/sepandhaghighi/samila#dependencies) * [Contribution](https://github.com/sepandhaghighi/samila/blob/master/.github/CONTRIBUTING.md) * [References](https://github.com/sepandhaghighi/samila#references) * [Authors](https://github.com/sepandhaghighi/samila/blob/master/AUTHORS.md) * [License](https://github.com/sepandhaghighi/samila/blob/master/LICENSE) * [Show Your Support](https://github.com/sepandhaghighi/samila#show-your-support) * [Changelog](https://github.com/sepandhaghighi/samila/blob/master/CHANGELOG.md) * [Code of Conduct](https://github.com/sepandhaghighi/samila/blob/master/.github/CODE_OF_CONDUCT.md) ## 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.

Open Hub
PyPI Counter
Github Stars
Branch master dev
CI
Code Quality codebeat badge CodeFactor
## Installation ### Source code - Download [Version 0.2](https://github.com/sepandhaghighi/samila/archive/v0.2.zip) or [Latest Source ](https://github.com/sepandhaghighi/samila/archive/dev.zip) - Run `pip install -r requirements.txt` or `pip3 install -r requirements.txt` (Need root access) - Run `python3 setup.py install` or `python setup.py install` (Need root access) ### PyPI - Check [Python Packaging User Guide](https://packaging.python.org/installing/) - Run `pip install samila==0.2` or `pip3 install samila==0.2` (Need root access) ### Easy install - Run `easy_install --upgrade samila` (Need root access) ## Usage ### Basic ```pycon >>> import random >>> import math >>> import matplotlib.pyplot as plt >>> from samila import GenerativeImage >>> 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() ``` ### Projection ```pycon >>> 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` and `MOLLWEIDE` * Default projection is `RECTILINEAR` ### Range ```pycon >>> g = GenerativeImage(f1,f2) >>> g.generate(start = -2*math.pi,step=0.1,stop=0) >>> g.plot() >>> g.seed 234752 >>> plt.show() ``` ### Color ```pycon >>> 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` and `bgcolor` parameters support color name and RGB/RGBA formats ### Regeneration ```pycon >>> g = GenerativeImage(f1,f2) >>> g.generate(seed=1018273) >>> g.plot(projection=Projection.POLAR) >>> plt.show() ``` ### NFT.storage Upload generated image directly to [NFT.storage](https://NFT.storage) ```pycon >>> g.nft_storage(api_key = YOUR_API_KEY) {'status': True, 'message': 'Everything seems good'} ``` ### Save Save generated image ```pycon >>> g.save_image(file_adr="test.png") {'status': True, 'message': 'Everything seems good'} ``` Save generated image in higher resolutions ```pycon >>> g.save_image(file_adr="test.png", depth=5) {'status': True, 'message': 'Everything seems good'} ``` ### Save data Save generated data into a file ```pycon >>> g.save_data(file_adr="test.json") ``` So you can load it into a `GenerativeImage` instance later by ```pycon >>> g = GenerativeImage(data=open('test.json', 'r')) ``` ## Mathematical details Samila is simply a transformation between a square-shaped space from the Cartesian coordinate system to any arbitrary coordination like [Polar coordinate system](https://en.wikipedia.org/wiki/Polar_coordinate_system). ### Example We have set of points in the first space (left square) which can be define as follow: And bellow functions are used for transformation: ```pycon >>> 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: ```pycon >>> g = GenerativeImage(f1,f2) >>> g.generate(seed=10) >>> g.plot(projection=Projection.POLAR) ``` ## Issues & bug reports Just fill an issue and describe it. We'll check it ASAP! or send an email to [info@4r7.ir](mailto:info@4r7.ir "info@4r7.ir"). * Please complete the issue template ## Dependencies
master dev
Requirements Status Requirements Status
## References
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
## Show your support

Star this repo

Give a ⭐️ if this project helped you!

Donate to our project

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 ;-) .

Bitcoin

1KtNLEEeUbTEK9PdN6Ya3ZAKXaqoKUuxCy

Ethereum

0xcD4Db18B6664A9662123D4307B074aE968535388

Litecoin

Ldnz5gMcEeV8BAdsyf8FstWDC6uyYR6pgZ

Doge

DDUnKpFQbBqLpFVZ9DfuVysBdr249HxVDh

Tron

TCZxzPZLcJHr2qR3uPUB1tXB6L3FDSSAx7

Ripple

rN7ZuRG7HDGHR5nof8nu5LrsbmSB61V1qq

Binance Coin

bnb1zglwcf0ac3d0s2f6ck5kgwvcru4tlctt4p5qef

Tether

0xcD4Db18B6664A9662123D4307B074aE968535388

Dash

Xd3Yn2qZJ7VE8nbKw2fS98aLxR5M6WUU3s

Stellar

GALPOLPISRHIYHLQER2TLJRGUSZH52RYDK6C3HIU4PSMNAV65Q36EGNL

Zilliqa

zil1knmz8zj88cf0exr2ry7nav9elehxfcgqu3c5e5

Coffeete