
Security News
Meet Socket at Black Hat Europe and BSides London 2025
Socket is heading to London! Stop by our booth or schedule a meeting to see what we've been working on.
Samila is a generative art generator written in Python, Samila lets you create images 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 |
pip install samila==1.6pip install .conda install -c sepandhaghighi samila>>> import matplotlib.pyplot as plt
>>> from samila import GenerativeImage
>>> g = GenerativeImage()
>>> g.generate()
>>> g.plot()
>>> plt.show()
ℹ️ You can change function generation seed by func_seed parameter in GenerativeImage
>>> 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 GenerateMode
>>> g = GenerativeImage(f1, f2)
>>> g.generate(mode=GenerateMode.F1_VS_INDEX)
>>> g.plot()
>>> g.seed
883114
>>> plt.show()
ℹ️ Supported modes : F1_VS_F2, F2_VS_F1, F1_VS_INDEX, F2_VS_INDEX, INDEX_VS_F1, INDEX_VS_F2, F1_VS_X1, F1_VS_X2, F2_VS_X1, F2_VS_X2, X1_VS_F1, X1_VS_F2, X2_VS_F1, X2_VS_F2, F1F2_VS_F1, F1F2_VS_F2, F1_VS_F1F2, F2_VS_F1F2 and RANDOM
ℹ️ Default mode is F1_VS_F2
>>> 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 and RANDOM
ℹ️ Default projection is RECTILINEAR
>>> from samila import Marker
>>> g = GenerativeImage(f1, f2)
>>> g.generate()
>>> g.plot(marker=Marker.CIRCLE, spot_size=10)
>>> g.seed
448742
>>> plt.show()
ℹ️ Supported markers : POINT, PIXEL, CIRCLE, TRIANGLE_DOWN, TRIANGLE_UP, TRIANGLE_LEFT, TRIANGLE_RIGHT, TRI_DOWN, TRI_UP, TRI_LEFT, TRI_RIGHT, OCTAGON, SQUARE, PENTAGON, PLUS, PLUS_FILLED, STAR, HEXAGON_VERTICAL, HEXAGON_HORIZONTAL, X, X_FILLED, DIAMOND, DIAMON_THIN, VLINE, HLINE and RANDOM
ℹ️ Default marker is POINT
You can even rotate your art by using rotation parameter. Enter your desired rotation for the image in degrees and you will have it.
>>> g = GenerativeImage(f1, f2)
>>> g.generate()
>>> g.plot(rotation=45)
ℹ️ Default rotation is 0
>>> g = GenerativeImage(f1, f2)
>>> g.generate(start=-2*math.pi, step=0.01, stop=0)
>>> g.plot()
>>> g.seed
234752
>>> plt.show()
ℹ️ Default range is $(-\pi, \pi)$
>>> g = GenerativeImage(f1, f2)
>>> g.generate()
>>> g.plot(color="yellow", bgcolor="black", projection=Projection.POLAR)
>>> g.seed
1018273
>>> plt.show()
ℹ️ Default color is black
ℹ️ Default background-color is white
ℹ️ Supported colors are available in VALID_COLORS list
ℹ️ color and bgcolor parameters supported formats:
color="yellow")color=(0.1,0.1,0.1), color=(0.1,0.1,0.1,0.1))color="#eeefff")color="random")color="complement", bgcolor="blue")bgcolor="transparent")color=["black", "#fffeef",...])⚠️ Transparent mode is only available for background
⚠️ List mode is only available for color
⚠️ In List mode, the length of this list must be equal to the lengths of data1 and data2
You can make your custom color map and use it in Samila.
>>> colorarray = [
... [0.7, 0.2, 0.2, 1],
... [0.6, 0.3, 0.2, 1],
... "black",
... [0.4, 0.4, 0.3, 1],
... [0.3, 0.4, 0.4, 1],
... "#ff2561"]
>>> g.generate()
>>> g.seed
454893
>>> g.plot(cmap=colorarray, color=g.data2, projection=Projection.POLAR)
>>> plt.show()
>>> g = GenerativeImage(f1, f2)
>>> g.generate(seed=1018273)
>>> g.plot(projection=Projection.POLAR)
>>> plt.show()
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
}
}
You can easily create art directly from the command line with Samila CLI. Here's an example command to get started:
samila --color=red --bgcolor=black --rotation=30 --projection=polar --mode f2_vs_f1 --save-image test.png
In this example:
--color=red: Sets the primary color of the art.--bgcolor=black: Sets the background color.--rotation=30: Rotates the artwork by 30 degrees.--projection=polar: Use polar projection for plotting.--mode=f2_vs_f1: Sets the generation mode--save-image=test.png: Saves the generated image as test.png.For more options and detailed usage, run the following command to access help:
samila --help
This will provide additional information on all available parameters and how to customize your artwork further.
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 defined as follow:
And below 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 use 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! or send an email to info@samila.site.
You can also join our discord server
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
If you use Samila in your research, we would appreciate citations to the following paper:
@article{sabouri2025samila,
title={Samila: A Generative Art Generator},
author={Sabouri, Sadra and Haghighi, Sepand and Masrour, Elena},
journal={arXiv preprint arXiv:2504.04298},
year={2025}
}
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 ;-) .
All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog and this project adheres to Semantic Versioning.
F1_VS_F1F2F2_VS_F1F2README.md updateddemo.ipynb updatedPython 3.6 support droppednft_storage methodGateway enumRANDOMF1F2_VS_F1F1F2_VS_F2--function_seed argument renamed to --function-seedREADME.md updateddemo.ipynb updateddev and master branchesPython 3.13 added to test.ymldeprecated functionF1_VS_F2F2_VS_F1F1_VS_INDEXF2_VS_INDEXINDEX_VS_F1INDEX_VS_F2F1_VS_X1F2_VS_X1F1_VS_X2F2_VS_X2X1_VS_F1X1_VS_F2X2_VS_F1X2_VS_F2bulk.ipynb notebookmode parameter added to generate methodREADME.md updateddemo.ipynb updatedfeature_request.yml templateconfig.yml for issue templateget_cmap functionGateway enumSECURITY.mdfunc_seed parameter added to GenerativeImage __init__functions.pyDEFAULT_CMAP renamed to DEFAULT_CMAP_NAMEpillow added to conda dependenciescodecov removed from dev-requirements.txtgateway parameter added to nft_storage methodREADME.md updatedPython 3.5 support droppedPython 3.12 added to test.yml__version__ attributepython_version attributeget_python_version functionRANDOM_EQUATION_MIN_COMPLEXITY parameterRANDOM_EQUATION_FOF_MAX_DEPTH parameterRANDOM_EQUATION_FOF_MIN_DEPTH parameterrotate functionrotation parameter added to plot methodtimeout parameter added to nft_storage methodload_config function modifiednft_storage_upload function modifiedRANDOM_EQUATION_GEN_COMPLEXITY parameter renamed to RANDOM_EQUATION_MAX_COMPLEXITYREADME.md updatedMarker enumget_data functionget_config functionmarker parameter added to plot methodupload_data parameter added to nft_storage methodupload_config parameter added to nft_storage methodgenerate method optimizedREADME.md updatedPython 3.11 added to test.ymlplot method warning bug fixedfill_data functionREADME.md updatedCODE_OF_CONDUCT.md updateddemo.ipynb updatedcmap parameter added to plot methodgenerate method optimizedsamila_help function updatedload_data and load_config functions error handling updatedINVALID_COLOR_TYPE_ERROR errorCOLOR_NOT_FOUND_WARNING warningBOTH_COLOR_COMPLEMENT_WARNING warningset_background functionis_valid_color functioncolor_complement functionselect_color functionbgcolor parametercolor and bgcolor parametersfilter_color function modifiedfill_data functionrandom_hex_color_gen functioncolor,bgcolor and projection parameters random modegenerate methodcolor and bgcolor parametersfilter_color function modifiedfilter_projection function modifiedis_same_data function modifiedREADME.md updatedsave_params_filter function__del__ method updatedmessage field changed in save_fig_file functionmessage field changed in save_config_file functionmessage field changed in save_data_file functionmessage field changed in nft_storage_upload functiondepth section added to config/data filelinewidth parameter added to plot methodlinewidth parameter added to plot_params_filter functionREADME.md updated__del__ methoddepth parameter added to nft_storage methoddepth parameter added to save_fig_buf functionalpha parameter added to plot methodalpha parameter added to plot_params_filter functionREADME.md updatedPLOT_DATA_ERROR error message_GI_initializer functiongenerate_params_filter functionplot_params_filter functionfilter_size functionsave_config methodload_config functionsave_config_file functionsamilaConfigError classsamilaPlotError classfilter_float functionfunction1_str attributefunction2_str attributeREADME.md updatedplot section added to data fileedgecolor changed to c in plot methodconfig parameter added to GenerativeImage __init__filter_projection function editedNO_FUNCTION_ERROR error messageDATA_PARSING_ERROR error messageJUST_DATA_WARNING warning messageload_data functionsave_data_file functionsave_data methoddata parameter added to GenerativeImage __init__ methoddepth parameter added to save_image methoddepth parameter added to save_fig_file functionsave_image and nft_storage methods background bug fixedREADME.md updatedPython 3.10 added to test.ymldependabot.ymlrequirements-splitter.pysamila_help functiontest.pyfunction_test.pyoverall_test.pynft_upload_test.pyis_same_data functionsave_image methoddev-requirements.txt updatedREADME.md updated__main__.py updatednft_storage method updatedGenerativeImage classplot methodgenerate methodnft_storage methodFAQs
A Generative Art Generator
We found that samila demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Socket is heading to London! Stop by our booth or schedule a meeting to see what we've been working on.

Security News
OWASP’s 2025 Top 10 introduces Software Supply Chain Failures as a new category, reflecting rising concern over dependency and build system risks.

Research
/Security News
Socket researchers discovered nine malicious NuGet packages that use time-delayed payloads to crash applications and corrupt industrial control systems.