diff --git a/chromaR/DESCRIPTION b/chromaR/DESCRIPTION index e4b0310..15270bb 100644 --- a/chromaR/DESCRIPTION +++ b/chromaR/DESCRIPTION @@ -7,20 +7,15 @@ Maintainer: Tommaso Buonocore Description: R toolkit to analyze and explore chromatic storytelling in any video source in any video source, previously converted in a csv sequence of frames. Imports: - dplyr, - stringr, - ggplot2, - corrplot, - Hmisc, - grid, - gridExtra, - plotwidgets, - circlize, - jpeg, - scales, - imager, - LICORS, - grDevices + utils, + tools, + ggplot2, + graphics, + plotwidgets, + circlize, + imager, + grDevices, + LICORS License: file LICENSE Encoding: UTF-8 LazyData: true diff --git a/chromaR/NAMESPACE b/chromaR/NAMESPACE index b4d3ed7..18b82d9 100644 --- a/chromaR/NAMESPACE +++ b/chromaR/NAMESPACE @@ -23,22 +23,11 @@ export(plotTimeWindows) export(satOnly) export(temperature) export(vividHex) -import(Hmisc) -import(circlize) -import(corrplot) -import(dplyr) import(ggplot2) -import(grDevices) import(graphics) -import(grid) -import(gridExtra) -import(jpeg) -import(plotwidgets) -import(scales) -import(stats) -import(stringr) -import(utils) importFrom(LICORS,kmeanspp) +importFrom(circlize,chordDiagram) +importFrom(circlize,circos.clear) importFrom(grDevices,convertColor) importFrom(grDevices,rgb) importFrom(imager,B) @@ -48,3 +37,9 @@ importFrom(imager,height) importFrom(imager,load.image) importFrom(imager,resize) importFrom(imager,width) +importFrom(plotwidgets,col2hsl) +importFrom(plotwidgets,hsl2col) +importFrom(plotwidgets,modCol) +importFrom(tools,file_path_sans_ext) +importFrom(utils,choose.files) +importFrom(utils,read.csv) diff --git a/chromaR/R/colors.R b/chromaR/R/colors.R index 30a1b73..028a9d2 100644 --- a/chromaR/R/colors.R +++ b/chromaR/R/colors.R @@ -1,18 +1,5 @@ -#' @import utils -#' @import stats #' @import graphics #' @import ggplot2 -#' @import dplyr -#' @import stringr -#' @import plotwidgets -#' @import gridExtra -#' @import grid -#' @import corrplot -#' @import Hmisc -#' @import circlize -#' @import jpeg -#' @import scales -#' @import grDevices NULL @@ -47,6 +34,7 @@ luminance <- function(r,g,b){ #' print("example") #' #' @export +#' @importFrom plotwidgets modCol vividHex <- function(hexString, intensity = c("light","medium","strong","ultra")){ darkIntensity <- switch(EXPR=intensity,light = .05,medium = .1,strong =.2, ultra =.3) satIntensity <- switch(EXPR=intensity,light = .1,medium = .2,strong =.3, ultra =.4) @@ -65,6 +53,7 @@ vividHex <- function(hexString, intensity = c("light","medium","strong","ultra") #' print("example") #' #' @export +#' @importFrom plotwidgets modCol lumOnly <- function(hexString){ return(modCol(hexString, darken = 0, saturate = -1, modhue = 0)) } @@ -81,6 +70,7 @@ lumOnly <- function(hexString){ #' print("example") #' #' @export +#' @importFrom plotwidgets hsl2col hueOnly <- function(hexString){ return(hsl2col(as.matrix(c(hslGet(hexString,"h"),1,0.5)))) } @@ -98,6 +88,7 @@ hueOnly <- function(hexString){ #' print("example") #' #' @export +#' @importFrom plotwidgets hsl2col satOnly <- function(hexString){ return(hsl2col(as.matrix(c(1,hslGet(hexString,"s"),0.5)))) } @@ -115,6 +106,7 @@ satOnly <- function(hexString){ #' print("example") #' #' @export +#' @importFrom plotwidgets col2hsl hslGet <- function(hexString, channel=c("H","S","V")){ values <- list() for(hex in hexString){ @@ -135,6 +127,7 @@ hslGet <- function(hexString, channel=c("H","S","V")){ #' print("example") #' #' @export +#' @importFrom plotwidgets col2hsl isWarm <- function(hexString){ hue <- col2hsl(hexString)["H",][[1]] sat <- col2hsl(hexString)["S",][[1]] @@ -162,6 +155,8 @@ isWarm <- function(hexString){ #' print("example") #' #' @export +#' @importFrom circlize chordDiagram +#' @importFrom circlize circos.clear colorCircle <- function(frames, extra = FALSE){ palette <- chromaRenv$colorHueRef if(extra) palette <- chromaRenv$colorHueRefExtra @@ -188,6 +183,7 @@ colorCircle <- function(frames, extra = FALSE){ #' print("example") #' #' @export +#' @importFrom plotwidgets col2hsl getHueRef <- function(hexString, extra = FALSE){ palette <- chromaRenv$colorHueRef if(extra) palette <- chromaRenv$colorHueRefExtra @@ -363,11 +359,12 @@ plotFrameline <- function(frames, verbose = 0, summary = TRUE, vivid = FALSE, ti #' #' plotTimeWindows #' -#' @param left frames -#' @param verbose frames -#' @param vivid frames -#' @param title frames -#' @param subtitle frames +#' @param left left +#' @param frames frames +#' @param verbose verbose +#' @param vivid vivid +#' @param title title +#' @param subtitle subtitle #' #' @return none #' @@ -684,10 +681,10 @@ theme_semiVoid <- function(xaxis = FALSE){ #' #' extractFramePalette #' -#' @param jpegFramePath jpegFramePath -#' @param paletteDim paletteDim -#' @param title title -#' @param subtitle subtitle +#' @param img_path img_path +#' @param palette_dim palette_dim +#' @param max_res max_res +#' @param graphics graphics #' #' @return none #' diff --git a/chromaR/R/parsing.R b/chromaR/R/parsing.R index 6ed7085..0317f05 100644 --- a/chromaR/R/parsing.R +++ b/chromaR/R/parsing.R @@ -12,12 +12,16 @@ #' print("example") #' #' @export +#' @importFrom utils choose.files +#' @importFrom utils read.csv +#' @importFrom tools file_path_sans_ext +#' @importFrom grDevices rgb getFrames <- function(paths=c(NULL),names=c(NULL),orderBySeason=FALSE){ #================================================= #= 1 - retrieve files and names = #================================================= if((Sys.info()['sysname']=="Windows")&(length(paths)==0)){ - paths <- choose.files(caption = "Select files",multi = TRUE, #get file paths + paths <- utils::choose.files(caption = "Select files",multi = TRUE, #get file paths filters = matrix(c("All files","*.*","Csv files","*.csv"), ncol = 2, byrow = TRUE )) } else { @@ -64,6 +68,7 @@ getFrames <- function(paths=c(NULL),names=c(NULL),orderBySeason=FALSE){ #' print("example") #' #' @export +#' @importFrom grDevices rgb groupframes <- function(frames,seconds=NULL,fps=chromaRenv$fps){ if(is.null(seconds)) { seconds <- round(length(frames$frameId)/(fps*chromaRenv$linesize$bold)) diff --git a/chromaR/chromaR.Rproj b/chromaR/chromaR.Rproj index d596992..335f5de 100644 --- a/chromaR/chromaR.Rproj +++ b/chromaR/chromaR.Rproj @@ -18,4 +18,4 @@ StripTrailingWhitespace: Yes BuildType: Package PackageUseDevtools: Yes PackageInstallArgs: --no-multiarch --with-keep.source -PackageCheckArgs: --as-cran +PackageBuildArgs: --resave-data diff --git a/chromaR/man/extractFramePalette.Rd b/chromaR/man/extractFramePalette.Rd index 8a0804d..cc47716 100644 --- a/chromaR/man/extractFramePalette.Rd +++ b/chromaR/man/extractFramePalette.Rd @@ -12,13 +12,13 @@ extractFramePalette( ) } \arguments{ -\item{jpegFramePath}{jpegFramePath} +\item{img_path}{img_path} -\item{paletteDim}{paletteDim} +\item{palette_dim}{palette_dim} -\item{title}{title} +\item{max_res}{max_res} -\item{subtitle}{subtitle} +\item{graphics}{graphics} } \value{ none diff --git a/chromaR/man/matrix.Rd b/chromaR/man/matrix.Rd new file mode 100644 index 0000000..dd0dda8 --- /dev/null +++ b/chromaR/man/matrix.Rd @@ -0,0 +1,57 @@ +\name{matrix} +\alias{matrix} +\docType{data} +\title{ +matrix +} +\description{ +description +} +\usage{data("matrix")} +\format{ + The format is: +List of 3 + $ :'data.frame': 196160 obs. of 6 variables: + ..$ R : num [1:196160] 0 0 0 0 0 0 0 0 0 0 ... + ..$ G : num [1:196160] 0 0 0 0 0 0 0 0 0 0 ... + ..$ B : num [1:196160] 0 0 0 0 0 0 0 0 0 0 ... + ..$ hex : chr [1:196160] "#000000" "#000000" "#000000" "#000000" ... + ..$ lum : num [1:196160] 0 0 0 0 0 0 0 0 0 0 ... + ..$ frameId: int [1:196160] 1 2 3 4 5 6 7 8 9 10 ... + ..- attr(*, "avgRGB")= chr "#292A22" + ..- attr(*, "title")= chr "s1e1" + ..- attr(*, "duration")= num 8173 + $ :'data.frame': 198950 obs. of 6 variables: + ..$ R : num [1:198950] 0 0 0 0 0 0 0 0 0 0 ... + ..$ G : num [1:198950] 0 0 0 0 0 0 0 0 0 0 ... + ..$ B : num [1:198950] 0 0 0 0 0 0 0 0 0 0 ... + ..$ hex : chr [1:198950] "#000000" "#000000" "#000000" "#000000" ... + ..$ lum : num [1:198950] 0 0 0 0 0 0 0 0 0 0 ... + ..$ frameId: int [1:198950] 1 2 3 4 5 6 7 8 9 10 ... + ..- attr(*, "avgRGB")= chr "#2D312A" + ..- attr(*, "title")= chr "s1e2" + ..- attr(*, "duration")= num 8290 + $ :'data.frame': 185945 obs. of 6 variables: + ..$ R : num [1:185945] 0 0 0 0 0 0 0 0 0 0 ... + ..$ G : num [1:185945] 0 0 0 0 0 0 0 0 0 0 ... + ..$ B : num [1:185945] 0 0 0 0 0 0 0 0 0 0 ... + ..$ hex : chr [1:185945] "#000000" "#000000" "#000000" "#000000" ... + ..$ lum : num [1:185945] 0 0 0 0 0 0 0 0 0 0 ... + ..$ frameId: int [1:185945] 1 2 3 4 5 6 7 8 9 10 ... + ..- attr(*, "avgRGB")= chr "#252A29" + ..- attr(*, "title")= chr "s1e3" + ..- attr(*, "duration")= num 7748 +} +\details{ +details +} +\source{ +source +} +\references{ +references +} +\examples{ +data(matrix) +} +\keyword{datasets} diff --git a/chromaR/man/miyazaki.Rd b/chromaR/man/miyazaki.Rd new file mode 100644 index 0000000..c93aeb1 --- /dev/null +++ b/chromaR/man/miyazaki.Rd @@ -0,0 +1,127 @@ +\name{miyazaki} +\alias{miyazaki} +\docType{data} +\title{ +miyazaki +} +\description{ +description +} +\usage{data("miyazaki")} +\format{ + The format is: +List of 10 + $ :'data.frame': 168361 obs. of 6 variables: + ..$ R : num [1:168361] 0 0 0 0 0 0 0 0 0 0 ... + ..$ G : num [1:168361] 0 0 0 0 0 0 0 0 0 0 ... + ..$ B : num [1:168361] 0 0 0 0 0 0 0 0 0 0 ... + ..$ hex : chr [1:168361] "#000000" "#000000" "#000000" "#000000" ... + ..$ lum : num [1:168361] 0 0 0 0 0 0 0 0 0 0 ... + ..$ frameId: int [1:168361] 1 2 3 4 5 6 7 8 9 10 ... + ..- attr(*, "avgRGB")= chr "#5F544C" + ..- attr(*, "title")= chr "1984 - Nausicaa of the Valley of the Wind" + ..- attr(*, "duration")= num 7015 + $ :'data.frame': 179186 obs. of 6 variables: + ..$ R : num [1:179186] 0 0 0 0 0 0 0 0 0 0 ... + ..$ G : num [1:179186] 0 0 0 0 0 0 0 0 0 0 ... + ..$ B : num [1:179186] 0 0 0 0 0 0 0 0 0 0 ... + ..$ hex : chr [1:179186] "#000000" "#000000" "#000000" "#000000" ... + ..$ lum : num [1:179186] 0 0 0 0 0 0 0 0 0 0 ... + ..$ frameId: int [1:179186] 1 2 3 4 5 6 7 8 9 10 ... + ..- attr(*, "avgRGB")= chr "#464846" + ..- attr(*, "title")= chr "1986 - Laputa Castle in the Sky" + ..- attr(*, "duration")= num 7466 + $ :'data.frame': 124321 obs. of 6 variables: + ..$ R : num [1:124321] 0 0 0 0 0 0 0 0 0 0 ... + ..$ G : num [1:124321] 0 0 0 0 0 0 0 0 0 0 ... + ..$ B : num [1:124321] 0 0 0 0 0 0 0 0 0 0 ... + ..$ hex : chr [1:124321] "#000000" "#000000" "#000000" "#000000" ... + ..$ lum : num [1:124321] 0 0 0 0 0 0 0 0 0 0 ... + ..$ frameId: int [1:124321] 1 2 3 4 5 6 7 8 9 10 ... + ..- attr(*, "avgRGB")= chr "#4B524A" + ..- attr(*, "title")= chr "1988 - My Neighbor Totoro" + ..- attr(*, "duration")= num 5180 + $ :'data.frame': 134264 obs. of 6 variables: + ..$ R : num [1:134264] 0 0 0 0 0 0 0 0 0 0 ... + ..$ G : num [1:134264] 0 0 0 0 0 0 0 0 0 0 ... + ..$ B : num [1:134264] 0 0 0 0 0 0 0 0 0 0 ... + ..$ hex : chr [1:134264] "#000000" "#000000" "#000000" "#000000" ... + ..$ lum : num [1:134264] 0 0 0 0 0 0 0 0 0 0 ... + ..$ frameId: int [1:134264] 1 2 3 4 5 6 7 8 9 10 ... + ..- attr(*, "avgRGB")= chr "#555D58" + ..- attr(*, "title")= chr "1992 - Porco Rosso" + ..- attr(*, "duration")= num 5594 + $ :'data.frame': 191878 obs. of 6 variables: + ..$ R : num [1:191878] 0 0 0 0 0 0 0 0 0 0 ... + ..$ G : num [1:191878] 0 0 0 0 0 0 0 0 0 0 ... + ..$ B : num [1:191878] 0 0 0 0 0 0 0 0 0 0 ... + ..$ hex : chr [1:191878] "#000000" "#000000" "#000000" "#000000" ... + ..$ lum : num [1:191878] 0 0 0 0 0 0 0 0 0 0 ... + ..$ frameId: int [1:191878] 1 2 3 4 5 6 7 8 9 10 ... + ..- attr(*, "avgRGB")= chr "#3A413D" + ..- attr(*, "title")= chr "1997 - Princess Mononoke" + ..- attr(*, "duration")= num 7995 + $ :'data.frame': 148236 obs. of 6 variables: + ..$ R : num [1:148236] 0 0 0 0 0 0 0 0 0 0 ... + ..$ G : num [1:148236] 0 0 0 0 0 0 0 0 0 0 ... + ..$ B : num [1:148236] 0 0 0 0 0 0 0 0 0 0 ... + ..$ hex : chr [1:148236] "#000000" "#000000" "#000000" "#000000" ... + ..$ lum : num [1:148236] 0 0 0 0 0 0 0 0 0 0 ... + ..$ frameId: int [1:148236] 1 2 3 4 5 6 7 8 9 10 ... + ..- attr(*, "avgRGB")= chr "#4D575B" + ..- attr(*, "title")= chr "1998 - Kiki's Delivery Service" + ..- attr(*, "duration")= num 6176 + $ :'data.frame': 179221 obs. of 6 variables: + ..$ R : num [1:179221] 0 0 0 0 0 0 0 0 0 0 ... + ..$ G : num [1:179221] 0 0 0 0 0 0 0 0 0 0 ... + ..$ B : num [1:179221] 0 0 0 0 0 0 0 0 0 0 ... + ..$ hex : chr [1:179221] "#000000" "#000000" "#000000" "#000000" ... + ..$ lum : num [1:179221] 0 0 0 0 0 0 0 0 0 0 ... + ..$ frameId: int [1:179221] 1 2 3 4 5 6 7 8 9 10 ... + ..- attr(*, "avgRGB")= chr "#5F5343" + ..- attr(*, "title")= chr "2001 - Spirited Away" + ..- attr(*, "duration")= num 7468 + $ :'data.frame': 171409 obs. of 6 variables: + ..$ R : num [1:171409] 0 0 0 0 0 0 0 0 0 0 ... + ..$ G : num [1:171409] 0 0 0 0 0 0 0 0 0 0 ... + ..$ B : num [1:171409] 0 0 0 0 0 0 0 0 0 0 ... + ..$ hex : chr [1:171409] "#000000" "#000000" "#000000" "#000000" ... + ..$ lum : num [1:171409] 0 0 0 0 0 0 0 0 0 0 ... + ..$ frameId: int [1:171409] 1 2 3 4 5 6 7 8 9 10 ... + ..- attr(*, "avgRGB")= chr "#514D43" + ..- attr(*, "title")= chr "2005 - Howl's Moving Castle" + ..- attr(*, "duration")= num 7142 + $ :'data.frame': 145055 obs. of 6 variables: + ..$ R : num [1:145055] 0 0 0 0 0 ... + ..$ G : num [1:145055] 0 0 0 0 0 ... + ..$ B : num [1:145055] 0 0 0 0 0 ... + ..$ hex : chr [1:145055] "#000000" "#000000" "#000000" "#000000" ... + ..$ lum : num [1:145055] 0 0 0 0 0 ... + ..$ frameId: int [1:145055] 1 2 3 4 5 6 7 8 9 10 ... + ..- attr(*, "avgRGB")= chr "#697060" + ..- attr(*, "title")= chr "2008 - Ponyo on the Cliff by the Sea" + ..- attr(*, "duration")= num 6044 + $ :'data.frame': 181985 obs. of 6 variables: + ..$ R : num [1:181985] 0 0 0 0 0 0 0 0 0 0 ... + ..$ G : num [1:181985] 0 0 0 0 0 0 0 0 0 0 ... + ..$ B : num [1:181985] 0 0 0 0 0 0 0 0 0 0 ... + ..$ hex : chr [1:181985] "#000000" "#000000" "#000000" "#000000" ... + ..$ lum : num [1:181985] 0 0 0 0 0 0 0 0 0 0 ... + ..$ frameId: int [1:181985] 1 2 3 4 5 6 7 8 9 10 ... + ..- attr(*, "avgRGB")= chr "#5D6150" + ..- attr(*, "title")= chr "2013 - The Wind Rises" + ..- attr(*, "duration")= num 7583 +} +\details{ +details +} +\source{ +source +} +\references{ +references +} +\examples{ +data(miyazaki) +} +\keyword{datasets} diff --git a/chromaR/man/plotTimeWindows.Rd b/chromaR/man/plotTimeWindows.Rd index d0d792e..0111c29 100644 --- a/chromaR/man/plotTimeWindows.Rd +++ b/chromaR/man/plotTimeWindows.Rd @@ -14,15 +14,17 @@ plotTimeWindows( ) } \arguments{ -\item{vivid}{frames} +\item{frames}{frames} -\item{verbose}{frames} +\item{vivid}{vivid} -\item{title}{frames} +\item{verbose}{verbose} -\item{subtitle}{frames} +\item{title}{title} -\item{left}{frames} +\item{subtitle}{subtitle} + +\item{left}{left} } \value{ none