library(grid)
library(vdiffr)
library(grid)
# https://developer.mozilla.org/en-US/docs/Web/SVG/Tutorial/Gradients
svg_ex <- '
<svg width="120" height="240" version="1.1" xmlns="http://www.w3.org/2000/svg">
<defs>
<linearGradient id="Gradient1">
<stop class="stop1" offset="0%"/>
<stop class="stop2" offset="50%"/>
<stop class="stop3" offset="100%"/>
</linearGradient>
<linearGradient id="Gradient2" x1="0" x2="0" y1="0" y2="1">
<stop offset="0%" stop-color="red"/>
<stop offset="50%" stop-color="black" stop-opacity="0"/>
<stop offset="100%" stop-color="blue"/>
</linearGradient>
<style type="text/css"><![CDATA[
#rect1 { fill: url(#Gradient1); }
.stop1 { stop-color: red; }
.stop2 { stop-color: black; stop-opacity: 0; }
.stop3 { stop-color: blue; }
]]></style>
</defs>
<rect id="rect1" x="10" y="10" rx="15" ry="15" width="100" height="100" stroke="black" />
<rect x="10" y="120" rx="15" ry="15" width="100" height="100" stroke="blue" fill="url(#Gradient2)"/>
</svg>
'
if (FALSE) {
ex_gradient <- read_svg(svg_ex)
grid.newpage();grid.draw(ex_gradient)
}
suppressMessages({
test_that("vdiffr linearGradient test", {
g <- read_svg(svg_ex)
vdiffr::expect_doppelganger("mdnLinearGradient", g)
})
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.