thorn: HTML widget displaying a shader

Description Usage Arguments Examples

View source: R/thorn.R

Description

Creates a HTML widget displaying a shader.

Usage

1
thorn(shader, width = NULL, height = NULL, elementId = NULL)

Arguments

shader

the name of the shader, one of "thorn", "thorn-color", "ikeda", "sweet", "biomorph1", "biomorph2", "biomorph3", "apollony", "smoke", "plasma"

width, height

a valid CSS measurement (like "100%", "400px", "auto") or a number, which will be coerced to a string and have "px" appended

elementId

a HTML id for the widget

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
28
29
30
library(thorn)
thorn("ikeda") # click on the shader to animate it
thorn("thorn") # you can also use the mouse wheel on this one

# four shaders ####
library(htmltools)

hw1 <- thorn("thorn-color", width = "50vw", height = "50vh")
hw2 <- thorn("ikeda", width = "50vw", height = "50vh")
hw3 <- thorn("sweet", width = "50vw", height = "50vh")
hw4 <- thorn("biomorph3", width = "50vw", height = "50vh")

if(interactive()){
  browsable(
    withTags(
      div(
        div(
          style = "position:absolute; top:0;",
          div(hw1, style="position:fixed; left:0;"),
          div(hw2, style="position:fixed; left:50vw;")
        ),
        div(
          style = "position:absolute; top:50vh;",
          div(hw3, style="position:fixed; left:0;"),
          div(hw4, style="position:fixed; left:50vw;")
        )
      )
    )
  )
}

thorn documentation built on Nov. 13, 2020, 1:14 a.m.