| 51 | protected readonly includeOpacity: boolean |
| 52 | |
| 53 | constructor( |
| 54 | document: Document, |
| 55 | node: HTMLElement, |
| 56 | captureTextNodes?: boolean |
| 57 | ) { |
| 58 | super(document, node, captureTextNodes) |
| 59 | |
| 60 | let matrix = toNumbers(this.getAttribute('values').getString()) |
| 61 | |
| 62 | switch (this.getAttribute('type').getString('matrix')) { // http://www.w3.org/TR/SVG/filters.html#feColorMatrixElement |
| 63 | case 'saturate': { |
| 64 | const s = matrix[0] |
| 65 | |
| 66 | /* eslint-disable array-element-newline */ |
| 67 | matrix = [ |
| 68 | 0.213 + 0.787 * s, 0.715 - 0.715 * s, 0.072 - 0.072 * s, 0, 0, |
| 69 | 0.213 - 0.213 * s, 0.715 + 0.285 * s, 0.072 - 0.072 * s, 0, 0, |
| 70 | 0.213 - 0.213 * s, 0.715 - 0.715 * s, 0.072 + 0.928 * s, 0, 0, |
| 71 | 0, 0, 0, 1, 0, |
| 72 | 0, 0, 0, 0, 1 |
| 73 | ] |
| 74 | /* eslint-enable array-element-newline */ |
| 75 | break |
| 76 | } |
| 77 | |
| 78 | case 'hueRotate': { |
| 79 | const a = matrix[0] * Math.PI / 180.0 |
| 80 | |
| 81 | /* eslint-disable array-element-newline */ |
| 82 | matrix = [ |
| 83 | c(a, 0.213, 0.787, -0.213), c(a, 0.715, -0.715, -0.715), c(a, 0.072, -0.072, 0.928), 0, 0, |
| 84 | c(a, 0.213, -0.213, 0.143), c(a, 0.715, 0.285, 0.140), c(a, 0.072, -0.072, -0.283), 0, 0, |
| 85 | c(a, 0.213, -0.213, -0.787), c(a, 0.715, -0.715, 0.715), c(a, 0.072, 0.928, 0.072), 0, 0, |
| 86 | 0, 0, 0, 1, 0, |
| 87 | 0, 0, 0, 0, 1 |
| 88 | ] |
| 89 | /* eslint-enable array-element-newline */ |
| 90 | break |
| 91 | } |
| 92 | |
| 93 | case 'luminanceToAlpha': |
| 94 | /* eslint-disable array-element-newline */ |
| 95 | matrix = [ |
| 96 | 0, 0, 0, 0, 0, |
| 97 | 0, 0, 0, 0, 0, |
| 98 | 0, 0, 0, 0, 0, |
| 99 | 0.2125, 0.7154, 0.0721, 0, 0, |
| 100 | 0, 0, 0, 0, 1 |
| 101 | ] |
| 102 | /* eslint-enable array-element-newline */ |
| 103 | break |
| 104 | |
| 105 | default: |
| 106 | } |
| 107 | |
| 108 | this.matrix = matrix |
| 109 | this.includeOpacity = this.getAttribute('includeOpacity').hasValue() |
| 110 | } |