Project Icon

genartlib

Clojure生成艺术创作工具库

genartlib是一个基于Clojure的生成艺术创作库,提供代数、几何、曲线处理和随机采样等数学工具。该库基于Quil框架,支持静态图像生成和SVG导出,并包含项目模板和绘图命令捕获功能。genartlib旨在简化艺术家的创作流程,为生成艺术提供全面的开发环境。

genartlib

Clojars Project cljdoc badge

Ectogenesis

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.

Usage

To install, add this to your dependencies in project.clj:

[genartlib "1.1.1"]

Dependencies

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.

Contents

View the API Docs.

The genartlib library has the following tools:

Project Template

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.algebra

The following algebra-ish functions are defined:

  • avg - average
  • interpolate / interpolate-multi - linear interpolation
  • rescale - map from one range to another
  • line-intersection - find the intersection of two lines
  • lines-intersection-point - another way to find line intersections
  • slope / point-slope - get the slope of a line
  • y-intercept - get the y intercept point of a line
  • angle / point-angle - get the angle between two points in radians
  • angular-coords - calculate the offset location from a base point with angle and magnitude
  • point-dist - distance between two points
  • point-to-line-dist - distance from a point to a line

genartlib.geometry

  • polygon-contains-point? - a fast test for checking if a point falls inside a polygon
  • rotate-polygon - rotates around the average center of the poly
  • shrink-polygon - shrink by a ratio

genartlib.curves

  • chaikin-curve - a curve-smoothing algorithm
  • chaikin-curve-retain-ends - a variation that preserves the original end points
  • curve-length - calculate the total length of a curve
  • split-curve-with-step - break up a curve into chunks with the given length
  • split-curve-into-parts - break up a curve into chunks with equal length, given a number of parts to have
  • interpolate-curve - find a point that is a given percentage along the length of a curve
  • line-simplification - an implementation of the Ramer-Douglas-Peucker line simplification algorithm
  • trim-curve-to-bounds - returns a seq of sub-curves that are entirely within the bounds of the image
  • trim-curve-start - removes the specified length from the start of a curve
  • trim-curve-end - removes the specified length from the end of a curve

genartlib.random

  • gauss - sample a gaussian probability distribution
  • abs-gauss - basically shorthand for (abs (gauss ....))
  • gauss-range - returns a seq of integers from zero to a value sampled from a Guassian distribution
  • triangular - sample a triangular probability distribution
  • simple-triangular - like triangular, but assumes a = 0 and b = c
  • pareto-sampler / pareto-sample - sample a pareto probability distribution
  • random-point-in-circle - uniform sampling of points within a circle
  • odds - returns true or false with the given probability
  • choice - pick from a list of items with uniform probability
  • weighted-choice - pick from a list of items, each with an assigned probability
  • repeatable-shuffle - a version of shuffle that uses Processing's Random, in order to ensure repeatability with the same seed
  • limited-shuffle - performs n swaps on a seq in order to partially shuffle it

genartlib.plotter

  • sort-curves-for-plotting - sorts a seq of curves in order to minimize plotter travel distance

genartlib.poisson-disc

  • poisson-disc-sample - generate a seq of points from a Poisson disc set with a guaranteed minimum spacing

Capture

This 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 Clojure
  • command-replay/command-replay-file - replays the results of with-command-capture

Utils

  • w 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 images
  • pi - 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 item
  • between? - 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 tuples
  • snap-to - snap a value to a given window size, kind of like configurable rounding
  • vec-remove - remove an item from a vector
  • distinct-key - given a function f to uniquely identify items, extracts all of the distinct values in a collection

License

Copyright © Tyler Hobbs

Distributed under the MIT License.

项目侧边栏1项目侧边栏2
推荐项目
Project Cover

豆包MarsCode

豆包 MarsCode 是一款革命性的编程助手,通过AI技术提供代码补全、单测生成、代码解释和智能问答等功能,支持100+编程语言,与主流编辑器无缝集成,显著提升开发效率和代码质量。

Project Cover

AI写歌

Suno AI是一个革命性的AI音乐创作平台,能在短短30秒内帮助用户创作出一首完整的歌曲。无论是寻找创作灵感还是需要快速制作音乐,Suno AI都是音乐爱好者和专业人士的理想选择。

Project Cover

有言AI

有言平台提供一站式AIGC视频创作解决方案,通过智能技术简化视频制作流程。无论是企业宣传还是个人分享,有言都能帮助用户快速、轻松地制作出专业级别的视频内容。

Project Cover

Kimi

Kimi AI助手提供多语言对话支持,能够阅读和理解用户上传的文件内容,解析网页信息,并结合搜索结果为用户提供详尽的答案。无论是日常咨询还是专业问题,Kimi都能以友好、专业的方式提供帮助。

Project Cover

阿里绘蛙

绘蛙是阿里巴巴集团推出的革命性AI电商营销平台。利用尖端人工智能技术,为商家提供一键生成商品图和营销文案的服务,显著提升内容创作效率和营销效果。适用于淘宝、天猫等电商平台,让商品第一时间被种草。

Project Cover

吐司

探索Tensor.Art平台的独特AI模型,免费访问各种图像生成与AI训练工具,从Stable Diffusion等基础模型开始,轻松实现创新图像生成。体验前沿的AI技术,推动个人和企业的创新发展。

Project Cover

SubCat字幕猫

SubCat字幕猫APP是一款创新的视频播放器,它将改变您观看视频的方式!SubCat结合了先进的人工智能技术,为您提供即时视频字幕翻译,无论是本地视频还是网络流媒体,让您轻松享受各种语言的内容。

Project Cover

美间AI

美间AI创意设计平台,利用前沿AI技术,为设计师和营销人员提供一站式设计解决方案。从智能海报到3D效果图,再到文案生成,美间让创意设计更简单、更高效。

Project Cover

AIWritePaper论文写作

AIWritePaper论文写作是一站式AI论文写作辅助工具,简化了选题、文献检索至论文撰写的整个过程。通过简单设定,平台可快速生成高质量论文大纲和全文,配合图表、参考文献等一应俱全,同时提供开题报告和答辩PPT等增值服务,保障数据安全,有效提升写作效率和论文质量。

投诉举报邮箱: service@vectorlightyear.com
@2024 懂AI·鲁ICP备2024100362号-6·鲁公网安备37021002001498号