File: tikzInternal.R

package info (click to toggle)
r-cran-tikzdevice 0.12.3.1-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 2,196 kB
  • sloc: ansic: 1,290; sh: 13; makefile: 12
file content (29 lines) | stat: -rwxr-xr-x 789 bytes parent folder | download | duplicates (3)
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
# These are unexported functions that are called by the C routines of the tikz
# device to execute tasks that are difficult to do at the C level.

getDateStampForTikz <- function() {

  # This function retrieves the current date stamp using
  # sys.time() and formats it to a string. This function
  # is used by the C routine Print_TikZ_Header to add
  # date stamps to output files.

  return(strftime(Sys.time()))
}

getTikzDeviceVersion <- function() {
  as.character(packageVersion("tikzDevice"))
}

tikz_writeRaster <- function(fileName, rasterCount, nativeRaster) {
  raster_file <- paste0(
    tools::file_path_sans_ext(fileName),
    "_ras", rasterCount, ".png"
  )

  png::writePNG(nativeRaster, raster_file)

  return(
    basename(tools::file_path_sans_ext(raster_file))
  )
}