{"id":13788819,"url":"https://github.com/sebdalgarno/tinter","last_synced_at":"2025-12-12T02:27:10.174Z","repository":{"id":44752470,"uuid":"156039908","full_name":"sebdalgarno/tinter","owner":"sebdalgarno","description":"An R package to get tints and shades (and both) of a colour","archived":false,"fork":false,"pushed_at":"2022-01-26T21:06:24.000Z","size":4472,"stargazers_count":51,"open_issues_count":3,"forks_count":2,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-12-03T05:26:34.644Z","etag":null,"topics":["color","colour","rstats"],"latest_commit_sha":null,"homepage":"","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sebdalgarno.png","metadata":{"files":{"readme":"README.Rmd","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-11-04T01:46:06.000Z","updated_at":"2024-08-22T18:46:46.000Z","dependencies_parsed_at":"2022-08-22T10:00:23.346Z","dependency_job_id":null,"html_url":"https://github.com/sebdalgarno/tinter","commit_stats":null,"previous_names":["poissonconsulting/tinter"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/sebdalgarno/tinter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sebdalgarno%2Ftinter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sebdalgarno%2Ftinter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sebdalgarno%2Ftinter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sebdalgarno%2Ftinter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sebdalgarno","download_url":"https://codeload.github.com/sebdalgarno/tinter/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sebdalgarno%2Ftinter/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":27674642,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-12-12T02:00:06.775Z","response_time":129,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["color","colour","rstats"],"created_at":"2024-08-03T21:00:54.172Z","updated_at":"2025-12-12T02:27:10.157Z","avatar_url":"https://github.com/sebdalgarno.png","language":"R","funding_links":[],"categories":["ggplot","R"],"sub_categories":["Palettes 🎨"],"readme":"---\noutput: github_document\n---\n\n\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\n\n```{r, echo = FALSE}\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  fig.path = \"man/figures/README-\",\n  fig.width = 5, fig.height = 1\n)\n```\n\n# tinter \u003cimg src=\"man/figures/logo.png\" align=\"right\" width='20%'/\u003e\n\n[![lifecycle](https://img.shields.io/badge/lifecycle-maturing-blue.svg)](https://www.tidyverse.org/lifecycle/#maturing)\n[![R build status](https://github.com/poissonconsulting/tinter/workflows/R-CMD-check/badge.svg)](https://github.com/poissonconsulting/tinter/actions)\n [![Coverage status](https://codecov.io/gh/poissonconsulting/tinter/branch/master/graph/badge.svg)](https://codecov.io/github/poissonconsulting/tinter?branch=master)\n[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT)\n[![CRAN status](https://www.r-pkg.org/badges/version/tinter)](https://cran.r-project.org/package=tinter)\n![CRAN Downloads](http://cranlogs.r-pkg.org/badges/grand-total/tinter)\n\n### Introduction  \n`tinter` provides a simple way to generate monochromatic palettes. Easily define: \n\n+ palette direction (\"shades\", \"tints\", or \"both\"). \n+ number of colours to generate on either side (`steps`). \n+ number of colours to remove from extreme end(s) of palette (e.g. default `crop = 1` eliminates black and white).\n+ darker or lighter output (`adjust`).\n\n```{r global}\nlibrary(tinter)\nhex \u003c- \"#335CAC\"\n```\n\n```{r colour, echo = FALSE, fig.width = 2, fig.height = 0.5}\ntinter_plot \u003c- function(x) {\n  grid \u003c- c(length(x), 1)\n  width \u003c- 0.9 / (max(grid) + 1)\n  gap \u003c- 1 / (max(grid) + 1)\n  centres \u003c- lapply(grid, function(i) {\n    gap * ((max(grid) -\n      i) / 2 + seq_len(i))\n  })\n  centres \u003c- as.matrix(expand.grid(centres))\n  oldPars \u003c- graphics::par(mai = c(0, 0, 0, 0), bg = \"white\")\n  on.exit(graphics::par(oldPars))\n  devSize \u003c- grDevices::dev.size()\n  devRatio \u003c- devSize[2] / devSize[1]\n  graphics::plot(NA, NA,\n    xlim = c(-0.1, 1.1), ylim = 0.5 + c(-1, 1) *\n      devRatio * 0.6, xlab = \"\", ylab = \"\", xaxt = \"n\", yaxt = \"n\",\n    bty = \"n\", asp = 1\n  )\n  graphics::rect(centres[, 1] - width / 2, rev(centres[, 2]) - width / 2,\n    centres[, 1] + width / 2, rev(centres[, 2]) + width / 2,\n    col = x, border = \"white\", lwd = 0.2\n  )\n}\n\ntinter_plot(hex)\n```\n\n```{r}\ntinter(hex)\n```\n\n```{r tinter, echo=FALSE}\ntinter_plot(tinter(hex))\n```\n\n```{r, results=\"hide\"}\ntinter(hex, direction = \"tints\")\n```\n\n```{r tints, echo=FALSE}\ntinter_plot(tinter(hex, direction = \"tints\"))\n```\n\n```{r, results=\"hide\"}\ntinter(hex, steps = 10)\n```\n\n```{r steps, echo=FALSE}\ntinter_plot(tinter(hex, steps = 10))\n```\n\n```{r, results=\"hide\"}\ntinter(hex, steps = 10, crop = 7)\n```\n\n```{r crop, echo=FALSE}\ntinter_plot(tinter(hex, steps = 10, crop = 7))\n```\n \n```{r, results=\"hide\"}\ntinter(hex, steps = 10, crop = 7, adjust = 0.4)\n```\n\n```{r darken, echo=FALSE}\ntinter_plot(tinter(hex, steps = 10, crop = 7, adjust = 0.4))\n```\n\n### Create a choropleth map\n\n```{r plot, fig.height = 4, fig.width = 8, message=FALSE, warning=FALSE, results=\"hide\"}\nlibrary(ggplot2)\nlibrary(sf)\n\nnc \u003c- st_read(system.file(package = \"sf\", \"shape/nc.shp\"))\n\nggplot(data = nc) +\n  geom_sf(aes(fill = AREA), colour = \"white\", lwd = 0.04) +\n  # colours from tinter\n  scale_fill_gradientn(colours = tinter(hex)) +\n  theme_void() +\n  coord_sf(datum = NA)\n```\n\n### Doesn't this already exist?\n`tinter` just simplifies a task usually done with `grDevices`.  It's default is to remove black and white from the palette.  \n\n```{r}\ntinter(\"blue\")\n\n### ------ is identical to\n\ngrDevices::colorRampPalette(colors = c(\"white\", \"blue\", \"black\"))(11)[-(c(1, 11))]\n```\n\n```{r}\ntinter(\"blue\", direction = \"shades\")\n\n### --- is identical to\n\ngrDevices::colorRampPalette(colors = c(\"blue\", \"black\"))(6)[-6]\n```\n\n\n```{r}\ntinter(\"blue\", crop = 2)\n\n### --- is identical to\n\ngrDevices::colorRampPalette(colors = c(\"white\", \"blue\", \"black\"))(11)[-(c(1:2, 10:11))]\n```\n\n## Installation\n\nTo install the latest release from [CRAN](https://cran.r-project.org)\n```{r, eval=FALSE}\ninstall.packages(\"tinter\")\n```\n\nTo install the developmental version from [GitHub](https://github.com/poissonconsulting/tinter)\n```{r, eval=FALSE}\n# install.packages(\"remotes\")\nremotes::install_github(\"poissonconsulting/tinter\")\n```\n\n## Contribution\n\nPlease report any [issues](https://github.com/poissonconsulting/tinter/issues).\n\n[Pull requests](https://github.com/poissonconsulting/tinter/pulls) are always welcome.\n\nPlease note that the tinter project is released with a [Contributor Code of Conduct](https://contributor-covenant.org/version/2/0/CODE_OF_CONDUCT.html). By contributing to this project, you agree to abide by its terms.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsebdalgarno%2Ftinter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsebdalgarno%2Ftinter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsebdalgarno%2Ftinter/lists"}