W3C home > Mailing lists > Public > public-fxtf-archive@w3.org > May 2017

[fxtf-drafts] Allow nesting filters instead of using 'in', 'in2' and 'result' attributes

From: Sebastian Zartner via GitHub <sysbot+gh@w3.org>
Date: Mon, 15 May 2017 10:31:10 +0000
To: public-fxtf-archive@w3.org
Message-ID: <issues.opened-228671929-1494844269-sysbot+gh@w3.org>
SebastianZ has just created a new issue for https://github.com/w3c/fxtf-drafts:

== Allow nesting filters instead of using 'in', 'in2' and 'result' attributes ==
Copying this over from https://github.com/w3c/svgwg/issues/258 to continue the discussion in the right repo and to get some more eyes on the proposal.

Filter elements currently use the `in` and `in2` attributes to specify their inputs and `result` for their output, which is somewhat hard to read, especially when the elements are in a different order than their inputs.

Furthermore, the `<feMerge>` element already has `<feMergeNode>` subelements, which makes it inconsistent to the other filter elements.

To improve readability and make the different filter elements consistent it should be possible to nest the different filters to define the inputs similar to how it was mentioned in https://github.com/w3c/svgwg/issues/257#issuecomment-245678506.
That means, the children and their order define which is the first input and which the second.

**Example:**
Instead of

``` svg
<filter id="example">
  <feGaussianBlur stdDeviation="4" in="SourceAlpha" result="blur" />
  <feOffset result="offset" in="blur" dy="5" dx="5" />
  <feTurbulence numOctaves="1" baseFrequency="0.05" result="turbulence" in="SourceGraphic" />
  <feComposite result="composite" operator="in" in2="offset" in="turbulence" />
  <feComposite operator="xor" in="SourceGraphic" in2="composite" />
</filter>
```

you could then write

``` svg
<filter id="example">
  <feComposite operator="xor" in="SourceGraphic">
    <feComposite operator="in">
      <feTurbulence numOctaves="1" baseFrequency="0.05" in="SourceGraphic" />
      <feOffset result="offset" dy="5" dx="5">
        <feGaussianBlur stdDeviation="4" in="SourceAlpha" />
      </feOffset>
    </feComposite>
  </feComposite>
</filter>
```

For backwards compatibility, branching and re-joining and to keep the support for the different input types, the `in` and `in2` attributes including their keywords would be kept.

If it's wished to stay consistent, the keywords need to be made available as elements as well, which would then look like this:

``` svg
<filter id="example">
  <feComposite operator="xor">
    <sourcegraphic />
    <feComposite operator="in">
      <feTurbulence numOctaves="1" baseFrequency="0.05">
        <sourcegraphic />
      </feTurbulence>
      <feOffset result="offset" dy="5" dx="5">
        <feGaussianBlur stdDeviation="4">
          <sourcealpha />
        </feGaussianBlur>
      </feOffset>
    </feComposite>
  </feComposite>
</filter>
```

@AmeliaBR [commented](https://github.com/w3c/svgwg/issues/258#issuecomment-245974823) that the suggested syntax may not be much more readable, either and that it's not obvious how many children are allowed for the different filters.

Sebastian


Please view or discuss this issue at https://github.com/w3c/fxtf-drafts/issues/160 using your GitHub account
Received on Monday, 15 May 2017 10:31:17 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 20 November 2018 00:45:58 UTC