Skip to content

An improved version of the `grid` package's rounded rectangles, allowing each corner to have a different radius instead of a uniform one. This package also provides more intuitive parameter names for easier usage. Customize fill color, border properties, opacity, and more with a simple function call.

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md
Notifications You must be signed in to change notification settings

shahriar-siham/roundrect

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Logo

roundrect - Custom Rounded Rectangle Drawing in R

roundrect is an R package that allows you to easily draw custom rounded rectangles with individually adjustable corner radii. Unlike the grid package's grid.roundrect() that applies the same radius to all corners, this package enables you to set different radii for each corner of the rectangle, making it more flexible for various graphical needs.

Features

  • Draw a rounded rectangle with customizable corner radii.
  • Easily adjust rectangle position, size, border color, and fill color.
  • Control opacity, border width, and border style.
  • Straightforward parameter names for easier understanding and use.

Installation

You can install the package from GitHub using the devtools package:

# Install devtools if not already installed
install.packages("devtools")

# Install roundrect from GitHub
devtools::install_github("shahriar-siham/roundrect")

Example

library(roundrect)

round_rect(
  fill = "#e43a59", 
  border = NA, 
  scale = c(0.5, 0.5), 
  corners = c(0.25, 0.05, 0.25, 0.05)
)

Example: Rounded Rectangle
Figure: Output of the example code.

Parameters:

  • position: A vector specifying the x and y positions of the rectangle (default: c(0.5, 0.5)).
  • scale: A vector specifying the width and height of the rectangle (default: c(1, 1)).
  • corners: A vector specifying the radii of the corners (clockwise) (default: c(0.15, 0.15, 0.15, 0.15)).
  • opacity: Opacity of the rectangle (default: 1).
  • fill: The fill color of the rectangle (default: NA).
  • border: The border color of the rectangle (default: "black").
  • border_width: The width of the border (default: 1).
  • border_type: The type of the border (e.g., "solid", "dashed") (default: "solid").
  • border_cap: The style of the border cap (e.g., "round", "butt") (default: "round").
  • output_as_grob: Whether to return the grob object instead of drawing it (default: FALSE).
  • name: The name of the grob object (optional).

License

This package is licensed under the MIT License.

About

An improved version of the `grid` package's rounded rectangles, allowing each corner to have a different radius instead of a uniform one. This package also provides more intuitive parameter names for easier usage. Customize fill color, border properties, opacity, and more with a simple function call.

Topics

Resources

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages