Movatterモバイル変換


[0]ホーム

URL:


CRANR_build_statusCodecovBugsTotalLicence

aRtsy: Generative ArtwithR andggplot2

logo

“If you laugh at a joke, what difference does it make ifsubsequently you are told that the joke was created by an algorithm?” -Marcus du Sautoy, The Creativity Code

aRtsy aims to make generative art accessible to thegeneral public in a straightforward and standardized manner. The packageprovides algorithms for creating artworks that incorporate some form ofrandomness and are dependent on the setseed. Eachalgorithm is implemented in a separate function with its own set ofparameters that can be tweaked.

Good luck hunting for some goodseed’s!

Artwork of the day

Every 24 hours this repository randomly generates and tweets anartwork from theaRtsy library. The full collection ofdaily artworks is available on thetwitter feed and themastodon feed. This istoday’s artwork:

Installation

The most recently released version ofaRtsy can bedownloaded fromCRAN by running thefollowing command in R:

install.packages("aRtsy")

Alternatively, you can download the development version from GitHubusing:

devtools::install_github("koenderks/aRtsy")

After installation, theaRtsy package can be loadedwith:

library(aRtsy)

Note: Render times in RStudio can be quite long forsome artworks. It is therefore recommended that you save the artwork toa file (e.g.,.png or.jpg) before viewing it.You can save the artwork in an appropriate size and quality using thesaveCanvas() function.

artwork<-canvas_strokes(colors =c("black","white"))saveCanvas(artwork,filename ="myArtwork.png")

Available artworks

The Iterative collection

The Geometric collection

The Supervised collection

The Static collection

The Iterative collection

The Iterative collection implements algorithms whose state depend onthe previous state. These algorithms mostly use a grid based canvas todraw on. On this grid, each point represents a pixel of the final image.By assigning a color to these points according to certain rules, one cancreate the images in this collection.

Langton’s ant

According toWikipedia,Langton’s ant is a turmite with a very specific set of rules. Inparticular, after choosing a starting position the algorithm involvesrepeating the following three rules:

  1. On a non-colored block: turn 90 degrees clockwise, un-color theblock, move forward one block,
  2. On a colored block: turn 90 degrees counter-clockwise, color theblock, move forward one block,
  3. If a certain number of iterations has passed, choose a differentcolor which corresponds to a different combination of these rules.

You can use thecanvas_ant() function to make your ownartwork using this algorithm.

set.seed(1)canvas_ant(colors =colorPalette("house"))# see ?canvas_ant for more input parameters of this function

Chladni figures

This function drawsChladni figureson the canvas. It works by generating one or multiple sine waves on asquare matrix. You can provide the waves to be added yourself. Aftergenerating the waves it is possible to warp them using adomain warpingtechnique. The angles and distances for the warp can be set manually oraccording to a type of noise.

You can use thecanvas_chladni() function to make yourown artwork using this algorithm.

set.seed(1)canvas_chladni(colors =colorPalette("tuscany1"))# see ?canvas_chladni for more input parameters of this function

Cobwebs

This function draws a lines in a structure that resemble cobwebs. Thealgorithm creates manyFibonacci spiralsshifted by random noise from a normal distribution.

You can use thecanvas_cobweb() function to make yourown artwork using this algorithm.

set.seed(1)canvas_cobweb(colors =colorPalette("tuscany1"))# see ?canvas_cobweb for more input parameters of this function

Collatz conjecture

The Collatz conjecture is also known as the3x+1equation. The algorithm draws lines according to a simple rule set:

  1. Take a random positive number.
  2. If the number is even, divide it by 2.
  3. If the number is odd, multiply the number by 3 and add 1.
  4. Repeat to get a sequence of numbers.

By visualizing the sequence for each number, overlaying sequencesthat are the same, and bending the edges differently for even and oddnumbers in the sequence, organic looking structures can occur.

You can use thecanvas_collatz() function to make yourown artwork using this algorithm.

set.seed(1)canvas_collatz(colors =colorPalette("tuscany3"))# see ?canvas_collatz for more input parameters of this function

Fractal flames

This function implements the Fractal Flame algorithm described inthis article by ScottDraves and Erik Reckase. It iterates a set of randomly determinedfunction systems following one or multiple specific variations todetermine a set of points. You can specify which variations from thearticle to include in the flame, what type of symmetry to include,whether to blend the variations using weights or to pick a singlevariation for each iteration, whether to apply a post transformation andwhether to apply a final transformation (optionally including anadditional posttransformation). The final image can either be based on athe origin of the attractors or on the log density of the hit count ofeach pixel (for a more rigid look).

You can use thecanvas_flame() function to make your ownartwork using this algorithm.

set.seed(2)canvas_flame(colors =colorPalette("dark2"))# see ?canvas_flame for more input parameters of this function

Flow fields

This artwork implements a version of the algorithm described in theblog postFlowFields by Tyler Hobbs. It works by creating a grid of angles anddetermining how certain points will flow through this field. The anglesin the field can be set manually or according to the predictions of asupervised learning method trained on randomly generated data.

You can use thecanvas_flow() function to make your ownartwork using this algorithm.

set.seed(1)canvas_flow(colors =colorPalette("dark2"))# see ?canvas_flow for more input parameters of this function

Lissajous curves

This function drawsLissajouscurves and subsequently connects the points on the curve to itsk-nearest neighbors. The function is inspired by the Lissajouscurves implemented in Marcus Volz’smathart package butadds colors into the mix.

You can use thecanvas_lissajous() function to make yourown artwork using this algorithm.

set.seed(1)canvas_lissajous(colors =colorPalette("blossom"))# see ?canvas_lissajous for more input parameters of this function

Mazes

This artwork creates mazes. The mazes are created using a random walkalgorithm (described in themazegeneratorrepository). The mazes can also be displayed with polar coordinates,creating some pretty cool effects.

You can use thecanvas_maze() function to make your ownartwork using this algorithm.

set.seed(1)canvas_maze(color ="#fafafa")# see ?canvas_maze for more input parameters of this function

Meshes

This artwork creates one or more rotating circular morphing meshes onthe canvas. The idea behind this artwork is described inthisblogpost by Dan Gries with the simple words:“deformed circlesmove across the canvas, and trace out these shapes”. The circle hasa three random components at each time step: the center, the radius, andthe increase in the radius.

You can use thecanvas_mesh() function to make your ownartwork using this algorithm.

set.seed(1)canvas_mesh(color ="#000000")# see ?canvas_mesh for more input parameters of this function

Petri dishes

This artwork uses a space colonization algorithm (excellentlydescribed inthisblogpost by Jason Webb) to draw Petri dish colonies. If you add ahole in the middle of the Petri dish, the colony grows around thehole.

You can use thecanvas_petri() function to make your ownartwork using this algorithm.

set.seed(1)canvas_petri(colors =colorPalette("sooph"))# see ?canvas_petri for more input parameters of this function

Phyllotaxis

This function draws aPhyllotaxis on thecanvas. This structure represents the arrangement of leaves on a plantstem.

You can use thecanvas_phyllotaxis() function to makeyour own artwork using this algorithm.

set.seed(1)canvas_phyllotaxis(colors =colorPalette("tuscany1"))# see ?canvas_phyllotaxis for more input parameters of this function

Planets

We all love space, and this type of artwork puts you right betweenthe planets. The algorithm creates one or multiple planets in space anduses a cellular automata (described in the blog postNeighborhoods:Experimenting with Cyclic Cellular Automata by Antonio SánchezChinchón) to fill in their surfaces. The color and placement of theplanets can be set manually.

You can use thecanvas_planet() function to make yourown artwork using this algorithm.

set.seed(1)canvas_planet(colors =colorPalette("retro3"))# see ?canvas_planet for more input parameters of this function

Recamán’s sequence

This function draws Recamán’s sequence on a canvas. The algorithmtakes increasingly large steps backwards on the positive number line,but takes a step forward if it is unable to perform the stepbackwards.

You can use thecanvas_recaman() function to make yourown artwork using this algorithm.

set.seed(1)canvas_recaman(colors =colorPalette("random",n =10))# see ?canvas_recaman for more input parameters of this function

Slime mold

This function implements thePhysarium model,which is neatly described inthis blogpostby Sage Jenson andthisblogpost by Antonio Sánchez Chinchón. The algorithm simulatesparticles on a two-dimensional grid that move towards areas on the gridwith a high intensity.

You can use thecanvas_slime() function to make your ownartwork using this algorithm.

set.seed(1)canvas_slime(colors =colorPalette("neon1"))# see ?canvas_slime for more input parameters of this function

Rainbow smoke

This function implements therainbow smoke algorithm, anoriginal idea from Jozsef Fejes. The algorithm works as follows: First,we select an initial color and apply it to a randomly chosen pixel.Next, we proceed to use the remaining colors one at the time and colorpixels in a manner where colors that are alike are positioned near eachother.

You can use thecanvas_smoke() function to make your ownartwork using this algorithm.

set.seed(1)canvas_smoke(colors =colorPalette("random",1024))# see ?canvas_smoke for more input parameters of this function

Split lines

This function generates afractal curve. Itstarts with four simple lines and proceeds to split each line in fournew line segments. If this action is repeated for some time, and eachtime the same split is made, the end product is a fractal curve. Thefractal curve in this function (optionally) uses some noise to createrandom distortions in the curve.

You can use thecanvas_splits() function to make yourown artwork using this algorithm.

set.seed(1)canvas_splits(colors =colorPalette("origami"))# see ?canvas_splits for more input parameters of this function

Stripes

This type of artwork is based on the concept ofBrownianmotion. The algorithm generates a sequence of slightly increasingand decreasing values for each row on the canvas. Next, it fills theseaccording to their generated value. More colors usually make thisartwork more interesting.

You can use thecanvas_stripes() function to make yourown artwork using this algorithm.

set.seed(1)canvas_stripes(colors =colorPalette("random",n =10))# see ?canvas_stripes for more input parameters of this function

Paint strokes

When you think of the act of painting, you probably imagine strokingpaint on a canvas. This type of artwork tries to mimic that activity.The algorithm is based on the simple idea that each next point on agrid-based canvas has a chance to take over the color of an adjacentcolored point, but also has a minor chance of generating a new color.Going over the canvas like this results in something that looks likestrokes of paint.

You can use thecanvas_strokes() function to make yourown artwork using this algorithm.

set.seed(1)canvas_strokes(colors =colorPalette("tuscany1"))# see ?canvas_strokes for more input parameters of this function

Swirls

In this artwork, inspired by Matt Deslauriers’ blog post ongenerativeart with Node.js and canvas, a particle system takes center stage,giving birth to enchanting swirling lines. The individual particles inthe system are subjected to velocities in two directions, dictating thepaths they traverse while shaping the swirls on the canvas.

You can use thecanvas_swirls() function to make yourown artwork using this algorithm.

set.seed(1)canvas_swirls(colors =colorPalette("tuscany1"))# see ?canvas_swirls for more input parameters of this function

Portuguese tiles

This function attempts to recreate the intricate designs onPortuguese-style decorative tiles. The artwork uses a reaction-diffusionalgorithm, which simulates the process of chemicals reacting anddiffusing on a surface (excellently described in these three blogposts:link,link andlink),to generate an initial quarter of each tile. Next, the initial quartertile is mirrored twice to get the symmetric look that is reminiscent oftraditional Portuguese tiles. You can fill the wall with as many uniquetiles as you want and specify a custom layout.

You can use thecanvas_tiles() function to make your ownartwork using this algorithm.

set.seed(1)canvas_tiles(colors =colorPalette("azul"))# see ?canvas_tiles for more input parameters of this function

Turmite

According toWikipedia, a turmite is“a Turing machine which has an orientation in addition to a currentstate and a”tape” that consists of an infinite two-dimensional grid ofcells”. The classic algorithm consists of repeating the followingthree simple steps:

  1. Turn on the spot (left, right, up, or down),
  2. Change the color of the block,
  3. Move forward one block.

You can use thecanvas_turmite() function to make yourown artwork using this algorithm.

set.seed(1)canvas_turmite(colors =colorPalette("dark2"))# see ?canvas_turmite for more input parameters of this function

Watercolors

This artwork implements a version of the algorithm described in theblog postAGuide to Simulating Watercolor Paint with Generative Art by TylerHobbs. It works by layering several geometric shapes and deforming eachshape by repeatedly splitting its edges.

You can use thecanvas_watercolors() function to makeyour own artwork using this algorithm.

set.seed(1)canvas_watercolors(colors =colorPalette("tuscany2"))# see ?canvas_watercolors for more input parameters of this function

The Geometric collection

The Geometric collection mostly implements algorithms that draw ageometric shape and apply a random color to it.

Diamonds

This function creates a set of diamonds on a canvas. The diamonds arefilled in (or left out) using a random color assignment.

You can use thecanvas_diamonds() function to make yourown artwork using this algorithm.

set.seed(1)canvas_diamonds(colors =colorPalette("tuscany1"))# see ?canvas_diamonds for more input parameters of this function

Functions

The idea for this type of artwork is taken over from thegenerativeartpackage. In this algorithm, the position of every single point iscalculated by a formula which has random parameters. You can supply yourown formula.

You can use thecanvas_function() function to make yourown artwork using this algorithm.

set.seed(1)canvas_function(colors =colorPalette("tuscany1"))# see ?canvas_function for more input parameters of this function

Polylines

This function draws many points on the canvas and connects thesepoints into a polygon. After repeating this for all the colors, theedges of all polygons are drawn on top of the artwork.

You can use thecanvas_polylines() function to make yourown artwork using this algorithm.

set.seed(1)canvas_polylines(colors =colorPalette("retro1"))# see ?canvas_polylines for more input parameters of this function

Ribbons

This function creates colored ribbons with (or without) a trianglethat breaks their paths. This path of the ribbon polygon is creating bypicking one point on the left side of the triangle and one point on theright side at random and using these points as nodes.

You can use thecanvas_ribbons() function to make yourown artwork using this algorithm.

set.seed(1)canvas_ribbons(colors =colorPalette("retro1")# see ?canvas_ribbons for more input parameters of this function

Segments

This type of artwork is inspired by the style of the well-knownpaintings by the Dutch artistPiet Mondriaan.The position and direction of each line segment is determinedrandomly.

You can use thecanvas_segments() function to make yourown artwork using this algorithm.

set.seed(1)canvas_segments(colors =colorPalette("dark1"))# see ?canvas_segments for more input parameters of this function

Squares and rectangles

This artwork uses a variety of squares and rectangles to fill thecanvas. It works by repeatedly cutting into the canvas at randomlocations and coloring the area that these cuts create.

You can use thecanvas_squares() function to make yourown artwork using this algorithm.

set.seed(1)canvas_squares(colors =colorPalette("retro2"))# see ?canvas_squares for more input parameters of this function

The Supervised collection

The artworks in the Supervised collection are inspired by decisionboundary plots in machine learning tasks. The algorithms in thiscollection work by generating random data points on a two dimensionalsurface (with either a continuous or a categorical response variable),which they then try to model using the supervised learning algorithm.Next, they try to predict the color of each pixel on the canvas.

Blacklights

This artwork is inspired by a supervised machine learning methodcalled support vector machines. It applies the principle as describedabove using a continuous response variable to fill the color of thepixels.

You can use thecanvas_blacklight() function to makeyour own artwork using this algorithm.

set.seed(1)canvas_blacklight(colors =colorPalette("random",n =5))# see ?canvas_blacklight for more input parameters of this function

Forests

This artwork is inspired by a supervised learning method calledrandom forest. It applies the principle as described above using acontinuous response variable to fill the color of the pixels.

You can use thecanvas_forest() function to make yourown artwork using this algorithm.

set.seed(1)canvas_forest(colors =colorPalette("jungle"))# see ?canvas_forest for more input parameters of this function

Gemstones

This artwork is inspired by a supervised learning method calledk-nearest neighbors. It applies the principle as described above using acontinuous response variable to fill the color of the pixels. In short,the k-nearest neighbors algorithm computes the distance of each pixel onthe canvas to each randomly generated data point and assigns it thecolor of the value of that data point.

You can use thecanvas_gemstone() function to make yourown artwork using this algorithm.

set.seed(1)canvas_gemstone(colors =colorPalette("dark3"))# see ?canvas_gemstone for more input parameters of this function

Mosaics

This artwork also uses a k-nearest neighbors method but instead of acontinuous response variable a categorical one is used, making it aclassification problem. If you considers fewer neighbors the artworklooks like a mosaic, while higher values make the artwork look moresmooth.

You can use thecanvas_mosaic() function to make yourown artwork using this algorithm.

set.seed(1)canvas_mosaic(colors =colorPalette("retro2"))# see ?canvas_mosaic for more input parameters of this function

Nebula

Based on the very same principle as described in the artwork above isthis next type of artwork. However, it produces slightly differentpictures as it uses different code to create a form of k-nearestneighbors noise. Some of these artworks can resemble nebulas in outerspace.

You can use thecanvas_nebula() function to make yourown artwork using this algorithm.

set.seed(1)canvas_nebula(colors =colorPalette("tuscany1"))# see ?canvas_nebula for more input parameters of this function

The Static collection

The Static collection implements static images that produce nicepictures.

Circle maps

This type of artwork is based on the concept of anArnold tongue.According to Wikipedia, Arnold tongues“are a pictorial phenomenonthat occur when visualizing how the rotation number of a dynamicalsystem, or other related invariant property thereof, changes accordingto two or more of its parameters”.

You can use thecanvas_circlemap() function to make yourown artwork using this algorithm.

canvas_circlemap(colors =colorPalette("dark2"))# see ?canvas_circlemap for more input parameters of this function

The Mandelbrot set

This type of artwork visualizes theMandelbrot setand other related fractals (e.g., theJulia set, theMultibrot set andtheBurningship fractal). These fractals are well-known examples of a complexstructure arising from the application of a simple rule set. You canzoom in on the set and apply some color to create these imagesbelow.

You can use thecanvas_mandelbrot() function to makeyour own artwork using this algorithm.

canvas_mandelbrot(colors =colorPalette("tuscany1"))# see ?canvas_mandelbrot for more input parameters of this function

Color palettes

The functioncolorPalette() can be used to generate a(semi-)random color palette, or pick a pre-implemented color palette.Currently, the color palettes displayed below are implemented inaRtsy. Feel free to suggest or add a new palette by makinganissue onGitHub!

Contributing to theaRtsy package

Contributions to theaRtsy package are very muchappreciated and you are free to suggest or add your own algorithms! Ifyou want to add your own artwork to the package so that others cancreate unique versions of it, feel free to make a pull request to theGitHub repository. Don’tforget to also adjustgenerate-artwork.Rif you want the artwork to show up in the ‘Artwork of the day’ categoryand the twitter feed.


[8]ページ先頭

©2009-2025 Movatter.jp