define([ "dojo/_base/lang", "dojo/_base/array" ], function(lang, array){ /*===== return { // summary: // A module that defines a minimal API to create SVG filter definition objects to be used with the // dojox/gfx/svgext/Shape.setFilter() API, as well as a set of predefined filters. // description: // The module defines the following API: // - filters.createFilter(config, primitives) : Creates a filter object from the specified config and the // given filter primitives. // - a set of methods to create the corresponding SVG filter primitives, based on the same // naming as the specification (e.g. filters.feGaussianBlur() ). A filter primitive method follows the // following signature (taking feGaussianBlur as an example): // filters.feGaussianBlur(properties, children?) // filters.feGaussianBlur(children) // The "properties" parameter must define the primitive attributes as defined by the specification. // The "children" array parameter is an array of child filter primitives. // In addition to this API, the module provides the following predefined filters: // - filters.convolutions.boxBlur3, // - filters.convolutions.boxBlur5, // - filters.convolutions.verticalEdges, // - filters.convolutions.horizontalEdges, // - filters.convolutions.allEdges3, // - filters.convolutions.edgeEnhance, // - filters.shadows.fastSmallDropShadow, // - filters.shadows.fastDropShadow, // - filters.shadows.fastDropShadowLight, // - filters.shadows.dropShadow, // - filters.shadows.dropShadowLight, // - filters.shadows.smallDropShadow, // - filters.shadows.smallDropShadowLight, // - filters.blurs.blur1, // - filters.blurs.blur2, // - filters.blurs.blur4, // - filters.blurs.blur8, // - filters.blurs.glow, // - filters.colors.negate, // - filters.colors.sepia, // - filters.colors.grayscale, // - filters.colors.showRed, // - filters.colors.showGreen, // - filters.colors.showBlue, // - filters.colors.hueRotate60, // - filters.colors.hueRotate120, // - filters.colors.hueRotate180, // - filters.colors.hueRotate270, // - filters.miscs.thinEmbossDropShadow, // - filters.miscs.embossDropShadow, // - filters.miscs.largeEmbossDropShadow, // - filters.miscs.thinEmbossDropShadowLight, // - filters.miscs.embossDropShadowLight, // - filters.miscs.largeEmbossDropShadowLight, // - filters.miscs.fuzzy, // - filters.miscs.veryFuzzy, // - filters.miscs.melting, // - filters.miscs.impressionist, // - filters.miscs.holes, // - filters.miscs.holesComplement, // - filters.reliefs.bumpIn, // - filters.reliefs.bumpOut, // - filters.reliefs.thinEmboss, // - filters.reliefs.emboss, // - filters.reliefs.largeEmboss, // - filters.textures.paper, // - filters.textures.swirl, // - filters.textures.swirl2, // - filters.textures.gold // Note: the dojox/gfx/tests/test_filter.html test shows the rendering of all the predefined filters. } =====*/ var filters = {}, defaultFilterBBox = {x:"0%", y:"0%", width:"100%", height:"100%"}, lib = {}; // // A minimal facade API to create primitives // filters.createFilter = function(/*Object*/args, /*Array*/primitives){ // summary: // Creates a filter with the specified primitives. // description: // This function creates a new filter object configured with the optional 'args' parameter, and // adds the filter primitives specified in the 'primitives' array'. The dojox/gfx/filters module // provides convenient methods to create the corresponding SVG filter primitives, based on the same // naming as the specification (e.g. filters.feGaussianBlur() ). // A filter primitive method follows the following signature (taking feGaussianBlur as an example): // filters.feGaussianBlur(/*Object*/properties, /*Array?*/children) // filters.feGaussianBlur(/*Array?*/children) // The "properties" parameter must define the primitive attributes as defined by the specification. // The optional "children" array parameter is an array of child filter primitives. // args: Object // The configuration object for the filter. // primitives: Array // An array of primitives object. var filter = lang.mixin({}, defaultFilterBBox, args); if(!filter.primitives){ filter.primitives = []; } if(primitives){ Array.prototype.push.apply(filter.primitives, primitives); } return filter; /*Object*/ }; var _createFePrimitive = function(tag, args, children){ if(args instanceof Array){ children = args; args = null; } var fe = lang.mixin({}, args); fe.children = children; fe.tag = tag; return fe; }; var _createFeMerge = function(args, children){ if(typeof args === "string"){ // list of primitives to merge via the 'in' property var toMerge = []; for(var i=0; i