Description Usage Arguments Examples
Stop draw() from looping.
1 |
sketch |
A p5 sketch. |
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 | ## Not run:
# Click the resulting sketch
pre_ <- pre() %>%
js("var x = 0;")
setup_ <- setup() %>%
createCanvas(100, 100)
draw_ <- draw() %>%
background("#F0F8FF") %>%
js(" x = x + 0.1;
if (x > width) {
x = 0;
} ") %>%
line(~x, 0, ~x, ~height)
post_ <- post() %>%
js(" mousePressed = function() {
noLoop();
}
mouseReleased = function() {
loop();
} ")
sketch(pre = pre_, setup = setup_, draw = draw_, post = post_)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.