├── .Rbuildignore ├── .github ├── .gitignore ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── ISSUE_TEMPLATE │ ├── bug.md │ └── feature-request.md ├── SUPPORT.md ├── pull_request_template.md └── workflows │ ├── R-CMD-check.yaml │ ├── coverage.yaml │ ├── pkgdown.yaml │ └── pr-commands.yaml ├── .gitignore ├── CRAN-RELEASE ├── DESCRIPTION ├── LICENSE ├── LICENSE.md ├── NAMESPACE ├── NEWS.md ├── R ├── chk.R ├── namespace.R ├── tinter.R ├── utils.R └── vld.R ├── README.Rmd ├── README.md ├── _pkgdown.yml ├── codecov.yml ├── cran-comments.md ├── man ├── chk_color.Rd ├── darken.Rd ├── figures │ ├── README-colour-1.png │ ├── README-crop-1.png │ ├── README-darken-1.png │ ├── README-plot-1.png │ ├── README-steps-1.png │ ├── README-tinter-1.png │ ├── README-tints-1.png │ ├── colour-1.png │ ├── crop-1.png │ ├── darken-1.png │ ├── logo.png │ ├── plot-1.png │ ├── steps-1.png │ ├── tinter-1.png │ └── tints-1.png ├── lighten.Rd ├── tinter.Rd └── vld_color.Rd ├── pkgdown └── favicon │ ├── apple-touch-icon-120x120.png │ ├── apple-touch-icon-152x152.png │ ├── apple-touch-icon-180x180.png │ ├── apple-touch-icon-60x60.png │ ├── apple-touch-icon-76x76.png │ ├── apple-touch-icon.png │ ├── favicon-16x16.png │ ├── favicon-32x32.png │ └── favicon.ico ├── scripts ├── build.R └── hex.R ├── tests ├── testthat.R └── testthat │ ├── test-chk.R │ ├── test-utils.R │ ├── test-vld.R │ └── test-zzz-package.R └── tinter.Rproj /.Rbuildignore: -------------------------------------------------------------------------------- 1 | ^.*\.Rproj$ 2 | ^\.Rproj\.user$ 3 | ^\.github$ 4 | ^data-raw$ 5 | ^docs$ 6 | ^pkgdown$ 7 | ^revdep$ 8 | ^scripts$ 9 | ^codecov\.yml$ 10 | ^\.covrignore$ 11 | ^cran-comments\.md$ 12 | ^CRAN-RELEASE$ 13 | ^LICENSE\.md$ 14 | ^_pkgdown\.yml$ 15 | ^README\.Rmd$ 16 | -------------------------------------------------------------------------------- /.github/.gitignore: -------------------------------------------------------------------------------- 1 | *.html 2 | -------------------------------------------------------------------------------- /.github/CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | We as members, contributors, and leaders pledge to make participation in our 6 | community a harassment-free experience for everyone, regardless of age, body 7 | size, visible or invisible disability, ethnicity, sex characteristics, gender 8 | identity and expression, level of experience, education, socio-economic status, 9 | nationality, personal appearance, race, religion, or sexual identity and 10 | orientation. 11 | 12 | We pledge to act and interact in ways that contribute to an open, welcoming, 13 | diverse, inclusive, and healthy community. 14 | 15 | ## Our Standards 16 | 17 | Examples of behavior that contributes to a positive environment for our 18 | community include: 19 | 20 | * Demonstrating empathy and kindness toward other people 21 | * Being respectful of differing opinions, viewpoints, and experiences 22 | * Giving and gracefully accepting constructive feedback 23 | * Accepting responsibility and apologizing to those affected by our mistakes, 24 | and learning from the experience 25 | * Focusing on what is best not just for us as individuals, but for the overall 26 | community 27 | 28 | Examples of unacceptable behavior include: 29 | 30 | * The use of sexualized language or imagery, and sexual attention or 31 | advances of any kind 32 | * Trolling, insulting or derogatory comments, and personal or political attacks 33 | * Public or private harassment 34 | * Publishing others' private information, such as a physical or email 35 | address, without their explicit permission 36 | * Other conduct which could reasonably be considered inappropriate in a 37 | professional setting 38 | 39 | ## Enforcement Responsibilities 40 | 41 | Community leaders are responsible for clarifying and enforcing our standards 42 | of acceptable behavior and will take appropriate and fair corrective action in 43 | response to any behavior that they deem inappropriate, threatening, offensive, 44 | or harmful. 45 | 46 | Community leaders have the right and responsibility to remove, edit, or reject 47 | comments, commits, code, wiki edits, issues, and other contributions that are 48 | not aligned to this Code of Conduct, and will communicate reasons for moderation 49 | decisions when appropriate. 50 | 51 | ## Scope 52 | 53 | This Code of Conduct applies within all community spaces, and also applies 54 | when an individual is officially representing the community in public spaces. 55 | Examples of representing our community include using an official e-mail 56 | address, posting via an official social media account, or acting as an appointed 57 | representative at an online or offline event. 58 | 59 | ## Enforcement 60 | 61 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 62 | reported to the community leaders responsible for enforcement at [INSERT CONTACT 63 | METHOD]. All complaints will be reviewed and investigated promptly and fairly. 64 | 65 | All community leaders are obligated to respect the privacy and security of the 66 | reporter of any incident. 67 | 68 | ## Enforcement Guidelines 69 | 70 | Community leaders will follow these Community Impact Guidelines in determining 71 | the consequences for any action they deem in violation of this Code of Conduct: 72 | 73 | ### 1. Correction 74 | 75 | **Community Impact**: Use of inappropriate language or other behavior deemed 76 | unprofessional or unwelcome in the community. 77 | 78 | **Consequence**: A private, written warning from community leaders, providing 79 | clarity around the nature of the violation and an explanation of why the 80 | behavior was inappropriate. A public apology may be requested. 81 | 82 | ### 2. Warning 83 | 84 | **Community Impact**: A violation through a single incident or series of 85 | actions. 86 | 87 | **Consequence**: A warning with consequences for continued behavior. No 88 | interaction with the people involved, including unsolicited interaction with 89 | those enforcing the Code of Conduct, for a specified period of time. This 90 | includes avoiding interactions in community spaces as well as external channels 91 | like social media. Violating these terms may lead to a temporary or permanent 92 | ban. 93 | 94 | ### 3. Temporary Ban 95 | 96 | **Community Impact**: A serious violation of community standards, including 97 | sustained inappropriate behavior. 98 | 99 | **Consequence**: A temporary ban from any sort of interaction or public 100 | communication with the community for a specified period of time. No public or 101 | private interaction with the people involved, including unsolicited interaction 102 | with those enforcing the Code of Conduct, is allowed during this period. 103 | Violating these terms may lead to a permanent ban. 104 | 105 | ### 4. Permanent Ban 106 | 107 | **Community Impact**: Demonstrating a pattern of violation of community 108 | standards, including sustained inappropriate behavior, harassment of an 109 | individual, or aggression toward or disparagement of classes of individuals. 110 | 111 | **Consequence**: A permanent ban from any sort of public interaction within the 112 | community. 113 | 114 | ## Attribution 115 | 116 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], 117 | version 2.0, 118 | available at https://www.contributor-covenant.org/version/2/0/ 119 | code_of_conduct.html. 120 | 121 | Community Impact Guidelines were inspired by [Mozilla's code of conduct 122 | enforcement ladder](https://github.com/mozilla/diversity). 123 | 124 | [homepage]: https://www.contributor-covenant.org 125 | 126 | For answers to common questions about this code of conduct, see the FAQ at 127 | https://www.contributor-covenant.org/faq. Translations are available at https:// 128 | www.contributor-covenant.org/translations. 129 | -------------------------------------------------------------------------------- /.github/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to tinter 2 | 3 | This outlines how to propose a change to tinter. 4 | 5 | ## Fixing typos 6 | 7 | You can fix typos, spelling mistakes, or grammatical errors in the documentation directly using the GitHub web interface, as long as the changes are made in the _source_ file. 8 | This generally means you'll need to edit [roxygen2 comments](https://roxygen2.r-lib.org/articles/roxygen2.html) in an `.R`, not a `.Rd` file. 9 | You can find the `.R` file that generates the `.Rd` by reading the comment in the first line. 10 | 11 | ## Bigger changes 12 | 13 | If you want to make a bigger change, it's a good idea to first file an issue and make sure someone from the team agrees that it’s needed. 14 | If you’ve found a bug, please file an issue that illustrates the bug with a minimal 15 | [reprex](https://www.tidyverse.org/help/#reprex) (this will also help you write a unit test, if needed). 16 | 17 | ### Pull request process 18 | 19 | * Fork the package and clone onto your computer. If you haven't done this before, we recommend using `usethis::create_from_github("", fork = TRUE)`. 20 | 21 | * Install all development dependences with `devtools::install_dev_deps()`, and then make sure the package passes R CMD check by running `devtools::check()`. 22 | If R CMD check doesn't pass cleanly, it's a good idea to ask for help before continuing. 23 | * Create a Git branch for your pull request (PR). We recommend using `usethis::pr_init("brief-description-of-change")`. 24 | 25 | * Make your changes, commit to git, and then create a PR by running `usethis::pr_push()`, and following the prompts in your browser. 26 | The title of your PR should briefly describe the change. 27 | The body of your PR should contain `Fixes #issue-number`. 28 | 29 | * Begin commit or merge messages with `-` to indicate user facing changes that should be included in NEWS.md. 30 | We will use [fledge](https://github.com/krlmlr/fledge) to automatically generate the NEWS.md file. 31 | 32 | ### Code style 33 | 34 | * New code should follow the tidyverse [style guide](https://style.tidyverse.org). 35 | You can use the [styler](https://CRAN.R-project.org/package=styler) package to apply these styles, but please don't restyle code that has nothing to do with your PR. 36 | 37 | * We use [roxygen2](https://cran.r-project.org/package=roxygen2), with [Markdown syntax](https://cran.r-project.org/web/packages/roxygen2/vignettes/rd-formatting.html), for documentation. 38 | 39 | * We use [testthat](https://cran.r-project.org/package=testthat) for unit tests. 40 | Contributions with test cases included are easier to accept. 41 | 42 | ## Code of Conduct 43 | 44 | Please note that the tinter project is released with a 45 | [Contributor Code of Conduct](/.github/CODE_OF_CONDUCT.md). 46 | By contributing to this project you agree to abide by its terms. 47 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Describe a bug you're experiencing 4 | --- 5 | 6 | ## The Bug 7 | 8 | Please briefly describe your problem and what output you expect. 9 | 10 | ## A Reprex 11 | 12 | Please include a minimal reproducible example (AKA a reprex). 13 | If you've never heard of a [reprex](http://reprex.tidyverse.org/) before, start by reading . 14 | 15 | ```r 16 | # insert reprex here 17 | ``` 18 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature-request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | --- 5 | 6 | ## Your Idea 7 | 8 | Please briefly describe your idea. 9 | -------------------------------------------------------------------------------- /.github/SUPPORT.md: -------------------------------------------------------------------------------- 1 | # Getting help with tinter 2 | 3 | Thanks for using tinter! 4 | Before filing an issue, there are a few places to explore and pieces to put together to make the process as smooth as possible. 5 | 6 | ## Make sure its new 7 | 8 | Before opening a new issue, be sure to [search issues and pull requests](https://github.com//issues) to make sure the bug hasn't been reported and/or already fixed in the development version. 9 | By default, the search will be pre-populated with `is:issue is:open`. 10 | You can [edit the qualifiers](https://help.github.com/articles/searching-issues-and-pull-requests/) (e.g. `is:pr`, `is:closed`) as needed. 11 | For example, you'd simply remove `is:open` to search _all_ issues in the repo, open or closed. 12 | 13 | ## Make a reprex 14 | 15 | Start by making a minimal **repr**oducible **ex**ample using the [reprex](https://reprex.tidyverse.org/) package. 16 | If you haven't heard of or used reprex before, you're in for a treat! 17 | Seriously, reprex will make all of your R-question-asking endeavors easier (which is a pretty insane ROI for the five to ten minutes it'll take you to learn what it's all about). 18 | For additional reprex pointers, check out the [Get help!](https://www.tidyverse.org/help/) section of the tidyverse site. 19 | -------------------------------------------------------------------------------- /.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | Thank you for taking the time to submit a pull request! 2 | 3 | To maximize the chances of acceptance: 4 | 5 | * The title of your PR should briefly describe the change. 6 | 7 | * The body of your PR should contain `Fixes #issue-number` (if relevant). 8 | 9 | * Commit/merge messages to be included in NEWS.md should begin with `-`. 10 | 11 | * Code should follow the tidyverse [style guide](https://style.tidyverse.org). 12 | 13 | * Documentation should use roxygen2, with Markdown syntax. 14 | 15 | * Contributions should include unit tests (using `testthat`). 16 | 17 | For more information see [Contributing](/.github/CONTRIBUTING.md). 18 | -------------------------------------------------------------------------------- /.github/workflows/R-CMD-check.yaml: -------------------------------------------------------------------------------- 1 | on: 2 | push: 3 | branches: 4 | - master 5 | pull_request: 6 | branches: 7 | - master 8 | schedule: 9 | - cron: '0 8 * * *' 10 | 11 | name: R-CMD-check 12 | 13 | jobs: 14 | R-CMD-check: 15 | runs-on: ${{ matrix.config.os }} 16 | 17 | name: ${{ matrix.config.os }} (${{ matrix.config.r }}) 18 | 19 | strategy: 20 | fail-fast: false 21 | matrix: 22 | config: 23 | - {os: macOS-latest, r: 'devel'} 24 | - {os: macOS-latest, r: 'release'} 25 | - {os: windows-latest, r: 'release'} 26 | - {os: ubuntu-16.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"} 27 | - {os: ubuntu-16.04, r: 'oldrel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"} 28 | - {os: ubuntu-16.04, r: '3.5', rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"} 29 | - {os: ubuntu-16.04, r: '3.4', rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"} 30 | 31 | env: 32 | R_REMOTES_NO_ERRORS_FROM_WARNINGS: true 33 | RSPM: ${{ matrix.config.rspm }} 34 | GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} 35 | 36 | steps: 37 | - uses: actions/checkout@v2 38 | 39 | - uses: r-lib/actions/setup-r@master 40 | with: 41 | r-version: ${{ matrix.config.r }} 42 | 43 | - uses: r-lib/actions/setup-pandoc@master 44 | 45 | - name: Query dependencies 46 | run: | 47 | install.packages('remotes') 48 | saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2) 49 | writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version") 50 | shell: Rscript {0} 51 | 52 | - name: Cache R packages 53 | if: runner.os != 'Windows' 54 | uses: actions/cache@v1 55 | with: 56 | path: ${{ env.R_LIBS_USER }} 57 | key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }} 58 | restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1- 59 | 60 | - name: Install system dependencies 61 | if: runner.os == 'Linux' 62 | env: 63 | RHUB_PLATFORM: linux-x86_64-ubuntu-gcc 64 | run: | 65 | Rscript -e "remotes::install_github('r-hub/sysreqs')" 66 | sysreqs=$(Rscript -e "cat(sysreqs::sysreq_commands('DESCRIPTION'))") 67 | sudo -s eval "$sysreqs" 68 | 69 | - name: Install dependencies 70 | run: | 71 | remotes::install_deps(dependencies = TRUE) 72 | remotes::install_cran("rcmdcheck") 73 | shell: Rscript {0} 74 | 75 | - name: Session info 76 | run: | 77 | options(width = 100) 78 | pkgs <- installed.packages()[, "Package"] 79 | sessioninfo::session_info(pkgs, include_base = TRUE) 80 | shell: Rscript {0} 81 | 82 | - name: Check 83 | env: 84 | _R_CHECK_CRAN_INCOMING_: false 85 | run: rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran"), error_on = "warning", check_dir = "check") 86 | shell: Rscript {0} 87 | 88 | - name: Show testthat output 89 | if: always() 90 | run: find check -name 'testthat.Rout*' -exec cat '{}' \; || true 91 | shell: bash 92 | 93 | - name: Upload check results 94 | if: failure() 95 | uses: actions/upload-artifact@master 96 | with: 97 | name: ${{ runner.os }}-r${{ matrix.config.r }}-results 98 | path: check 99 | 100 | - name: action-slack 101 | if: failure() 102 | uses: 8398a7/action-slack@v3.0.0 103 | env: 104 | SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} 105 | with: 106 | status: ${{ job.status }} 107 | author_name: "github action: R-CMD-check" 108 | fields: repo, workflow, commit, message, author, action 109 | -------------------------------------------------------------------------------- /.github/workflows/coverage.yaml: -------------------------------------------------------------------------------- 1 | on: 2 | push: 3 | branches: 4 | - master 5 | pull_request: 6 | branches: 7 | - master 8 | 9 | name: coverage 10 | 11 | jobs: 12 | coverage: 13 | runs-on: macOS-latest 14 | env: 15 | GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} 16 | steps: 17 | - uses: actions/checkout@v2 18 | 19 | - uses: r-lib/actions/setup-r@master 20 | 21 | - uses: r-lib/actions/setup-pandoc@master 22 | 23 | - name: Query dependencies 24 | run: | 25 | install.packages('remotes') 26 | saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2) 27 | writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version") 28 | shell: Rscript {0} 29 | 30 | - name: Cache R packages 31 | uses: actions/cache@v1 32 | with: 33 | path: ${{ env.R_LIBS_USER }} 34 | key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }} 35 | restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1- 36 | 37 | - name: Install dependencies 38 | run: | 39 | install.packages(c("remotes")) 40 | remotes::install_deps(dependencies = TRUE) 41 | remotes::install_cran("covr") 42 | shell: Rscript {0} 43 | 44 | - name: Test coverage 45 | run: covr::codecov() 46 | shell: Rscript {0} 47 | -------------------------------------------------------------------------------- /.github/workflows/pkgdown.yaml: -------------------------------------------------------------------------------- 1 | on: 2 | push: 3 | branches: master 4 | 5 | name: pkgdown 6 | 7 | jobs: 8 | pkgdown: 9 | runs-on: macOS-latest 10 | env: 11 | GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} 12 | steps: 13 | - uses: actions/checkout@v2 14 | 15 | - uses: r-lib/actions/setup-r@master 16 | 17 | - uses: r-lib/actions/setup-pandoc@master 18 | 19 | - name: Query dependencies 20 | run: | 21 | install.packages('remotes') 22 | saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2) 23 | writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version") 24 | shell: Rscript {0} 25 | 26 | - name: Cache R packages 27 | uses: actions/cache@v1 28 | with: 29 | path: ${{ env.R_LIBS_USER }} 30 | key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }} 31 | restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1- 32 | 33 | - name: Install dependencies 34 | run: | 35 | install.packages("remotes") 36 | remotes::install_deps(dependencies = TRUE) 37 | remotes::install_dev("pkgdown") 38 | shell: Rscript {0} 39 | 40 | - name: Install package 41 | run: R CMD INSTALL . 42 | 43 | - name: Deploy package 44 | run: pkgdown::deploy_to_branch(new_process = FALSE) 45 | shell: Rscript {0} 46 | - name: action-slack 47 | uses: 8398a7/action-slack@v3.0.0 48 | with: 49 | status: ${{ job.status }} 50 | author_name: "github action: pkgdown" 51 | fields: repo, workflow, commit, message, author, action 52 | env: 53 | SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} 54 | if: failure() 55 | -------------------------------------------------------------------------------- /.github/workflows/pr-commands.yaml: -------------------------------------------------------------------------------- 1 | on: 2 | issue_comment: 3 | types: [created] 4 | name: Commands 5 | jobs: 6 | document: 7 | if: startsWith(github.event.comment.body, '/document') 8 | name: document 9 | runs-on: macOS-latest 10 | env: 11 | GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} 12 | steps: 13 | - uses: actions/checkout@v2 14 | - uses: r-lib/actions/pr-fetch@master 15 | with: 16 | repo-token: ${{ secrets.GITHUB_TOKEN }} 17 | - uses: r-lib/actions/setup-r@master 18 | - name: Install dependencies 19 | run: Rscript -e 'install.packages(c("remotes", "roxygen2"))' -e 'remotes::install_deps(dependencies = TRUE)' 20 | - name: Document 21 | run: Rscript -e 'roxygen2::roxygenise()' 22 | - name: commit 23 | run: | 24 | git add man/\* NAMESPACE 25 | git commit -m 'Document' 26 | - uses: r-lib/actions/pr-push@master 27 | with: 28 | repo-token: ${{ secrets.GITHUB_TOKEN }} 29 | style: 30 | if: startsWith(github.event.comment.body, '/style') 31 | name: style 32 | runs-on: macOS-latest 33 | env: 34 | GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} 35 | steps: 36 | - uses: actions/checkout@v2 37 | - uses: r-lib/actions/pr-fetch@master 38 | with: 39 | repo-token: ${{ secrets.GITHUB_TOKEN }} 40 | - uses: r-lib/actions/setup-r@master 41 | - name: Install dependencies 42 | run: Rscript -e 'install.packages("styler")' 43 | - name: Style 44 | run: Rscript -e 'styler::style_pkg()' 45 | - name: commit 46 | run: | 47 | git add \*.R 48 | git commit -m 'Style' 49 | - uses: r-lib/actions/pr-push@master 50 | with: 51 | repo-token: ${{ secrets.GITHUB_TOKEN }} 52 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .Rproj.user 2 | .Rhistory 3 | .RData 4 | .Ruserdata 5 | 6 | .DS_Store 7 | .Renviron 8 | .RProfile 9 | .httr-oauth 10 | 11 | *.html 12 | 13 | docs/ 14 | inst/docs/ 15 | -------------------------------------------------------------------------------- /CRAN-RELEASE: -------------------------------------------------------------------------------- 1 | This package was submitted to CRAN on 2020-04-17. 2 | Once it is accepted, delete this file and tag the release (commit a77096f62a). 3 | -------------------------------------------------------------------------------- /DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: tinter 2 | Title: Generate a Monochromatic Palette 3 | Version: 0.1.0.9001 4 | Authors@R: c( 5 | person("Sebastian", "Dalgarno", role = c("aut", "cre"), email = "seb@poissonconsulting.ca"), 6 | person("Joe", "Thorley", role = "ctb", email = "joe@poissonconsulting.ca", comment = c(ORCID = "0000-0002-7683-4592"))) 7 | Description: Generate a palette of tints, shades or both from a single colour. 8 | URL: https://github.com/poissonconsulting/tinter 9 | BugReports: https://github.com/poissonconsulting/tinter/issues 10 | Depends: 11 | R (>= 3.4) 12 | Imports: 13 | chk, 14 | grDevices 15 | Suggests: 16 | graphics, 17 | covr, 18 | testthat 19 | License: MIT + file LICENSE 20 | Encoding: UTF-8 21 | LazyData: true 22 | RoxygenNote: 7.1.1.9000 23 | Language: en-US 24 | Roxygen: list(markdown = TRUE) 25 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | YEAR: 2018 2 | COPYRIGHT HOLDER: Poisson Consulting Ltd. 3 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | # MIT License 2 | 3 | Copyright (c) 2018 Poisson Consulting Ltd. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /NAMESPACE: -------------------------------------------------------------------------------- 1 | # Generated by roxygen2: do not edit by hand 2 | 3 | export(chk_color) 4 | export(chk_colour) 5 | export(darken) 6 | export(lighten) 7 | export(tinter) 8 | export(vld_color) 9 | export(vld_colour) 10 | import(chk) 11 | -------------------------------------------------------------------------------- /NEWS.md: -------------------------------------------------------------------------------- 1 | # tinter 0.1.0.9001 2 | 3 | - Same as previous version. 4 | 5 | # tinter 0.1.0.9000 6 | 7 | - Same as previous version. 8 | 9 | # tinter 0.0.1 10 | 11 | * Added a `NEWS.md` file to track changes to the package. 12 | 13 | # tinter 0.1.0 14 | 15 | * Added exported functions `chk_color`/`chk_colour` and `vld_color`/`vld_colour`. 16 | * Resolved issue in r devel build caused by testing condition on vector of length two. 17 | -------------------------------------------------------------------------------- /R/chk.R: -------------------------------------------------------------------------------- 1 | #' Check Color String 2 | #' 3 | #' Checks that x is a string (non-missing character vector of length 1) 4 | #' that specifies a color. 5 | #' 6 | #' @inheritParams chk::chk_true 7 | #' @return `NULL`, invisibly. Called for the side effect of throwing an error 8 | #' if the condition is not met. 9 | #' @seealso [vld_color()] 10 | #' @name chk_color 11 | NULL 12 | 13 | #' @describeIn chk_color Check Color String Object 14 | #' 15 | #' @description 16 | #' 17 | #' `chk_color` 18 | #' checks if a color string. 19 | #' 20 | #' @export 21 | #' 22 | #' @examples 23 | #' 24 | #' # chk_color 25 | #' chk_color("blue") 26 | #' try(chk_color("glue")) 27 | chk_color <- function(x, x_name = NULL) { 28 | if (vld_color(x)) { 29 | return(invisible()) 30 | } 31 | if (is.null(x_name)) x_name <- deparse_backtick_chk(substitute(x)) 32 | chk_string(x, x_name = x_name) 33 | abort_chk(x_name, " must be a valid color", call. = FALSE) 34 | } 35 | 36 | #' @describeIn chk_color Check Color String Object 37 | #' 38 | #' @description 39 | #' 40 | #' `chk_colour` 41 | #' checks if a color string. 42 | #' 43 | #' @export 44 | #' 45 | #' @examples 46 | #' 47 | #' # chk_colour 48 | #' chk_colour("blue") 49 | #' try(chk_colour("glue")) 50 | chk_colour <- function(x, x_name = NULL) { 51 | if (vld_colour(x)) { 52 | return(invisible()) 53 | } 54 | if (is.null(x_name)) x_name <- deparse_backtick_chk(substitute(x)) 55 | chk_string(x, x_name = x_name) 56 | abort_chk(x_name, " must be a valid color", call. = FALSE) 57 | } 58 | -------------------------------------------------------------------------------- /R/namespace.R: -------------------------------------------------------------------------------- 1 | #' @import chk 2 | NULL 3 | -------------------------------------------------------------------------------- /R/tinter.R: -------------------------------------------------------------------------------- 1 | #' Generate shades, tints or both from a colour. 2 | #' 3 | #' @param x A string of a colour in any format accepted by grDevices::col2rgb(). 4 | #' @param steps An integer indicating how many shades/tints to generate (excluding x). 5 | #' @param crop An integer indicating how many extreme colours to remove (e.g. crop = 1 eliminates 'black' and 'white'). 6 | #' @param direction A string indicating whether to include 'tints', 'shades' or 'both'. 7 | #' @param adjust A number between -1 and 1. Values between 0 and -1 increasingly darken colour; values between 0 and 1 increasingly lighten colour. 8 | #' 9 | #' @return A vector of colours. 10 | #' @export 11 | #' @examples 12 | #' tinter("blue") 13 | #' tinter("#fa6a5c", steps = 10, crop = 3) 14 | #' tinter("#fa6a5c", direction = "tints") 15 | tinter <- function(x, steps = 5, crop = 1, direction = "both", adjust = 0) { 16 | chk_colour(x) 17 | chk_whole_number(steps) 18 | chk_whole_number(crop) 19 | chk_string(direction) 20 | chk_subset(direction, c("shades", "tints", "both")) 21 | chk_number(adjust) 22 | chk_range(adjust, c(-1, 1)) 23 | 24 | if (crop > steps) { 25 | stop("crop cannot be greater than steps.", call. = FALSE) 26 | } 27 | 28 | shades <- shade(x, steps, crop) 29 | tints <- tint(x, steps, crop) 30 | 31 | res <- c(tints, shades[-1]) 32 | 33 | if (direction == "shades") { 34 | res <- shades 35 | } 36 | if (direction == "tints") { 37 | res <- tints 38 | } 39 | 40 | if (adjust == 0) { 41 | return(res) 42 | } 43 | if (adjust > 0) { 44 | return(lighten(res, 1 - adjust)) 45 | } 46 | darken(res, abs(adjust)) 47 | } 48 | 49 | #' Darken colour. 50 | #' 51 | #' @param x A vector of strings of colours in any format accepted by grDevices::col2rgb(). 52 | #' @param amount A number from 0 to 1. 53 | #' 54 | #' @return A vector of modified colours. 55 | #' @export 56 | #' @examples 57 | #' darken(tinter("blue"), 0.2) 58 | darken <- function(x, amount) { 59 | chk_all(x, chk_colour) 60 | chk_number(amount) 61 | chk_range(amount) 62 | sapply(x, function(x) { 63 | shade(x, 100, 0)[amount * 100] 64 | }, USE.NAMES = FALSE) 65 | } 66 | 67 | #' Lighten colour. 68 | #' 69 | #' @param x A vector of strings of colours in any format accepted by grDevices::col2rgb(). 70 | #' @param amount A number from 0 to 1. 71 | #' 72 | #' @return A vector of modified colours. 73 | #' @export 74 | #' @examples 75 | #' lighten(tinter("blue"), 0.2) 76 | lighten <- function(x, amount) { 77 | chk_all(x, chk_colour) 78 | chk_number(amount) 79 | chk_range(amount) 80 | 81 | if (amount == 0) { 82 | amount <- 0.01 83 | } 84 | sapply(x, function(x) { 85 | tint(x, 100, 0)[amount * 100] 86 | }, USE.NAMES = FALSE) 87 | } 88 | -------------------------------------------------------------------------------- /R/utils.R: -------------------------------------------------------------------------------- 1 | shade <- function(x, steps, crop) { 2 | shade <- rev(grDevices::colorRampPalette(c(x, "black"))(steps + 1)) 3 | if (crop == 0) { 4 | return(rev(shade)) 5 | } 6 | rev(shade[-(seq_len(crop))]) 7 | } 8 | 9 | tint <- function(x, steps, crop) { 10 | tint <- rev(grDevices::colorRampPalette(c(x, "white"))(steps + 1)) 11 | if (crop == 0) { 12 | return(tint) 13 | } 14 | tint[-(seq_len(crop))] 15 | } 16 | -------------------------------------------------------------------------------- /R/vld.R: -------------------------------------------------------------------------------- 1 | #' Validate Color String 2 | #' 3 | #' Validates whether x is a string (non-missing character vector of length 1) 4 | #' that specifies a color. 5 | #' 6 | #' @inheritParams chk::chk_true 7 | #' @return A flag indicating whether the object was validated. 8 | #' @seealso [chk_color()] 9 | #' @name vld_color 10 | NULL 11 | 12 | #' @describeIn vld_color Validate Color String 13 | #' 14 | #' @export 15 | #' 16 | #' @examples 17 | #' 18 | #' # vld_color 19 | #' vld_color("blue") 20 | #' vld_color("glue") 21 | vld_color <- function(x) { 22 | vld_string(x) && !inherits(try(grDevices::col2rgb(x), silent = TRUE), "try-error") 23 | } 24 | 25 | #' @describeIn vld_color Validate Colour String 26 | #' 27 | #' @export 28 | #' 29 | #' @examples 30 | #' 31 | #' # vld_color 32 | #' vld_colour("blue") 33 | #' vld_colour("glue") 34 | vld_colour <- function(x) { 35 | vld_color(x) 36 | } 37 | -------------------------------------------------------------------------------- /README.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | output: github_document 3 | --- 4 | 5 | 6 | 7 | ```{r, echo = FALSE} 8 | knitr::opts_chunk$set( 9 | collapse = TRUE, 10 | comment = "#>", 11 | fig.path = "man/figures/README-", 12 | fig.width = 5, fig.height = 1 13 | ) 14 | ``` 15 | 16 | # tinter 17 | 18 | [![lifecycle](https://img.shields.io/badge/lifecycle-maturing-blue.svg)](https://www.tidyverse.org/lifecycle/#maturing) 19 | [![R build status](https://github.com/poissonconsulting/tinter/workflows/R-CMD-check/badge.svg)](https://github.com/poissonconsulting/tinter/actions) 20 | [![Coverage status](https://codecov.io/gh/poissonconsulting/tinter/branch/master/graph/badge.svg)](https://codecov.io/github/poissonconsulting/tinter?branch=master) 21 | [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT) 22 | [![CRAN status](https://www.r-pkg.org/badges/version/tinter)](https://cran.r-project.org/package=tinter) 23 | ![CRAN Downloads](http://cranlogs.r-pkg.org/badges/grand-total/tinter) 24 | 25 | ### Introduction 26 | `tinter` provides a simple way to generate monochromatic palettes. Easily define: 27 | 28 | + palette direction ("shades", "tints", or "both"). 29 | + number of colours to generate on either side (`steps`). 30 | + number of colours to remove from extreme end(s) of palette (e.g. default `crop = 1` eliminates black and white). 31 | + darker or lighter output (`adjust`). 32 | 33 | ```{r global} 34 | library(tinter) 35 | hex <- "#335CAC" 36 | ``` 37 | 38 | ```{r colour, echo = FALSE, fig.width = 2, fig.height = 0.5} 39 | tinter_plot <- function(x) { 40 | grid <- c(length(x), 1) 41 | width <- 0.9 / (max(grid) + 1) 42 | gap <- 1 / (max(grid) + 1) 43 | centres <- lapply(grid, function(i) { 44 | gap * ((max(grid) - 45 | i) / 2 + seq_len(i)) 46 | }) 47 | centres <- as.matrix(expand.grid(centres)) 48 | oldPars <- graphics::par(mai = c(0, 0, 0, 0), bg = "white") 49 | on.exit(graphics::par(oldPars)) 50 | devSize <- grDevices::dev.size() 51 | devRatio <- devSize[2] / devSize[1] 52 | graphics::plot(NA, NA, 53 | xlim = c(-0.1, 1.1), ylim = 0.5 + c(-1, 1) * 54 | devRatio * 0.6, xlab = "", ylab = "", xaxt = "n", yaxt = "n", 55 | bty = "n", asp = 1 56 | ) 57 | graphics::rect(centres[, 1] - width / 2, rev(centres[, 2]) - width / 2, 58 | centres[, 1] + width / 2, rev(centres[, 2]) + width / 2, 59 | col = x, border = "white", lwd = 0.2 60 | ) 61 | } 62 | 63 | tinter_plot(hex) 64 | ``` 65 | 66 | ```{r} 67 | tinter(hex) 68 | ``` 69 | 70 | ```{r tinter, echo=FALSE} 71 | tinter_plot(tinter(hex)) 72 | ``` 73 | 74 | ```{r, results="hide"} 75 | tinter(hex, direction = "tints") 76 | ``` 77 | 78 | ```{r tints, echo=FALSE} 79 | tinter_plot(tinter(hex, direction = "tints")) 80 | ``` 81 | 82 | ```{r, results="hide"} 83 | tinter(hex, steps = 10) 84 | ``` 85 | 86 | ```{r steps, echo=FALSE} 87 | tinter_plot(tinter(hex, steps = 10)) 88 | ``` 89 | 90 | ```{r, results="hide"} 91 | tinter(hex, steps = 10, crop = 7) 92 | ``` 93 | 94 | ```{r crop, echo=FALSE} 95 | tinter_plot(tinter(hex, steps = 10, crop = 7)) 96 | ``` 97 | 98 | ```{r, results="hide"} 99 | tinter(hex, steps = 10, crop = 7, adjust = 0.4) 100 | ``` 101 | 102 | ```{r darken, echo=FALSE} 103 | tinter_plot(tinter(hex, steps = 10, crop = 7, adjust = 0.4)) 104 | ``` 105 | 106 | ### Create a choropleth map 107 | 108 | ```{r plot, fig.height = 4, fig.width = 8, message=FALSE, warning=FALSE, results="hide"} 109 | library(ggplot2) 110 | library(sf) 111 | 112 | nc <- st_read(system.file(package = "sf", "shape/nc.shp")) 113 | 114 | ggplot(data = nc) + 115 | geom_sf(aes(fill = AREA), colour = "white", lwd = 0.04) + 116 | # colours from tinter 117 | scale_fill_gradientn(colours = tinter(hex)) + 118 | theme_void() + 119 | coord_sf(datum = NA) 120 | ``` 121 | 122 | ### Doesn't this already exist? 123 | `tinter` just simplifies a task usually done with `grDevices`. It's default is to remove black and white from the palette. 124 | 125 | ```{r} 126 | tinter("blue") 127 | 128 | ### ------ is identical to 129 | 130 | grDevices::colorRampPalette(colors = c("white", "blue", "black"))(11)[-(c(1, 11))] 131 | ``` 132 | 133 | ```{r} 134 | tinter("blue", direction = "shades") 135 | 136 | ### --- is identical to 137 | 138 | grDevices::colorRampPalette(colors = c("blue", "black"))(6)[-6] 139 | ``` 140 | 141 | 142 | ```{r} 143 | tinter("blue", crop = 2) 144 | 145 | ### --- is identical to 146 | 147 | grDevices::colorRampPalette(colors = c("white", "blue", "black"))(11)[-(c(1:2, 10:11))] 148 | ``` 149 | 150 | ## Installation 151 | 152 | To install the latest release from [CRAN](https://cran.r-project.org) 153 | ```{r, eval=FALSE} 154 | install.packages("tinter") 155 | ``` 156 | 157 | To install the developmental version from [GitHub](https://github.com/poissonconsulting/tinter) 158 | ```{r, eval=FALSE} 159 | # install.packages("remotes") 160 | remotes::install_github("poissonconsulting/tinter") 161 | ``` 162 | 163 | ## Contribution 164 | 165 | Please report any [issues](https://github.com/poissonconsulting/tinter/issues). 166 | 167 | [Pull requests](https://github.com/poissonconsulting/tinter/pulls) are always welcome. 168 | 169 | Please 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. 170 | 171 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | # tinter 5 | 6 | [![lifecycle](https://img.shields.io/badge/lifecycle-maturing-blue.svg)](https://www.tidyverse.org/lifecycle/#maturing) 7 | [![R build 8 | status](https://github.com/poissonconsulting/tinter/workflows/R-CMD-check/badge.svg)](https://github.com/poissonconsulting/tinter/actions) 9 | [![Coverage 10 | status](https://codecov.io/gh/poissonconsulting/tinter/branch/master/graph/badge.svg)](https://codecov.io/github/poissonconsulting/tinter?branch=master) 11 | [![License: 12 | MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT) 13 | [![CRAN 14 | status](https://www.r-pkg.org/badges/version/tinter)](https://cran.r-project.org/package=tinter) 15 | ![CRAN Downloads](http://cranlogs.r-pkg.org/badges/grand-total/tinter) 16 | 17 | ### Introduction 18 | 19 | `tinter` provides a simple way to generate monochromatic palettes. 20 | Easily define: 21 | 22 | - palette direction (“shades”, “tints”, or “both”). 23 | - number of colours to generate on either side (`steps`). 24 | - number of colours to remove from extreme end(s) of palette 25 | (e.g. default `crop = 1` eliminates black and white). 26 | - darker or lighter output (`adjust`). 27 | 28 | 29 | 30 | ``` r 31 | library(tinter) 32 | hex <- "#335CAC" 33 | ``` 34 | 35 | ![](man/figures/README-colour-1.png) 36 | 37 | ``` r 38 | tinter(hex) 39 | #> [1] "#D6DEEE" "#ADBDDD" "#849DCD" "#5B7CBC" "#335CAC" "#284989" "#1E3767" 40 | #> [8] "#142444" "#0A1222" 41 | ``` 42 | 43 | ![](man/figures/README-tinter-1.png) 44 | 45 | ``` r 46 | tinter(hex, direction = "tints") 47 | ``` 48 | 49 | ![](man/figures/README-tints-1.png) 50 | 51 | ``` r 52 | tinter(hex, steps = 10) 53 | ``` 54 | 55 | ![](man/figures/README-steps-1.png) 56 | 57 | ``` r 58 | tinter(hex, steps = 10, crop = 7) 59 | ``` 60 | 61 | ![](man/figures/README-crop-1.png) 62 | 63 | ``` r 64 | tinter(hex, steps = 10, crop = 7, adjust = 0.4) 65 | ``` 66 | 67 | ![](man/figures/README-darken-1.png) 68 | 69 | ### Create a choropleth map 70 | 71 | ``` r 72 | library(ggplot2) 73 | library(sf) 74 | 75 | nc <- st_read(system.file(package = "sf", "shape/nc.shp")) 76 | 77 | ggplot(data = nc) + 78 | geom_sf(aes(fill = AREA), colour = "white", lwd = 0.04) + 79 | # colours from tinter 80 | scale_fill_gradientn(colours = tinter(hex)) + 81 | theme_void() + 82 | coord_sf(datum = NA) 83 | ``` 84 | 85 | ![](man/figures/README-plot-1.png) 86 | 87 | ### Doesn’t this already exist? 88 | 89 | `tinter` just simplifies a task usually done with `grDevices`. It’s 90 | default is to remove black and white from the palette. 91 | 92 | ``` r 93 | tinter("blue") 94 | #> [1] "#CCCCFF" "#9999FF" "#6666FF" "#3333FF" "#0000FF" "#0000CC" "#000099" 95 | #> [8] "#000065" "#000032" 96 | 97 | ### ------ is identical to 98 | 99 | grDevices::colorRampPalette(colors = c("white", "blue", "black"))(11)[-(c(1, 11))] 100 | #> [1] "#CCCCFF" "#9999FF" "#6565FF" "#3232FF" "#0000FF" "#0000CB" "#000098" 101 | #> [8] "#000065" "#000032" 102 | ``` 103 | 104 | ``` r 105 | tinter("blue", direction = "shades") 106 | #> [1] "#0000FF" "#0000CC" "#000099" "#000065" "#000032" 107 | 108 | ### --- is identical to 109 | 110 | grDevices::colorRampPalette(colors = c("blue", "black"))(6)[-6] 111 | #> [1] "#0000FF" "#0000CC" "#000099" "#000065" "#000032" 112 | ``` 113 | 114 | ``` r 115 | tinter("blue", crop = 2) 116 | #> [1] "#9999FF" "#6666FF" "#3333FF" "#0000FF" "#0000CC" "#000099" "#000065" 117 | 118 | ### --- is identical to 119 | 120 | grDevices::colorRampPalette(colors = c("white", "blue", "black"))(11)[-(c(1:2, 10:11))] 121 | #> [1] "#9999FF" "#6565FF" "#3232FF" "#0000FF" "#0000CB" "#000098" "#000065" 122 | ``` 123 | 124 | ## Installation 125 | 126 | To install the latest release from [CRAN](https://cran.r-project.org) 127 | 128 | ``` r 129 | install.packages("tinter") 130 | ``` 131 | 132 | To install the developmental version from 133 | [GitHub](https://github.com/poissonconsulting/tinter) 134 | 135 | ``` r 136 | # install.packages("remotes") 137 | remotes::install_github("poissonconsulting/tinter") 138 | ``` 139 | 140 | ## Contribution 141 | 142 | Please report any 143 | [issues](https://github.com/poissonconsulting/tinter/issues). 144 | 145 | [Pull requests](https://github.com/poissonconsulting/tinter/pulls) are 146 | always welcome. 147 | 148 | Please note that the tinter project is released with a [Contributor Code 149 | of 150 | Conduct](https://contributor-covenant.org/version/2/0/CODE_OF_CONDUCT.html). 151 | By contributing to this project, you agree to abide by its terms. 152 | -------------------------------------------------------------------------------- /_pkgdown.yml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebdalgarno/tinter/21ff64202eb15c06db5d9b0a2e5d676a0c386fa6/_pkgdown.yml -------------------------------------------------------------------------------- /codecov.yml: -------------------------------------------------------------------------------- 1 | comment: false 2 | 3 | coverage: 4 | status: 5 | project: 6 | default: 7 | target: auto 8 | threshold: 1% 9 | informational: true 10 | patch: 11 | default: 12 | target: auto 13 | threshold: 1% 14 | informational: true 15 | -------------------------------------------------------------------------------- /cran-comments.md: -------------------------------------------------------------------------------- 1 | * This is a resubmission of an archived package addressing this problem: "Apparently your package no longer works correctly when class(matrix(...)) gives a vector of length two and conditions of length greater than one in 'if' or 'while' give an error: please fix as necessary." The package was removed from CRAN but now has been fixed. 2 | 3 | ## Test environments 4 | * local OS X install, R 3.5.1 5 | * ubuntu 14.04 (on travis-ci), R 3.5.1 6 | * win-builder (devel and release) 7 | 8 | ## R CMD check results 9 | 10 | 0 errors | 0 warnings | 1 note 11 | 12 | Note for new submission of archived package 13 | 14 | -------------------------------------------------------------------------------- /man/chk_color.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/chk.R 3 | \name{chk_color} 4 | \alias{chk_color} 5 | \alias{chk_colour} 6 | \title{Check Color String} 7 | \usage{ 8 | chk_color(x, x_name = NULL) 9 | 10 | chk_colour(x, x_name = NULL) 11 | } 12 | \arguments{ 13 | \item{x}{The object to check.} 14 | 15 | \item{x_name}{A string of the name of object x or NULL.} 16 | } 17 | \value{ 18 | \code{NULL}, invisibly. Called for the side effect of throwing an error 19 | if the condition is not met. 20 | } 21 | \description{ 22 | Checks that x is a string (non-missing character vector of length 1) 23 | that specifies a color. 24 | 25 | \code{chk_color} 26 | checks if a color string. 27 | 28 | \code{chk_colour} 29 | checks if a color string. 30 | } 31 | \section{Functions}{ 32 | \itemize{ 33 | \item \code{chk_color}: Check Color String Object 34 | 35 | \item \code{chk_colour}: Check Color String Object 36 | }} 37 | 38 | \examples{ 39 | 40 | # chk_color 41 | chk_color("blue") 42 | try(chk_color("glue")) 43 | 44 | # chk_colour 45 | chk_colour("blue") 46 | try(chk_colour("glue")) 47 | } 48 | \seealso{ 49 | \code{\link[=vld_color]{vld_color()}} 50 | } 51 | -------------------------------------------------------------------------------- /man/darken.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/tinter.R 3 | \name{darken} 4 | \alias{darken} 5 | \title{Darken colour.} 6 | \usage{ 7 | darken(x, amount) 8 | } 9 | \arguments{ 10 | \item{x}{A vector of strings of colours in any format accepted by grDevices::col2rgb().} 11 | 12 | \item{amount}{A number from 0 to 1.} 13 | } 14 | \value{ 15 | A vector of modified colours. 16 | } 17 | \description{ 18 | Darken colour. 19 | } 20 | \examples{ 21 | darken(tinter("blue"), 0.2) 22 | } 23 | -------------------------------------------------------------------------------- /man/figures/README-colour-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebdalgarno/tinter/21ff64202eb15c06db5d9b0a2e5d676a0c386fa6/man/figures/README-colour-1.png -------------------------------------------------------------------------------- /man/figures/README-crop-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebdalgarno/tinter/21ff64202eb15c06db5d9b0a2e5d676a0c386fa6/man/figures/README-crop-1.png -------------------------------------------------------------------------------- /man/figures/README-darken-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebdalgarno/tinter/21ff64202eb15c06db5d9b0a2e5d676a0c386fa6/man/figures/README-darken-1.png -------------------------------------------------------------------------------- /man/figures/README-plot-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebdalgarno/tinter/21ff64202eb15c06db5d9b0a2e5d676a0c386fa6/man/figures/README-plot-1.png -------------------------------------------------------------------------------- /man/figures/README-steps-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebdalgarno/tinter/21ff64202eb15c06db5d9b0a2e5d676a0c386fa6/man/figures/README-steps-1.png -------------------------------------------------------------------------------- /man/figures/README-tinter-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebdalgarno/tinter/21ff64202eb15c06db5d9b0a2e5d676a0c386fa6/man/figures/README-tinter-1.png -------------------------------------------------------------------------------- /man/figures/README-tints-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebdalgarno/tinter/21ff64202eb15c06db5d9b0a2e5d676a0c386fa6/man/figures/README-tints-1.png -------------------------------------------------------------------------------- /man/figures/colour-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebdalgarno/tinter/21ff64202eb15c06db5d9b0a2e5d676a0c386fa6/man/figures/colour-1.png -------------------------------------------------------------------------------- /man/figures/crop-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebdalgarno/tinter/21ff64202eb15c06db5d9b0a2e5d676a0c386fa6/man/figures/crop-1.png -------------------------------------------------------------------------------- /man/figures/darken-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebdalgarno/tinter/21ff64202eb15c06db5d9b0a2e5d676a0c386fa6/man/figures/darken-1.png -------------------------------------------------------------------------------- /man/figures/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebdalgarno/tinter/21ff64202eb15c06db5d9b0a2e5d676a0c386fa6/man/figures/logo.png -------------------------------------------------------------------------------- /man/figures/plot-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebdalgarno/tinter/21ff64202eb15c06db5d9b0a2e5d676a0c386fa6/man/figures/plot-1.png -------------------------------------------------------------------------------- /man/figures/steps-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebdalgarno/tinter/21ff64202eb15c06db5d9b0a2e5d676a0c386fa6/man/figures/steps-1.png -------------------------------------------------------------------------------- /man/figures/tinter-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebdalgarno/tinter/21ff64202eb15c06db5d9b0a2e5d676a0c386fa6/man/figures/tinter-1.png -------------------------------------------------------------------------------- /man/figures/tints-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebdalgarno/tinter/21ff64202eb15c06db5d9b0a2e5d676a0c386fa6/man/figures/tints-1.png -------------------------------------------------------------------------------- /man/lighten.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/tinter.R 3 | \name{lighten} 4 | \alias{lighten} 5 | \title{Lighten colour.} 6 | \usage{ 7 | lighten(x, amount) 8 | } 9 | \arguments{ 10 | \item{x}{A vector of strings of colours in any format accepted by grDevices::col2rgb().} 11 | 12 | \item{amount}{A number from 0 to 1.} 13 | } 14 | \value{ 15 | A vector of modified colours. 16 | } 17 | \description{ 18 | Lighten colour. 19 | } 20 | \examples{ 21 | lighten(tinter("blue"), 0.2) 22 | } 23 | -------------------------------------------------------------------------------- /man/tinter.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/tinter.R 3 | \name{tinter} 4 | \alias{tinter} 5 | \title{Generate shades, tints or both from a colour.} 6 | \usage{ 7 | tinter(x, steps = 5, crop = 1, direction = "both", adjust = 0) 8 | } 9 | \arguments{ 10 | \item{x}{A string of a colour in any format accepted by grDevices::col2rgb().} 11 | 12 | \item{steps}{An integer indicating how many shades/tints to generate (excluding x).} 13 | 14 | \item{crop}{An integer indicating how many extreme colours to remove (e.g. crop = 1 eliminates 'black' and 'white').} 15 | 16 | \item{direction}{A string indicating whether to include 'tints', 'shades' or 'both'.} 17 | 18 | \item{adjust}{A number between -1 and 1. Values between 0 and -1 increasingly darken colour; values between 0 and 1 increasingly lighten colour.} 19 | } 20 | \value{ 21 | A vector of colours. 22 | } 23 | \description{ 24 | Generate shades, tints or both from a colour. 25 | } 26 | \examples{ 27 | tinter("blue") 28 | tinter("#fa6a5c", steps = 10, crop = 3) 29 | tinter("#fa6a5c", direction = "tints") 30 | } 31 | -------------------------------------------------------------------------------- /man/vld_color.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/vld.R 3 | \name{vld_color} 4 | \alias{vld_color} 5 | \alias{vld_colour} 6 | \title{Validate Color String} 7 | \usage{ 8 | vld_color(x) 9 | 10 | vld_colour(x) 11 | } 12 | \arguments{ 13 | \item{x}{The object to check.} 14 | } 15 | \value{ 16 | A flag indicating whether the object was validated. 17 | } 18 | \description{ 19 | Validates whether x is a string (non-missing character vector of length 1) 20 | that specifies a color. 21 | } 22 | \section{Functions}{ 23 | \itemize{ 24 | \item \code{vld_color}: Validate Color String 25 | 26 | \item \code{vld_colour}: Validate Colour String 27 | }} 28 | 29 | \examples{ 30 | 31 | # vld_color 32 | vld_color("blue") 33 | vld_color("glue") 34 | 35 | # vld_color 36 | vld_colour("blue") 37 | vld_colour("glue") 38 | } 39 | \seealso{ 40 | \code{\link[=chk_color]{chk_color()}} 41 | } 42 | -------------------------------------------------------------------------------- /pkgdown/favicon/apple-touch-icon-120x120.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebdalgarno/tinter/21ff64202eb15c06db5d9b0a2e5d676a0c386fa6/pkgdown/favicon/apple-touch-icon-120x120.png -------------------------------------------------------------------------------- /pkgdown/favicon/apple-touch-icon-152x152.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebdalgarno/tinter/21ff64202eb15c06db5d9b0a2e5d676a0c386fa6/pkgdown/favicon/apple-touch-icon-152x152.png -------------------------------------------------------------------------------- /pkgdown/favicon/apple-touch-icon-180x180.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebdalgarno/tinter/21ff64202eb15c06db5d9b0a2e5d676a0c386fa6/pkgdown/favicon/apple-touch-icon-180x180.png -------------------------------------------------------------------------------- /pkgdown/favicon/apple-touch-icon-60x60.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebdalgarno/tinter/21ff64202eb15c06db5d9b0a2e5d676a0c386fa6/pkgdown/favicon/apple-touch-icon-60x60.png -------------------------------------------------------------------------------- /pkgdown/favicon/apple-touch-icon-76x76.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebdalgarno/tinter/21ff64202eb15c06db5d9b0a2e5d676a0c386fa6/pkgdown/favicon/apple-touch-icon-76x76.png -------------------------------------------------------------------------------- /pkgdown/favicon/apple-touch-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebdalgarno/tinter/21ff64202eb15c06db5d9b0a2e5d676a0c386fa6/pkgdown/favicon/apple-touch-icon.png -------------------------------------------------------------------------------- /pkgdown/favicon/favicon-16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebdalgarno/tinter/21ff64202eb15c06db5d9b0a2e5d676a0c386fa6/pkgdown/favicon/favicon-16x16.png -------------------------------------------------------------------------------- /pkgdown/favicon/favicon-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebdalgarno/tinter/21ff64202eb15c06db5d9b0a2e5d676a0c386fa6/pkgdown/favicon/favicon-32x32.png -------------------------------------------------------------------------------- /pkgdown/favicon/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebdalgarno/tinter/21ff64202eb15c06db5d9b0a2e5d676a0c386fa6/pkgdown/favicon/favicon.ico -------------------------------------------------------------------------------- /scripts/build.R: -------------------------------------------------------------------------------- 1 | roxygen2md::roxygen2md() 2 | styler::style_pkg(filetype = c("R", "Rmd")) 3 | lintr::lint_package() 4 | 5 | devtools::test() 6 | devtools::document() 7 | 8 | rmarkdown::render("README.Rmd", output_format = "md_document") 9 | pkgdown::build_site() 10 | 11 | devtools::check() 12 | -------------------------------------------------------------------------------- /scripts/hex.R: -------------------------------------------------------------------------------- 1 | library(hexSticker) 2 | library(sf) 3 | library(ggplot2) 4 | library(dplyr) 5 | library(showtext) 6 | 7 | font_add_google("Montserrat", "montserrat") 8 | showtext_auto() 9 | 10 | hexd <- data.frame(x = 1 + c(rep(-sqrt(3)/2, 2), 0, rep(sqrt(3)/2,2), 0), y = 1 + c(0.5, -0.5, -1, -0.5, 0.5, 1)) 11 | hexd <- rbind(hexd, hexd[1, ]) 12 | hexd$id <- 1 13 | 14 | # create polygon 15 | hex_sf <- st_as_sf(hexd, coords = c("x", "y")) %>% 16 | group_by(id) %>% 17 | summarise(do_union = FALSE) %>% 18 | st_cast("LINESTRING") %>% 19 | st_cast("POLYGON") 20 | 21 | buffers <- seq(-0.05, -0.85, -0.15) 22 | hexes <- do.call("rbind", lapply(buffers, function(x){ 23 | st_buffer(hex_sf, x) %>% 24 | mutate(id = x) 25 | })) 26 | 27 | hex_tint <- "#335CAC" 28 | hex_text <- "#263e51" 29 | hex_outline <- "#263e51" 30 | family <- "montserrat" 31 | pal <- tinter::tinter(hex_tint, steps = length(buffers) - 1, crop = 0, direction = "tints") 32 | rev(tinter::tinter(hex_tint, steps = length(buffers) - 1, crop = 0, direction = "tints")) %>% shades::swatch() 33 | pal2 <- pal %>% tinter::lighten(amount = 0.1) 34 | # create more polygons 35 | gp <- ggplot() + 36 | geom_sf(data = hexes[1,], color = hex_outline, size = 7) + 37 | geom_sf(data = hexes[-nrow(hexes),], aes(fill = id), alpha = 1, color = "transparent", size = 0.01) + 38 | scale_fill_gradientn(colours = pal) + 39 | geom_text(aes(x = 1, y = 1, label = "tinter"), size = 40, colour = hex_text, family = family) + 40 | geom_url(url = "github.com/poissonconsulting/tinter", family = family, size = 3, vjust = 0.1, color = hex_text) + 41 | theme_transparent() + 42 | theme(plot.margin = margin(b = -0.2, l = -0.2, unit = "lines"), 43 | strip.text = element_blank(), 44 | line = element_blank(), 45 | text = element_blank(), 46 | title = element_blank(), 47 | legend.position = "none", 48 | plot.background = element_blank() 49 | ) + 50 | coord_sf(datum = NA) 51 | gp 52 | ggsave(plot = gp, filename = "man/figures/logo.png", device = "png") 53 | 54 | -------------------------------------------------------------------------------- /tests/testthat.R: -------------------------------------------------------------------------------- 1 | library(testthat) 2 | library(tinter) 3 | 4 | test_check("tinter") 5 | -------------------------------------------------------------------------------- /tests/testthat/test-chk.R: -------------------------------------------------------------------------------- 1 | test_that("chk_color", { 2 | expect_null(chk_color("green")) 3 | expect_invisible(chk_color("green")) 4 | chk::expect_chk_error(chk_color(1)) 5 | }) 6 | 7 | test_that("chk_colour", { 8 | expect_null(chk_colour("green")) 9 | expect_invisible(chk_colour("green")) 10 | chk::expect_chk_error(chk_colour(1)) 11 | }) 12 | -------------------------------------------------------------------------------- /tests/testthat/test-utils.R: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /tests/testthat/test-vld.R: -------------------------------------------------------------------------------- 1 | test_that("vld_color", { 2 | expect_true(vld_color("blue")) 3 | expect_false(vld_color(1)) 4 | expect_false(vld_color(character(0))) 5 | expect_false(vld_color(NA_character_)) 6 | expect_false(vld_color(c("blue", "green"))) 7 | expect_false(vld_color("glue")) 8 | }) 9 | 10 | test_that("vld_colour", { 11 | expect_true(vld_colour("blue")) 12 | expect_false(vld_colour(1)) 13 | expect_false(vld_colour(character(0))) 14 | expect_false(vld_colour(NA_character_)) 15 | expect_false(vld_colour(c("blue", "green"))) 16 | expect_false(vld_colour("glue")) 17 | }) 18 | -------------------------------------------------------------------------------- /tests/testthat/test-zzz-package.R: -------------------------------------------------------------------------------- 1 | context("tinter") 2 | 3 | test_that("package", { 4 | expect_length(tinter("blue", 10, 1, adjust = 0.2), 19) 5 | expect_length(tinter("blue", 10, 1, "shades", adjust = 0.1), 10) 6 | expect_length(tinter("blue", 10, 1, "tints", adjust = 0.2), 10) 7 | 8 | expect_true("#1381C2" %in% tinter("#1381c2")) 9 | expect_false("#1381C2" %in% tinter("#1381c2", adjust = 0.1)) 10 | expect_false("#1381C2" %in% tinter("#1381c2", adjust = 0.1)) 11 | 12 | 13 | expect_true("#1381C2" %in% tinter("#1381c2", direction = "shades")) 14 | expect_true("#1381C2" %in% tinter("#1381c2", direction = "tints")) 15 | 16 | expect_true("#FFFFFF" %in% tinter("#1381c2", crop = 0)) 17 | expect_true("#000000" %in% tinter("#1381c2", crop = 0)) 18 | 19 | expect_is(tinter("blue"), "character") 20 | 21 | expect_length(darken(tinter("blue"), amount = 0.1), 9L) 22 | expect_length(lighten(tinter("blue"), amount = 0.1), 9L) 23 | }) 24 | -------------------------------------------------------------------------------- /tinter.Rproj: -------------------------------------------------------------------------------- 1 | Version: 1.0 2 | 3 | RestoreWorkspace: No 4 | SaveWorkspace: No 5 | AlwaysSaveHistory: Default 6 | 7 | EnableCodeIndexing: Yes 8 | UseSpacesForTab: Yes 9 | NumSpacesForTab: 2 10 | Encoding: UTF-8 11 | 12 | RnwWeave: Sweave 13 | LaTeX: pdfLaTeX 14 | 15 | AutoAppendNewline: Yes 16 | StripTrailingWhitespace: Yes 17 | 18 | BuildType: Package 19 | PackageUseDevtools: Yes 20 | PackageInstallArgs: --no-multiarch --with-keep.source 21 | PackageRoxygenize: rd,collate,namespace 22 | --------------------------------------------------------------------------------