agilgur5 / agilgur5/trim-canvas

Support for other colors?

未關閉
#4 1 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
backlog feature
主要語言
JavaScript
星號
74
分支
5
PR 合併指標
30 天內沒有已合併 PR

描述

Potential downstream request from https://github.com/agilgur5/react-signature-canvas/issues/22

The `trimCanvas` function would have to accept a second argument for the color and default to transparency detection. Since this hasn't really come up in 2 years and there are alternative ways to achieve the behavior wanted in that issue, I'm not sure that it's worth the added complexity, but I'll document my thoughts here.

In order to be backwards-compatible, the second argument would have to be able to accept wildcards, since right now the function only checks the RGBA `alpha` transparency if it's not 0 and doesn't even check any of the other RGB parts.

The backwards-compatible wildcard requirement also means one couldn't necessarily just use [`color-rgba`](https://github.com/colorjs/color-rgba) to parse the second argument, unless the default behavior was just kept as different from the arg behavior (as there is no color equivalent to the current check of `rgba(*,*,*,0)`).

`color-rgba` is also [much larger](https://bundlephobia.com/result?p=color-rgba@2.1.0) than this library so that would make an extremely significant size increase, clashing with the existing image of "tiny (< 100 LoC)". Could accept only `'rgba(r,g,b,a)'` strings and do some manual parsing instead, but that wouldn't entirely fulfill the downstream issue as there `backgroundColor` accepts other types of color strings :/ . That would therefore either be incomplete or end up pushing the dependency downstream.

貢獻指南

這個儲存庫沒有索引到貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。