R/ndc2cell.R

Defines functions ndc2cell

ndc2cell <- function(x, y, vp = "corner") {
  x <- graphics::grconvertX(x, "ndc", "inches")
  y <- graphics::grconvertY(y, "ndc", "inches")
  grid::seekViewport(vp)
  cell <- grid::deviceLoc(grid::unit(0:1, "npc"), grid::unit(1:0, "npc"))
  grid::seekViewport("board")
  cell <- lapply(cell, `attributes<-`, NULL)
  ceiling(c(x = interpolate(x, cell$x), y = interpolate(y, cell$y)))
}

Try the minesweeper package in your browser

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

minesweeper documentation built on April 3, 2025, 9:29 p.m.