o.T. (carré noir)
Vera Molnár
posit::conf(2023)
geom_polygon()
We will use the following aesthetics
x
, y
)color
)fill
)group
)geom_polygon()
We will use the following aesthetics
x
, y
)color
)fill
)group
)geom_polygon()
tips
Order of coordinates matters (a lot!)
Only coordinates of interest are the vertices
exercises/03-ot/exercise.Rmd
exercises/03-ot/letters/
and draw out the letter.tribble()
with the coordinates of the letter you selected.create_letter()
, that takes x0
and y0
as arguments and moves the shape according to those arguments.x0
and y0
of your choosing.10:00
Throughout her career, Vera Molnár experimented with repetitions and variations of letters, especially the letter M – as in Molnár.
She explored the balance between order and chaos.
y_new
= -x_old
& x_new
= y_old
y_new
= -y_old
& x_new
= -x_old
y_new
= x_old
& x_new
= -y_old
x0 <- 3
y0 <- 3
initial_u_shape <-
create_initial_shape(x0, y0) %>%
mutate(
x = x - x0,
y = y - y0
) %>%
mutate(
x_new = y,
y_new = -x
)
initial_u_shape %>%
ggplot() +
geom_polygon(
aes(
x = x_new,
y = y_new
)
) +
geom_point(
aes(
x = x0,
y = y0
),
size = 5,
color = "red"
) +
coord_fixed(
xlim = c(-1, 4),
ylim = c(-1, 4)
)
x0 <- 3
y0 <- 3
initial_u_shape <-
create_initial_shape(x0, y0) %>%
mutate(
x = x - x0,
y = y - y0
) %>%
mutate(
x_new = y,
y_new = -x
) %>%
mutate(
x = x_new + x0,
y = y_new + y0
)
initial_u_shape %>%
ggplot() +
geom_polygon(
aes(
x = x,
y = y
)
) +
geom_point(
aes(
x = x0,
y = y0
),
size = 5,
color = "red"
) +
coord_fixed(
xlim = c(-1, 4),
ylim = c(-1, 4)
)
x0 <- 3
y0 <- 3
shape_width <- 1
initial_u_shape <-
create_initial_shape(x0, y0) %>%
mutate(
x = x - x0,
y = y - y0
) %>%
mutate(
x_new = y,
y_new = -x
) %>%
mutate(
x = x_new + x0,
y = y_new + y0 + shape_width
)
initial_u_shape %>%
ggplot() +
geom_polygon(
aes(
x = x,
y = y
)
) +
geom_point(
aes(
x = x0,
y = y0
),
size = 5,
color = "red"
) +
coord_fixed(
xlim = c(-1, 4),
ylim = c(-1, 4)
)
rotate_shape <- function(data, x0, y0, degrees, shape_width) {
if (degrees == 90) {
data %>%
mutate(
x = x - x0,
y = y - y0
) %>%
mutate(
x_new = y,
y_new = -x
) %>%
mutate(
x = x_new + x0,
y = y_new + y0 + shape_width
)
} else if (degrees == 180) {
data %>%
mutate(
x = x - x0,
y = y - y0
) %>%
mutate(
x_new = -x,
y_new = -y
) %>%
mutate(
x = x_new + x0 + shape_width,
y = y_new + y0 + shape_width
)
} else if (degrees == 270) {
data %>%
mutate(
x = x - x0,
y = y - y0
) %>%
mutate(
x_new = -y,
y_new = x
) %>%
mutate(
x = x_new + x0 + shape_width,
y = y_new + y0
)
} else if (degrees == 0) {
data
}
}
exercises/03-ot/exercise.Rmd
initiate_rotate_shape()
function.x0
, y0
, and the degrees
argument within initiate_rotate_shape()
to rotate and move your letter.shape_width
to be greater or smaller than 1? Why does this happen?05:00
# A tibble: 100 × 2
x y
<dbl> <dbl>
1 0 0
2 0 1.25
3 0 2.5
4 0 3.75
5 0 5
6 0 6.25
7 0 7.5
8 0 8.75
9 0 10
10 0 11.2
# ℹ 90 more rows
ncol <- 10
nrow <- 10
shape_width <- 1
perimeter_width <- shape_width + .25
grid <-
expand_grid(
x = seq(0,
by = perimeter_width,
length.out = ncol
),
y = seq(0,
by = perimeter_width,
length.out = nrow
)
) %>%
mutate(y = if_else(x >= 5 * perimeter_width,
y + perimeter_width / 2,
y
))
grid
# A tibble: 100 × 2
x y
<dbl> <dbl>
1 0 0
2 0 1.25
3 0 2.5
4 0 3.75
5 0 5
6 0 6.25
7 0 7.5
8 0 8.75
9 0 10
10 0 11.2
# ℹ 90 more rows
library(purrr)
make_molnar_system <- function() {
ncol <- 10
nrow <- 10
shape_width <- 1
perimeter_width <- shape_width + .25
grid <-
expand_grid(
x = seq(0, by = perimeter_width, length.out = ncol),
y = seq(0, by = perimeter_width, length.out = nrow)
) %>%
mutate(y = if_else(x >= 5 * perimeter_width,
y + perimeter_width / 2,
y
))
output <-
map_dfr(
1:nrow(grid),
function(i) {
create_rotate_shape(
x = grid$x[i],
y = grid$y[i],
degrees = 180,
shape_width = shape_width
)
}
)
return(output)
}
geom_polygon()
We will use the following aesthetics
x
, y
)color
)fill
)group
)make_molnar_system <- function() {
ncol <- 10
nrow <- 10
shape_width <- 1
perimeter_width <- shape_width + .25
grid <-
expand_grid(
x = seq(0, by = perimeter_width, length.out = nrow),
y = seq(0, by = perimeter_width, length.out = ncol)
) %>%
mutate(y = if_else(x >= 5 * perimeter_width,
y + perimeter_width / 2,
y
))
output <-
map_dfr(
1:nrow(grid),
function(i) {
bind_cols(
group = i,
create_rotate_shape(
x = grid$x[i],
y = grid$y[i],
degrees = 180,
shape_width = shape_width
)
)
}
)
return(output)
}
make_molnar_system <- function(seed) {
set.seed(seed)
ncol <- 10
nrow <- 10
shape_width <- 1
perimeter_width <- shape_width + .25
grid <-
expand_grid(
x = seq(0, by = perimeter_width, length.out = nrow),
y = seq(0, by = perimeter_width, length.out = ncol)
) %>%
mutate(y = if_else(x >= 5 * perimeter_width,
y + perimeter_width / 2,
y
))
output <-
map_dfr(
1:nrow(grid),
function(i) {
bind_cols(
group = i,
create_rotate_shape(
x = grid$x[i],
y = grid$y[i],
degrees = 180,
shape_width = shape_width
)
)
}
)
return(output)
}
make_molnar_system <- function(seed) {
set.seed(seed)
ncol <- 10
nrow <- 10
shape_width <- 1
perimeter_width <- shape_width + .25
grid <-
expand_grid(
x = seq(0, by = perimeter_width, length.out = nrow),
y = seq(0, by = perimeter_width, length.out = ncol)
) %>%
mutate(y = if_else(x >= 5 * perimeter_width,
y + perimeter_width / 2,
y
))
output <-
map_dfr(
1:nrow(grid),
function(i) {
bind_cols(
group = i,
create_rotate_shape(
x = grid$x[i],
y = grid$y[i],
degrees = sample(c(0, 90, 180, 270),
size = 1
),
shape_width = shape_width
)
)
}
)
return(output)
}
Layout: 1, 2, 3, Skip, 4, 1, 2
make_molnar_system <-
function(seed) {
set.seed(seed)
ncol <- 10
nrow <- 10
shape_width <- 1
perimeter_width <- shape_width + .25
degree_pattern_options <- c(0, 90, 180, 270)
degree_pattern <- sample(degree_pattern_options, size = 6, replace = TRUE)
grid <-
expand_grid(
x = seq(0,
by = perimeter_width,
length.out = nrow
),
y = seq(0,
by = perimeter_width,
length.out = ncol
)
) %>%
mutate(y = if_else(x >= 5 * perimeter_width,
y + perimeter_width / 2,
y
))
degree_pattern_exp <- rep(degree_pattern,
length.out = nrow(grid)
)
output <-
map_dfr(
1:nrow(grid),
function(i) {
bind_cols(
group = i,
create_rotate_shape(
x = grid$x[i],
y = grid$y[i],
degrees = degree_pattern_exp[i],
shape_width = shape_width
)
)
}
)
return(output)
}
exercises/03-ot/exercise.Rmd
make_exercise_molnar()
function which encompasses the whole system.degree_pattern_options=
and degree_sample_size=
for the function make_exercise_molnar()
to experiment with modifying the rotation patterns to one of your choice. (Degrees options are 0, 90, 80, 270)ggsave()
code provided and share on GitHub discussion board.fill=
and color=
in geom_polygon()
plot.background
in theme()
10:00
geom_polygon()
geom_polygon()
arguments: order matters and group is important!