https://github.com/djnavarro/jasmines
miscellaneous functions for Danielle's art
https://github.com/djnavarro/jasmines
Last synced: about 8 hours ago
JSON representation
miscellaneous functions for Danielle's art
- Host: GitHub
- URL: https://github.com/djnavarro/jasmines
- Owner: djnavarro
- License: other
- Created: 2019-10-01T06:22:10.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2021-12-14T08:21:39.000Z (over 3 years ago)
- Last Synced: 2025-03-28T10:50:29.256Z (18 days ago)
- Language: R
- Homepage: https://jasmines.djnavarro.net
- Size: 3.15 MB
- Stars: 112
- Watchers: 5
- Forks: 16
- Open Issues: 8
-
Metadata Files:
- Readme: README.Rmd
- License: LICENSE
Awesome Lists containing this project
- jimsghstars - djnavarro/jasmines - miscellaneous functions for Danielle's art (R)
README
---
output: github_document
---```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# jasminesThe jasmines package is what I use to make a lot of my generative artwork with R. Internally it relies heavily on the [ambient](https://github.com/thomasp85/ambient) package, and you may need to install the developer version of ambient to make it work:
``` r
# install.packages("remotes")
# remotes::install_github("thomasp85/ambient")
remotes::install_github("djnavarro/jasmines")
```Functions in the jasmines package are designed to work with the dplyr pipe, so you will likely want to have dplyr loaded:
```{r packageload, message=FALSE, warning=FALSE}
library(dplyr)
library(jasmines)
```## Example 1
A typical jasmines pipeline looks like this:
```{r example1}
use_seed(1) %>%
entity_circle(grain = 1000) %>%
unfold_tempest(iterations = 10) %>%
style_ribbon(background = "wheat")
```The `use_seed()` function is a convenience function that sets the random number generator seed, and stores that value for later use. The seed is then piped to an `entity_` function (or a `scene_` function) that creates the initial object that will be operated upon. In this case this initial object is a circle of diameter 2 rendered using 1000 points. This is then passed to an `unfold_` function, that iteratively applies some operation (in this case the "warp") operation for some number of steps (in this case 100). The object is converted to a ggplot2 image using one of the `style_` functions. In this and most cases the `style_ribbon()` is used and has several customisable finctions.
## Example 2
```{r example2}
use_seed(1) %>%
entity_circle(grain = 1000, size = 2) %>%
unfold_warp(iterations = 100) %>%
style_ribbon(palette = "rainbow")
```## Example 3
An example where the initial object is created with `entity_heart()`, the unfolding performed by `unfold_slice()` and the styling is more elaborate.
```{r example3}
use_seed(1) %>%
entity_heart(grain = 1000) %>%
unfold_slice(iterations = 10) %>%
style_ribbon(
palette = "base",
colour = "ind",
background = "mistyrose"
) %>%
style_overlay(border = "white")
```## Example 4
It is possible to create "scenes" comprised of multiple entities as the initial starting point, apply multiple unfolding operations, and modify the way transparency and colouring is done.
```{r example4}
use_seed(1) %>%
scene_discs(
rings = 3, points = 5000, size = 5
) %>%
mutate(ind = 1:n()) %>%
unfold_warp(
iterations = 1,
scale = .5,
output = "layer"
) %>%
unfold_tempest(
iterations = 20,
scale = .01
) %>%
style_ribbon(
palette = palette_named("vik"),
colour = "ind",
alpha = c(.1,.1),
background = "oldlace"
)
```To save the image to a file, the pipeline can include an additional step that uses the `export_image()` function.