R/J007_checkPatterns.R

Defines functions checkPattern2 checkPattern1

Documented in checkPattern1 checkPattern2

#' Check Patterns
#'
#' @description
#' Functions to create chequered patterns
#' @param x0,x1,y0,y1 co-ordinates for the top, bottom, left and right of the square.
#' @param backgroundBorder,patternBorder colour for the lines in the background and foreground.
#' @param foreground,background colours for the foreground and background.
#' @param ... parameters passed to the component.
#' @details
#' Two functions that make checkered patterns.
#' @return return a single component
#' @family patterns
#' @seealso
#' @examples
#' print(1+1)
#' @name checkPatterns
NULL

#' @rdname checkPatterns
#' @export
checkPattern1=function(x0,x1,y0,y1,backgroundBorder="black",background="black",patternBorder="black",foreground="white",...){
	answer=blankPattern(x0,x1,y0,y1,backgroundBorder,background,...)
	answer=addPolygonToPattern(answer,c(x0,(x1+x0)/2,(x1+x0)/2,x0),c(y0,y0,(y0+y1)/2,(y0+y1)/2),NA,foreground)
	answer=addPolygonToPattern(answer,c((x1+x0)/2,x1,x1,(x1+x0)/2),c((y0+y1)/2,(y0+y1)/2,y1,y1),NA,foreground)
	if(!is.na(patternBorder)){
		answer=addLineToPattern(answer,(x1+x0)/2,(x1+x0)/2,y0,y1,patternBorder)
		answer=addLineToPattern(answer,x0,x1,(y0+y1)/2,(y0+y1)/2,patternBorder)
	}
	return(answer)
}

#' @rdname checkPatterns
#' @export
checkPattern2=function(x0,x1,y0,y1,backgroundBorder="black",background="black",patternBorder="black",foreground="white",...){
	answer=blankPattern(x0,x1,y0,y1,backgroundBorder,background,...)
	answer=addPolygonToPattern(answer,c(x0,(x1+x0)/2,x0),c(y0,(y0+y1)/2,y1),NA,foreground)
	answer=addPolygonToPattern(answer,c((x1+x0)/2,x1,x1),c((y0+y1)/2,y1,y0),NA,foreground)
	if(!is.na(patternBorder)){
		answer=addLineToPattern(answer,x0,x1,y0,y1,patternBorder)
		answer=addLineToPattern(answer,x0,x1,y1,y0,patternBorder)
	}
	return(answer)
}
R-graphic-design/RGD documentation built on Jan. 2, 2023, 10:30 p.m.