Re: [fxtf-drafts] [filter-effects-2] Add recolor() shorthand (#334)

Based on the preceding comments, can I suggest something along the following lines (I'm not an experienced spec writer - so please treat with appropriate patience/forebearance)

Using   as the base document:

add to Section 6.1

recolor() = recolor( colorA, colorB, colorC )

Applies a monotone, duotone or tritone effect on the input image based on the number of input colors. The monotone effect discards the input image's color channels replacing them with ColorA. The duotone and tritone effects map the luminosity of the input image to new range(s) in each color channel based on the red, green and blue values specified in colorA and colorB (and colorC if present). The markup equivalent of this function is given below.

Default value when omitted is opaque black
The initial value for interpolation is opaque black.

And added to Section 13.1.11

recolor(colorA) [where colorA-r is the unitized value of the red color channel etc.]

<filter id="recolor1">
  <feColorMatrix type="matrix"
             values="0 0 0 0 colorA-r
                           0 0 0 0 colorA-g
                           0 0 0 0 colorA-b
                           0 0 0 1 0"/>

recolor(colorA, colorB [, colorC])
<filter id="recolor">
  <feColorMatrix type="matrix"
             values="0.2126  0.7152 0.0722  0 0 
                          0.2126  0.7152 0.0722  0 0 
                          0.2126  0.7152 0.0722  0 0 
                          0 0 0 1 0"/>
    <feFuncR type="table" tableValues="colorA-r colorB-r [colorC-r]"/>
    <feFuncG type="table" tableValues="colorA-g colorB-g [colorC-r]"/>
    <feFuncB type="table" tableValues="colorA-b colorB-b [colorC-r]"/>

We could express all of this using feComponentTransfer - but since feColorMatrix has been made very fast in existing browsers and feComponentTransfer is generally quite slow - I'm hoping that the single color case can be supported with high performance with minimal work. This might be a misunderstanding of how the implementors approach spec implementation - but I thought I'd suggest it. 

As this stands, this preserves the alpha channel of the input image. There may be cases where people want to adjust the alpha channel or apply a % effect -  is it ok not to expose these capabilities in a shorthand (vs making users write a SVG filter.)

GitHub Notification of comment by gitmullany
Please view or discuss this issue at using your GitHub account

Received on Tuesday, 14 May 2019 00:57:50 UTC