tests/testthat/test-clip.R

test_that("regression test for no clipping", {
  svglite("test-no-clip.svg", 4, 4, user_fonts = bitstream)
  on.exit(dev.off())

  mini_plot(c(-1, 1), c(-1, 1), asp = 1, type = "n")
  rect(-0.5, -0.5, 0.5, 0.5, col = "blue")
  text(0, 0.5, "Clipping", cex = 2, srt = 30)
  abline(h = 0.5, col = "red")
})

test_that("regression test for clipping", {
  svglite("test-clip.svg", 4, 4, user_fonts = bitstream)
  on.exit(dev.off())

  mini_plot(c(-1, 1), c(-1, 1), asp = 1, type = "n")
  clip(-1, 0, -1, 0)
  rect(-0.5, -0.5, 0.5, 0.5, col = "blue")
  clip(0, 1, 0, 1)
  text(0, 0.5, "Clipping", cex = 2, srt = 30)
  clip(-1, 0, 0, 1)
  abline(h = 0.5, col = "red")
})

Try the svglite package in your browser

Any scripts or data that you put into this service are public.

svglite documentation built on Oct. 11, 2023, 9:06 a.m.