Skip to content

Programmatically Generated Fish Drawings via JavaScript

License

Notifications You must be signed in to change notification settings

Otoliths/rfishdraw

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rfishdraw

Procedurally generated fish drawings via ggplot2 based on fishdraw Javascript JavaScript library. Note: You need to install nodejs before using the rfishdraw package.

⏬ Installation

Windows

Installing nodejs under from windows nodejs.

MacOS

brew search node 
brew install node@14
brew link node@14
node --version

Ubuntu

sudo apt-get install nodejs

Installing rfishdraw

Install development versions from GitHub with:

library(devtools)
install_github("Otoliths/rfishdraw")

🔰 Example

Load the rnsii package
library("rfishdraw")
Get outputs polylines in svg
get_polylines(path = "inst/fishdraw.js",
              format = "smil",
              output = "animated.svg",
              draw_type = "random")

fish drawings via plot
file <- system.file("extdata",package = "rfishdraw")
dat <- readRDS(paste0(file,"/","output_json.rds"))
for (i in seq(length(dat))) {
dat[[i]] <- cbind(dat[[i]],i)
}
plot(NA, xlim = c(0,520),ylim = c(-320,0),axes = F,xlab = " ",ylab = " ")
for(i in seq(length(dat))) {
  lines(x = dat[[i]][,1],y = -dat[[i]][,2], lwd=2, col = "blue")
}

fish drawings via ggplot2
fish_draw()

fish drawings via ggplot2
require(ggplot2)
p1 <- fish_draw() +
  theme_void()

library(patchwork)
p1+p1+p1+p1+p1+p1+plot_layout(ncol = 2)

❤️ Contribution

Contributions to this package are welcome. The preferred method of contribution is through a GitHub pull request. Feel also free to contact us by creating an issue.

About

Programmatically Generated Fish Drawings via JavaScript

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published