p5: Create a p5 sketch

Description Usage Arguments Examples

Description

Create a blank p5 sketch.

Usage

1
p5(data = NULL, width = NULL, height = NULL, padding = 0)

Arguments

data

A tibble::data_frame() which can be used to draw objects on the canvas where each row is an object to be drawn and columns are attributes of the object to be drawn.

width

Width of the sketch.

height

Height of the sketch.

padding

Padding of the sketch.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
## Not run: 

p5() %>%
  rect(10, 10, 40, 50)

p5() %>%
  createCanvas(400, 300) %>%
  background("#F0F8FF")

library(dplyr)

stripes <- data_frame(
  x = rep(0, 7),
  y = cumsum(c(0, rep(30, 6))),
  w = rep(300, 7),
  h = rep(15, 7)
)

stripes %>%
  p5() %>%
  createCanvas(300, 200) %>%
  fill("#FF0000") %>%
  noStroke() %>%
  rect()


## End(Not run)

seankross/p5 documentation built on May 30, 2019, 8:17 a.m.