{"id":16476991,"url":"https://github.com/agilgur5/trim-canvas","last_synced_at":"2025-05-08T21:17:59.147Z","repository":{"id":57379920,"uuid":"67160452","full_name":"agilgur5/trim-canvas","owner":"agilgur5","description":"A tiny (\u003c 100 LoC) library for trimming whitespace from a canvas element with no dependencies","archived":false,"fork":false,"pushed_at":"2019-12-08T19:23:17.000Z","size":23,"stargazers_count":71,"open_issues_count":4,"forks_count":5,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-05-08T21:17:50.699Z","etag":null,"topics":["blanks","canvas","remove","signature","trim","whitespace"],"latest_commit_sha":null,"homepage":"https://agilgur5.github.io/react-signature-canvas/","language":"JavaScript","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/agilgur5.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-09-01T19:33:53.000Z","updated_at":"2025-03-15T06:20:23.000Z","dependencies_parsed_at":"2022-09-02T20:22:12.970Z","dependency_job_id":null,"html_url":"https://github.com/agilgur5/trim-canvas","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agilgur5%2Ftrim-canvas","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agilgur5%2Ftrim-canvas/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agilgur5%2Ftrim-canvas/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/agilgur5%2Ftrim-canvas/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/agilgur5","download_url":"https://codeload.github.com/agilgur5/trim-canvas/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253149622,"owners_count":21861740,"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","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":["blanks","canvas","remove","signature","trim","whitespace"],"created_at":"2024-10-11T12:44:11.824Z","updated_at":"2025-05-08T21:17:59.081Z","avatar_url":"https://github.com/agilgur5.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# trim-canvas\n\n\u003c!-- releases / versioning --\u003e\n[![package-json](https://img.shields.io/github/package-json/v/agilgur5/trim-canvas.svg)](https://npmjs.org/package/trim-canvas)\n[![releases](https://img.shields.io/github/release/agilgur5/trim-canvas.svg)](https://github.com/agilgur5/trim-canvas/releases)\n[![commits](https://img.shields.io/github/commits-since/agilgur5/trim-canvas/latest.svg)](https://github.com/agilgur5/trim-canvas/commits/master)\n\u003cbr\u003e\u003c!-- downloads --\u003e\n[![dt](https://img.shields.io/npm/dt/trim-canvas.svg)](https://npmjs.org/package/trim-canvas)\n[![dy](https://img.shields.io/npm/dy/trim-canvas.svg)](https://npmjs.org/package/trim-canvas)\n[![dm](https://img.shields.io/npm/dm/trim-canvas.svg)](https://npmjs.org/package/trim-canvas)\n[![dw](https://img.shields.io/npm/dw/trim-canvas.svg)](https://npmjs.org/package/trim-canvas)\n\u003cbr\u003e\u003c!-- status / activity --\u003e\n[![build status](https://img.shields.io/travis/agilgur5/trim-canvas/master.svg)](https://travis-ci.org/agilgur5/trim-canvas)\n[![code coverage](https://img.shields.io/codecov/c/gh/agilgur5/trim-canvas/master.svg)](https://codecov.io/gh/agilgur5/trim-canvas)\n\u003cbr\u003e\n[![NPM](https://nodei.co/npm/trim-canvas.png?downloads=true\u0026downloadRank=true\u0026stars=true)](https://npmjs.org/package/trim-canvas)\n\nA tiny (\u003c 100 LoC) library for trimming whitespace from a `canvas` element with no dependencies.\n\n## Installation\n\n`npm i -S trim-canvas`\n\n## Usage\n\n```javascript\nimport trimCanvas from 'trim-canvas'\n\nconst canvas = document.createElement('canvas')\n\n// do some drawing on it ...\n\ntrimCanvas(canvas)\n// now the whitespace has been trimmed\n```\n\nIf you don't want to mess with your existing canvas, then simply clone the canvas element beforehand.\n\n`trim-canvas` returns the canvas element for easy chaining.\n\n## Example\n\nCan see how `trim-canvas` is used inside of `react-signature-canvas` [here](https://github.com/agilgur5/react-signature-canvas/blob/310bff81813509a4035bedfe50d76e7045a880cb/src/index.js#L53-L64).\nIt includes a step for cloning the canvas.\n\n## Demo\n\nYou can see a demo of `trim-canvas` [here](https://agilgur5.github.io/react-signature-canvas/).\n\n\u003csmall\u003e*(N.B. this is the demo for [`react-signature-canvas`](https://github.com/agilgur5/react-signature-canvas) which depends on `trim-canvas`)*\u003c/small\u003e\n\n## Credits\n\nCredits go to [@efc](https://github.com/efc) for writing a quick version of this in [this issue](https://github.com/szimek/signature_pad/issues/49#issue-29108215) and to the original [StackOverflow Answer](http://stackoverflow.com/a/12178531/3431180) that was credited in that issue.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fagilgur5%2Ftrim-canvas","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fagilgur5%2Ftrim-canvas","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fagilgur5%2Ftrim-canvas/lists"}