CanvasFilters: Difference between revisions

From MozillaWiki
Jump to navigation Jump to search
(first steps)
m (typo)
Line 36: Line 36:


  context . filter [ = value ]
  context . filter [ = value ]
 
     Returns the current filter.
     Returns the current filter.
     Can be set, to change the filter. Values that cannot be parsed are ignored.
     Can be set, to change the filter. Values that cannot be parsed are ignored.
Line 46: Line 46:
On setting, if the new value is "none", filters must be disabled for the context. Otherwise, the value must be parsed as a CSS <filter-function-list> value. If the value cannot be parsed as a CSS <filter-function-list> value then it must be ignored, and the attribute must retain its previous value. [filter-effects]
On setting, if the new value is "none", filters must be disabled for the context. Otherwise, the value must be parsed as a CSS <filter-function-list> value. If the value cannot be parsed as a CSS <filter-function-list> value then it must be ignored, and the attribute must retain its previous value. [filter-effects]


Coordinates in filters are interpreted as 1 px = 1 SVG user space unit = 1 canvas coordinate space unit. Filters coordinates are not affected by the current transformation matrix. The current transformation matrix only affects the input to the filter, filters are applied in device space (XXX "device space" is apparently not defined on https://html.spec.whatwg.org/multipage/scripting.html , how should we say this?).
Coordinates in filters are interpreted as 1px = 1 SVG user space unit = 1 canvas coordinate space unit. Filter coordinates are not affected by the current transformation matrix. The current transformation matrix only affects the input to the filter, filters are applied in device space (XXX "device space" is apparently not defined on https://html.spec.whatwg.org/multipage/scripting.html , how should we say this?).


...
...

Revision as of 21:51, 15 June 2015

This article is a stub. You can help MozillaWiki by expanding it.

Canvas Filters is a specification for a filter attribute that takes a list of filter operations similar to the CSS Image filter function.

Editor
Tantek Çelik (acting to get this started, until hand-off to dev/test)

Per CC0, to the extent possible under law, the editors have waived all copyright and related or neighboring rights to this work. In addition, as of 2026-01-04, the editors have made this specification available under the Open Web Foundation Agreement Version 1.0.

Background:

Bugs:

Raw Beginnings of spec text, please improve

IDL addition:

[Constructor(),
 Constructor(unsigned long width, unsigned long height),
 Exposed=(Window,Worker)]
interface CanvasRenderingContext2D {
  // ...

  // filter
  attribute DOMString filter; // (default "none")
}

The value of the filter property is part of the canvas drawing state.

4.12.4.2.19 Filters

All drawing operations are affected by the global filter attribute.

context . filter [ = value ]

   Returns the current filter.
   Can be set, to change the filter. Values that cannot be parsed are ignored.

When the context is created, the filter attribute initially must be set to "none".

On getting, must return the value that it was last successfully set to. The value must not be re-serialized.

On setting, if the new value is "none", filters must be disabled for the context. Otherwise, the value must be parsed as a CSS <filter-function-list> value. If the value cannot be parsed as a CSS <filter-function-list> value then it must be ignored, and the attribute must retain its previous value. [filter-effects]

Coordinates in filters are interpreted as 1px = 1 SVG user space unit = 1 canvas coordinate space unit. Filter coordinates are not affected by the current transformation matrix. The current transformation matrix only affects the input to the filter, filters are applied in device space (XXX "device space" is apparently not defined on https://html.spec.whatwg.org/multipage/scripting.html , how should we say this?).

...

Maybe the shadow drawing algorithm should mention in step 1 that the "source image for which a shadow is being created" is already the output of the filter, if a filter is set.

See Also