07:00
Riso Grids
Ryan Miglinczy
posit::conf(2023)
Invented by the Riso Kagaku Corporation in the mid-1980s in Tokyo
Images are created in layers - each layer is one color, and layers are combined to create different colors and combinations
Using the shape types below, sketch two different 2x2 layers that could be combined to make a riso print
07:00
x
, y
: polygon verticesgroup
: which polygon it issubgroup
: to differentiate outer polygon points from holes# A tibble: 8 × 3
x y subgroup
<dbl> <dbl> <dbl>
1 1.5 1.5 1
2 8.5 1.5 1
3 8.5 8.5 1
4 1.5 8.5 1
5 2.75 2.75 2
6 7.25 2.75 2
7 7.25 7.25 2
8 2.75 7.25 2
# A tibble: 12 × 4
x y subgroup group
<dbl> <dbl> <dbl> <dbl>
1 1.5 1.5 1 1
2 8.5 1.5 1 1
3 8.5 8.5 1 1
4 1.5 8.5 1 1
5 2.75 2.75 2 1
6 7.25 2.75 2 1
7 7.25 7.25 2 1
8 2.75 7.25 2 1
9 4 4 NA 2
10 6 4 NA 2
11 6 6 NA 2
12 4 6 NA 2
geom_circle()
from {ggforce} draws a circle based on the center point (x0
, y0
) and the radius (r
)
Another brief math interlude…
~the parametric equation~
For a circle:
x0
, y0
r
The coordinates a point at an angle tau
from the center are:
x = x0 + sin(tau) * r
y = y0 + cos(tau) * r
Another brief math interlude…
Another brief math interlude…
Another brief math interlude…
Another brief math interlude…
Another brief math interlude…
Another brief math interlude…
Another brief math interlude…
Another brief math interlude…
Another brief math interlude…
geom_arc_bar
is used to make parts of circles
x0
, y0
: center of circler
: radius of circlestart
: starting angleend
: ending angleexercises/02-riso-grids/exercise-1.Rmd
x
, y
, start
, and end
of the bottom left circle, pictured heregeom_arc_bar()
05:00
generate_shape_data <- function(shape, color) {
switch(shape,
"oreo square" = oreo_square,
"upper triangle" = upper_triangle,
"lower triangle" = lower_triangle,
"quarter donut q1" = quarter_donut_1,
"quarter donut q2" = quarter_donut_2,
"quarter donut q3" = quarter_donut_3,
"quarter donut q4" = quarter_donut_4
) %>%
mutate(
color = color,
shape = shape
)
}
# A tibble: 12 × 6
x y subgroup group color shape
<dbl> <dbl> <dbl> <dbl> <chr> <chr>
1 1.5 1.5 1 1 #DDA710 oreo square
2 8.5 1.5 1 1 #DDA710 oreo square
3 8.5 8.5 1 1 #DDA710 oreo square
4 1.5 8.5 1 1 #DDA710 oreo square
5 2.75 2.75 2 1 #DDA710 oreo square
6 7.25 2.75 2 1 #DDA710 oreo square
7 7.25 7.25 2 1 #DDA710 oreo square
8 2.75 7.25 2 1 #DDA710 oreo square
9 4 4 NA 2 #DDA710 oreo square
10 6 4 NA 2 #DDA710 oreo square
11 6 6 NA 2 #DDA710 oreo square
12 4 6 NA 2 #DDA710 oreo square
generate_shape_plotter <- function(data) {
shape <- data[["shape"]][[1]]
if (shape %in% c("oreo square", "upper triangle", "lower triangle")) {
geom_polygon(
data = data,
aes(
x = x, y = y, group = group, subgroup = subgroup, fill = color
)
)
} else if (shape %in% c("quarter donut q1", "quarter donut q2", "quarter donut q3", "quarter donut q4")) {
geom_arc_bar(
data = data,
aes(
x0 = x, y0 = y, r = r, r0 = r0, start = start, end = end, fill = color
),
color = NA
)
}
}
generate_shape_plotter <- function(data) {
shape <- data[["shape"]][[1]]
if (shape %in% c("oreo square", "upper triangle", "lower triangle")) {
geom_polygon(
data = data,
aes(
x = x, y = y, group = group, subgroup = subgroup, fill = color
)
)
} else if (shape %in% c("quarter donut q1", "quarter donut q2", "quarter donut q3", "quarter donut q4")) {
geom_arc_bar(
data = data,
aes(
x0 = x, y0 = y, r = r, r0 = r0, start = start, end = end, fill = color
),
color = NA
)
}
}
mapping: x = ~x, y = ~y, group = ~group, subgroup = ~subgroup, fill = ~color
geom_polygon: na.rm = FALSE, rule = evenodd
stat_identity: na.rm = FALSE
position_identity
Returns only the geom_*()
function, which can be used directly in a ggplot2
pipeline, or with multiple together in a list()
layer_1 <- tribble(
~row, ~column, ~shape,
1, 1, "quarter donut q3",
1, 2, "upper triangle",
2, 2, "quarter donut q1",
2, 1, "lower triangle"
) %>%
mutate(
color = yellow,
id = row_number()
)
layer_1
# A tibble: 4 × 5
row column shape color id
<dbl> <dbl> <chr> <chr> <int>
1 1 1 quarter donut q3 #DDA710 1
2 1 2 upper triangle #DDA710 2
3 2 2 quarter donut q1 #DDA710 3
4 2 1 lower triangle #DDA710 4
$`1`
# A tibble: 1 × 5
row column shape color id
<dbl> <dbl> <chr> <chr> <int>
1 1 1 quarter donut q3 #DDA710 1
$`2`
# A tibble: 1 × 5
row column shape color id
<dbl> <dbl> <chr> <chr> <int>
1 1 2 upper triangle #DDA710 2
$`3`
# A tibble: 1 × 5
row column shape color id
<dbl> <dbl> <chr> <chr> <int>
1 2 2 quarter donut q1 #DDA710 3
$`4`
# A tibble: 1 × 5
row column shape color id
<dbl> <dbl> <chr> <chr> <int>
1 2 1 lower triangle #DDA710 4
library(purrr)
layer_1 %>%
split(.$id) %>%
map(function(data) {
generate_shape_data(data[["shape"]], data[["color"]])
})
$`1`
# A tibble: 1 × 8
x y r r0 start end color shape
<dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <chr> <chr>
1 10 10 10 5 3.14 4.71 #DDA710 quarter donut q3
$`2`
# A tibble: 3 × 6
x y group subgroup color shape
<dbl> <dbl> <lgl> <lgl> <chr> <chr>
1 0 0 NA NA #DDA710 upper triangle
2 10 10 NA NA #DDA710 upper triangle
3 0 10 NA NA #DDA710 upper triangle
$`3`
# A tibble: 1 × 8
x y r r0 start end color shape
<dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <chr> <chr>
1 0 0 10 5 0 1.57 #DDA710 quarter donut q1
$`4`
# A tibble: 3 × 6
x y group subgroup color shape
<dbl> <dbl> <lgl> <lgl> <chr> <chr>
1 0 0 NA NA #DDA710 lower triangle
2 10 0 NA NA #DDA710 lower triangle
3 10 10 NA NA #DDA710 lower triangle
library(purrr)
layer_1_plotting <- layer_1 %>%
split(.$id) %>%
map(function(data) {
generate_shape_data(data[["shape"]], data[["color"]])
}) %>%
map(function(data) {
data %>%
generate_shape_plotter()
})
layer_1_plotting
$`1`
mapping: x0 = ~x, y0 = ~y, r = ~r, r0 = ~r0, start = ~start, end = ~end, fill = ~color
geom_arc_bar: expand = 0, radius = 0
stat_arc_bar: na.rm = FALSE, n = 360
position_identity
$`2`
mapping: x = ~x, y = ~y, group = ~group, subgroup = ~subgroup, fill = ~color
geom_polygon: na.rm = FALSE, rule = evenodd
stat_identity: na.rm = FALSE
position_identity
$`3`
mapping: x0 = ~x, y0 = ~y, r = ~r, r0 = ~r0, start = ~start, end = ~end, fill = ~color
geom_arc_bar: expand = 0, radius = 0
stat_arc_bar: na.rm = FALSE, n = 360
position_identity
$`4`
mapping: x = ~x, y = ~y, group = ~group, subgroup = ~subgroup, fill = ~color
geom_polygon: na.rm = FALSE, rule = evenodd
stat_identity: na.rm = FALSE
position_identity
???
Shift everything over using the size of one grid and the row and column
layer_1_data <- layer_1 %>%
split(.$id) %>%
map_dfr(
function(data) {
generate_shape_data(data[["shape"]], data[["color"]])
},
.id = "id"
) %>%
mutate(id = as.numeric(id)) %>%
left_join(layer_1, by = c("id", "color", "shape"))
layer_1_data %>% select(-id)
# A tibble: 8 × 12
x y r r0 start end color shape group subgroup row column
<dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <chr> <chr> <lgl> <lgl> <dbl> <dbl>
1 10 10 10 5 3.14 4.71 #DDA710 quart… NA NA 1 1
2 0 0 NA NA NA NA #DDA710 upper… NA NA 1 2
3 10 10 NA NA NA NA #DDA710 upper… NA NA 1 2
4 0 10 NA NA NA NA #DDA710 upper… NA NA 1 2
5 0 0 10 5 0 1.57 #DDA710 quart… NA NA 2 2
6 0 0 NA NA NA NA #DDA710 lower… NA NA 2 1
7 10 0 NA NA NA NA #DDA710 lower… NA NA 2 1
8 10 10 NA NA NA NA #DDA710 lower… NA NA 2 1
Shift everything over using the size of one grid and the row and column
grid_size <- 10
layer_1_data_shifted <- layer_1_data %>%
mutate(
x = x + column * grid_size,
y = y + row * grid_size
)
layer_1_data_shifted %>% select(-id)
# A tibble: 8 × 12
x y r r0 start end color shape group subgroup row column
<dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <chr> <chr> <lgl> <lgl> <dbl> <dbl>
1 20 20 10 5 3.14 4.71 #DDA710 quart… NA NA 1 1
2 20 10 NA NA NA NA #DDA710 upper… NA NA 1 2
3 30 20 NA NA NA NA #DDA710 upper… NA NA 1 2
4 20 20 NA NA NA NA #DDA710 upper… NA NA 1 2
5 20 20 10 5 0 1.57 #DDA710 quart… NA NA 2 2
6 10 20 NA NA NA NA #DDA710 lower… NA NA 2 1
7 20 20 NA NA NA NA #DDA710 lower… NA NA 2 1
8 20 30 NA NA NA NA #DDA710 lower… NA NA 2 1
layer_2 <- tribble(
~row, ~column, ~shape,
1, 1, "oreo square",
1, 2, "quarter donut q2",
2, 2, "oreo square",
2, 1, "quarter donut q4"
) %>%
mutate(
color = grey,
id = row_number()
)
layer_2_plotting <- layer_2 %>%
split(.$id) %>%
map_dfr(
function(data) {
generate_shape_data(data[["shape"]], data[["color"]])
},
.id = "id"
) %>%
mutate(id = as.numeric(id)) %>%
left_join(layer_2, by = c("id", "color", "shape")) %>%
mutate(
x = x + column * grid_size,
y = y + row * grid_size
) %>%
split(.$id) %>%
map(function(data) {
generate_shape_plotter(data)
})
ggplot() +
layer_2_plotting +
scale_fill_identity() +
coord_fixed() +
theme_void()
exercises/02-riso-grids/exercise-2-3.Rmd
row
, column
, shape
, and color
. Try using two of the colors listed in the file, which are common colors in riso printing.generate_and_plot_two_layers()
with your two layers and save the plots in the correct dimension using ggsave()
10:00
Risograph effect please?
layer_1 <- ggplot() +
layer_1_plotting +
scale_fill_identity() +
coord_fixed() +
theme_void()
layer_1_file <- "riso-layer-1.png"
ggsave(layer_1_file, layer_1, height = 5, width = 5)
layer_2 <- ggplot() +
layer_2_plotting +
scale_fill_identity() +
coord_fixed() +
theme_void()
layer_2_file <- "riso-layer-2.png"
ggsave(layer_2_file, layer_2, height = 5, width = 5)
library(magick)
layer_1_img <- image_read(layer_1_file)
layer_2_img <- image_read(layer_2_file)
paper <- image_blank(
width = image_info(layer_1_img)[["width"]],
height = image_info(layer_1_img)[["height"]],
color = "#E1DED7"
)
paper %>%
image_composite(layer_1_img) %>%
image_composite(
layer_2_img,
operator = "multiply"
)
exercises/02-riso-grids/exercise-2-3.Rmd
05:00
geom_polygon()
and geom_arc_bar()
can be used to create more complex shapesgeom_*()
s in a ggplot2 pipeline combine the layers