MyNixOS website logo
Description

Creates Generative Art Data.

Create data that displays generative art when mapped into a 'ggplot2' plot. Functionality includes specialized data frame creation for geometric shapes, tools that define artistic color palettes, tools for geometrically transforming data, and other miscellaneous tools that are helpful when using 'ggplot2' for generative art.

codecov

R-CMD-check

The goal of artpack is to help generative artists of all levels create generative art in R. The artpack package is intended for use with the tidyverse suite. More specifically, with the ggplot2 package.

Installation

You can install {artpack} from CRAN with the following code:

install.packages("artpack")

You can install the development version of artpack from GitHub with:

# install.packages("devtools")
devtools::install_github("Meghansaha/artpack")

Overview

artpack is a package that helps users create generative art in R with a “data-centric” approach and is currently in early development. artpack is intended to be used with ggplot2 for artistic purposes.


What does data-centric mean in this context?

“data-centric” means that the package focuses on providing direct data outputs to the user, as opposed to providing geom_fxs() like most supplemental packages.


Why data outputs? Wouldn’t geoms be more efficient or user-friendly?

Not necessarily. Data outputs are provided to afford the user freedom of manipulation and choice. artpack is developed to make the user’s life easier by making data generation for ggplot2 art easier. All data outputs are intended to be used with existing ggplot2 geoms like geom_polygon() and geom_path(). For artistic purposes, it can be much easier for a user to manipulate direct data frames, as opposed to trying to “hack” geoms.


Brief Examples

artpack can be used create specified dataframes that will map art when fed into ggplot2 functions:

For example, square_data() creates a data frame that maps a square on to a ggplot:

library(ggplot2)
library(artpack)

# Use the function to create a data frame #
df_square <-
  square_data(
    x = 0,
    y = 0,
    size = 5,
    color = "purple",
    fill = "black"
  )

# Feed it into a ggplot #
df_square |>
  ggplot(aes(x = x, y = y)) +
  geom_polygon(
    fill = df_square$fill,
    color = df_square$color,
    linewidth = 2
  ) +
  coord_equal()


rotator will mathematically “rotate” existing data points in a data frame:

library(ggplot2)
library(artpack)

original_square <- data.frame(
  x = c(0, 3, 3, 0, 0),
  y = c(0, 0, 3, 3, 0)
)

rotated_square <- rotator(
  data = original_square,
  x = x,
  y = y,
  angle = 120,
  anchor = "center"
)

ggplot() +
  geom_path(
    data = original_square,
    aes(x, y),
    color = "red"
  ) +
  geom_polygon(
    data = rotated_square,
    aes(x, y),
    fill = "green"
  ) +
  coord_equal()



artpack functions are designed to be used in any part of your workflow. Experiment for some cool results:

library(ggplot2)
library(purrr)
library(dplyr)
#> 
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union
library(tibble)
library(artpack)

# Create a base square #
square <- square_data(x = 0, y = 0, size = 1, group_var = TRUE)

# Create square specs to be iterated on #
n_square <- 50
scaler <- seq(1, 5, length = n_square)
fills <- art_pals("imagination", n = n_square)
angles <- seq(0, 360, length = n_square)
group_n <- group_numbers(1:n_square)

# Add a random transformation for a little razzle dazzle ✨
theta <- seq(0, 2 * pi, length = 250)

list_opts <- list(
  scaler,
  fills,
  angles,
  group_n
)

df <- pmap(list_opts, ~ rotator(
  square |>
    mutate(
      x = (x + ..1),
      y = (y + ..1),
      fill = ..2,
      group = paste0(group, ..4)
    ),
  x = x, y = y, angle = ..3
)) |>
  list_rbind() |>
  mutate(
    x = x * cos(theta) + x,
    y = y * sin(theta)
  )



df |>
  ggplot(aes(x = x, y = y, group = group)) +
  theme_void() +
  theme(plot.background = element_rect(fill = "#000000")) +
  geom_polygon(
    fill = df$fill,
    color = "#000000",
    alpha = .5
  ) +
  coord_equal(expand = FALSE)
Metadata

Version

0.1.0

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows