Changes between Initial Version and Version 11 of Ticket #13928


Ignore:
Timestamp:
Mar 8, 2013, 6:37:24 PM (8 years ago)
Author:
Patrick Ruzand
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #13928

    • Property Status changed from new to assigned
    • Property Keywords 1.9 added
    • Property Milestone changed from tbd to 1.9
    • Property Owner changed from eugene to Patrick Ruzand
    • Property Type changed from defect to enhancement
    • Property Blocking changed from to 14357
  • Ticket #13928 – Description

    initial v11  
     1This patch adds support for the SVG Filter API in the gfx SVG renderer only, by:
     2   * adding a new Shape.setFilter() method
     3   * providing a minimal helper api to create filters conform to the spec
     4   * providing a set of 52 predefined filters grouped by category (blurs, shadows, colors, textures, convolutions, miscs and reliefs)
     5
     61/ The Shape.setFilter() API is implemented in the dojox/gfx/svgext module, since it's a SVG-specific api.
     7
     8The raw implementation of a filter is an object defined as:
     9{{{
     10  var filter = {
     11    // filter specific properties like id, x, y, width, etc.
     12    "id":"myFilter",
     13    ...
     14    // an array of filter primitives
     15    primitives:[
     16       // ex: a feGaussian primitive
     17       {
     18          "tag":"feGaussian",
     19          "in": "SourceAlpha",
     20          "stdDeviation":"4",
     21          "result":"blur"
     22        }
     23        ...
     24    ]
     25  }
     26}}}
     27
     28To make easier writing filters, a helper api is defined (see below).
     29
     302/ A new dojox/gfx/filters module is created, and contains the helper api and the filter library.
     31
     32The helper API is a minimal (on purpose) api whose purpose is to simplify the creation of filter. It consists on:
     33   * the filters.create(/*Object*/config, /*Array*/primitives) function, which returns a filter object populated with the specified primitives.
     34   * additional functions for every filter primitives defined in the SVG spec, whose name matches the primitives name. The signature of such a function is in the form:
     35
     36  filters.''feFoo''(/*Object*/properties, /*Array?*/ children)
     37
     38where ''propertie'' defines the primitive properties as per the spec, and ''children'' defines an optional array of child primitive (see the spec. for more information).
     39
     40For example, writing a simple "glow" effect gives:
     41{{{
     42filters.createFilter({
     43                x:"-10%",
     44                y:"-10%",
     45                width:"120%",
     46                height:"120%"
     47        },[
     48                filters.feGaussianBlur({
     49                        "in": "SourceGraphic",
     50                        "stdDeviation": 2
     51                }),
     52                filters.feComponentTransfer([
     53                        filters.feFuncA({
     54                                "type":"linear",
     55                                "slope":10
     56                        })
     57                ])
     58        ])
     59}}}
     60
     61Finally, the dojox/gfx/filters module also defines a set of 52 predefined filters, grouped by category, and exported as functions. For example, the following code sets a "Swirl" filter on a rect:
     62{{{
     63  rect.setFilter(filters.textures.swirl({id:"myFilter",x:0,y:0,width:100,height:100}));