A Clojure library with simple utilities for creating generative artwork.
This library is built around Quil, a Clojure wrapper around the Processing framework. However, most of the functions are just mathematical utilies that could be used idependently.
To see and read about my artwork, visit tylerxhobbs.com or follow me on Instagram or Twitter.
To install, add this to your dependencies in project.clj:
[genartlib "1.1.1"]
This version of genartlib is compatible with Processing 4.x and Quil 4.x. It has been tested with JDK 21.
The previous 0.x versions of genartlib were compatible with Processing/Quil 3.x and JDK 1.8.
View the API Docs.
The genartlib library has the following tools:
Under project-template/, you'll find the basic setup that I use for every new generative art project. This is geared towards creating static images.
genartlib.algebraThe following algebra-ish functions are defined:
avg - averageinterpolate / interpolate-multi - linear interpolationrescale - map from one range to anotherline-intersection - find the intersection of two lineslines-intersection-point - another way to find line intersectionsslope / point-slope - get the slope of a liney-intercept - get the y intercept point of a lineangle / point-angle - get the angle between two points in radiansangular-coords - calculate the offset location from a base point with angle and magnitudepoint-dist - distance between two pointspoint-to-line-dist - distance from a point to a linegenartlib.geometrypolygon-contains-point? - a fast test for checking if a point falls inside a polygonrotate-polygon - rotates around the average center of the polyshrink-polygon - shrink by a ratiogenartlib.curveschaikin-curve - a curve-smoothing algorithmchaikin-curve-retain-ends - a variation that preserves the original end pointscurve-length - calculate the total length of a curvesplit-curve-with-step - break up a curve into chunks with the given lengthsplit-curve-into-parts - break up a curve into chunks with equal length, given a number of parts to haveinterpolate-curve - find a point that is a given percentage along the length of a curveline-simplification - an implementation of the Ramer-Douglas-Peucker line simplification algorithmtrim-curve-to-bounds - returns a seq of sub-curves that are entirely within the bounds of the imagetrim-curve-start - removes the specified length from the start of a curvetrim-curve-end - removes the specified length from the end of a curvegenartlib.randomgauss - sample a gaussian probability distributionabs-gauss - basically shorthand for (abs (gauss ....))gauss-range - returns a seq of integers from zero to a value sampled from a Guassian distributiontriangular - sample a triangular probability distributionsimple-triangular - like triangular, but assumes a = 0 and b = cpareto-sampler / pareto-sample - sample a pareto probability distributionrandom-point-in-circle - uniform sampling of points within a circleodds - returns true or false with the given probabilitychoice - pick from a list of items with uniform probabilityweighted-choice - pick from a list of items, each with an assigned probabilityrepeatable-shuffle - a version of shuffle that uses Processing's Random, in order to ensure repeatability with the same seedlimited-shuffle - performs n swaps on a seq in order to partially shuffle itgenartlib.plottersort-curves-for-plotting - sorts a seq of curves in order to minimize plotter travel distancegenartlib.poisson-discpoisson-disc-sample - generate a seq of points from a Poisson disc set with a guaranteed minimum spacingThis namespace contains a set of macros that are useful for capturing draw operations in a sketch, and recording them (or translating) them to another format, such as an SVG that is suitable for plotting. The nice part is that the sketch will still function as normal.
with-plotter-svg-capture - create an svg file representing all line and shape operations that is suitable for plotting with an Axidraw. Note that Processing functions other than these two (e.g. ellipse, or bezier curves, or transformations) are not yet supported and are ignored.with-command-capture - captures many draw operations in an EDN format that is easy to manipulate with Clojurecommand-replay/command-replay-file - replays the results of with-command-capturew and h - shorthand for expressing a length or position in terms of percentage of the image width or height - good for using a pseudo-vector approach to creating imagespi - shorthand for (* Math.PI value)set-color-mode - set the color mode to HSV with ranges H [0, 360], S [0.0, 100.0], V [0.0, 100.0], alpha [0.0, 1.0]in? / not-in? - test if a seq contains an itembetween? - is a value inside an inclusive range?enumerate - turns a seq of items into a seq like ([0 item-0] [1 item-1] [2 item-2] ...)zip - combine two or more seqs into tuplessnap-to - snap a value to a given window size, kind of like configurable roundingvec-remove - remove an item from a vectordistinct-key - given a function f to uniquely identify items, extracts all of the distinct values in a collectionCopyright © Tyler Hobbs
Distributed under the MIT License.


企业专属的AI法律顾问
iTerms是法大大集团旗下法律子品牌,基于最先进的大语言模型(LLM)、专业的法律知识库和强大的智能体架构,帮助企业扫清合规障碍,筑牢风控防线,成为您企业专属的AI法律顾问。


稳定高效的流量提升解决方案,助力品牌曝光
稳定高效的流量提升解决方案,助力品牌曝光


最新版Sora2模型免费使用,一键生成无水印视频
最新版Sora2模型免费使用,一键生成无水印视频


实时语音翻译/同声传译工具
Transly是一个多场景的AI大语言模型驱动的同声传译、专业翻译助手,它拥有超精准的音频识别翻译能力,几乎零延迟的使用体验和支持多国语言可以让你带它走遍全球,无论你是留学生、商务人士、韩剧美剧爱好者,还是出国游玩、多国会议、跨国追星等等,都可以满足你所有需要同传的场景需求,线上线下通用,扫除语言障碍,让全世界的语言交流不再有国界。


选题、配图、成文,一站式创作,让内容运营更高效
讯飞绘文,一个AI集成平台,支持写作、选题、配图、排版和发布。高效生成适用于各类媒体的定制内容,加速品 牌传播,提升内容营销效果。


AI辅助编程,代码自动修复
Trae是一种自适应的集成开发环境(IDE),通过自动化和多元协作改变开发流程。利用Trae,团队能够更快速、精确地编写和部署代码,从而提高编程效率和项目交付速度。Trae具备上下文感知和代码自动完成功能,是提升开发效率的理想工具。


最强AI数据分析助手
小浣熊家族Raccoon,您的AI智能助手,致力于通过先进的人工智能技术,为用户提供高效、便捷的智能服务。无论是日常咨询还是专业问题解答,小浣熊都能以快速、准确的响应满足您的需求,让您的生活更加智能便捷。


像人一样思考的AI智能体
imini 是一款超级AI智能体,能根据人类指令,自主思考、自主完成、并且交付结果的AI智能体。


AI数字人视频创作平台
Keevx 一款开箱即用的AI数字人视频创作平台,广泛适用于电商广告、企业培训与社媒宣传,让全球企业与个人创作者无需拍摄剪辑,就能快速生成多语言、高质量的专业视频。


一站式AI创作平台
提供 AI 驱动的图片、视频生成及数字人等功能,助力创意创作
最新AI工具、AI资讯
独家AI资源、AI项目落地

微信扫一扫关注公众号