MCPcopy Index your code
hub / github.com/darkreader/darkreader / createFilterMatrix

Function createFilterMatrix

src/generators/utils/matrix.ts:6–24  ·  view source on GitHub ↗
(config: Theme)

Source from the content-addressed store, hash-verified

4
5
6export function createFilterMatrix(config: Theme): Matrix5x5 {
7 let m: Matrix5x5 = Matrix.identity();
8 if (config.sepia !== 0) {
9 m = multiplyMatrices(m, Matrix.sepia(config.sepia / 100));
10 }
11 if (config.grayscale !== 0) {
12 m = multiplyMatrices(m, Matrix.grayscale(config.grayscale / 100));
13 }
14 if (config.contrast !== 100) {
15 m = multiplyMatrices(m, Matrix.contrast(config.contrast / 100));
16 }
17 if (config.brightness !== 100) {
18 m = multiplyMatrices(m, Matrix.brightness(config.brightness / 100));
19 }
20 if (config.mode === 1) {
21 m = multiplyMatrices(m, Matrix.invertNHue());
22 }
23 return m;
24}
25
26export function applyColorMatrix([r, g, b]: [number, number, number], matrix: Matrix5x5): [number, number, number] {
27 const rgb: Matrix5x1 = [[r / 255], [g / 255], [b / 255], [1], [1]];

Callers 4

modifyColorWithCacheFunction · 0.90
createStaticStylesheetFunction · 0.90
getSVGFilterMatrixValueFunction · 0.90

Calls 1

multiplyMatricesFunction · 0.90

Tested by

no test coverage detected