jui.define("util.svg.base", [ "util.base", "util.math", "util.color", "util.svg.element", "util.svg.element.transform", "util.svg.element.path", "util.svg.element.path.symbol", "util.svg.element.path.rect", "util.svg.element.poly" ], function(_, math, color, Element, TransElement, PathElement, PathSymbolElement, PathRectElement, PolyElement) { var globalObj = null; /** * @class util.svg.base * SVG base module * * @requires util.base * @requires util.math * @requires util.color * @requires util.svg.element * @requires util.svg.element.transform * @requires util.svg.element.path * @requires util.svg.element.path.symbol * @requires util.svg.element.path.rect * @requires util.svg.element.poly * @alias SVGBase */ var SVGBase = function() { this.create = function(obj, type, attr, callback) { obj.create(type, attr); return obj; } this.createChild = function(obj, type, attr, callback) { return this.create(obj, type, attr, callback); } /** * @method custom * * return custom element * * @param {String} name * @param {Object} attr * @param {Function} callback * @return {util.svg.element} */ this.custom = function(name, attr, callback) { return this.create(new Element(), name, attr, callback); } /** * @method defs * * return defs element * * @param {Function} callback * @return {util.svg.element} */ this.defs = function(callback) { return this.create(new Element(), "defs", null, callback); } /** * @method symbol * * return symbol element * * @param {Object} attr * @param {Function} callback * @return {util.svg.element} */ this.symbol = function(attr, callback) { return this.create(new Element(), "symbol", attr, callback); } /** * @method g * * return defs element * * @alias group * @param {Object} attr * @param {Function} callback * @return {util.svg.element.transform} */ this.g = this.group = function(attr, callback) { return this.create(new TransElement(), "g", attr, callback); } /** * @method marker * * return marker element * * @param {Object} attr * @param {Function} callback * @return {util.svg.element} */ this.marker = function(attr, callback) { return this.create(new Element(), "marker", attr, callback); } /** * @method a * * return a element * * @param {Object} attr * @param {Function} callback * @return {util.svg.element.transform} */ this.a = function(attr, callback) { return this.create(new TransElement(), "a", attr, callback); } /** * @method switch * * return switch element * * @param {Object} attr * @param {Function} callback * @return {util.svg.element} */ this.switch = function(attr, callback) { return this.create(new Element(), "switch", attr, callback); } /** * @method use * * return use element * * @param {Object} attr * @return {util.svg.element} */ this.use = function(attr) { return this.create(new Element(), "use", attr); } /** * @method rect * * return rect element * * @param {Object} attr * @param {Function} callback * @return {util.svg.element.transform} */ this.rect = function(attr, callback) { return this.create(new TransElement(), "rect", attr, callback); } /** * @method line * * return line element * * @param {Object} attr * @param {Function} callback * @return {util.svg.element.transform} */ this.line = function(attr, callback) { return this.create(new TransElement(), "line", attr, callback); } this.circle = function(attr, callback) { return this.create(new TransElement(), "circle", attr, callback); } this.text = function(attr, textOrCallback) { if(arguments.length == 2) { if (_.typeCheck("function", textOrCallback)) { return this.create(new TransElement(), "text", attr, textOrCallback); } return this.create(new TransElement(), "text", attr).text(textOrCallback); } return this.create(new TransElement(), "text", attr); } this.textPath = function(attr, text) { if(_.typeCheck("string", text)) { return this.create(new Element(), "textPath", attr).text(text); } return this.create(new Element(), "textPath", attr); } this.tref = function(attr, text) { if(_.typeCheck("string", text)) { return this.create(new Element(), "tref", attr).text(text); } return this.create(new Element(), "tref", attr); } this.tspan = function(attr, text) { if(_.typeCheck("string", text)) { return this.create(new Element(), "tspan", attr).text(text); } return this.create(new Element(), "tspan", attr); } this.ellipse = function(attr, callback) { return this.create(new TransElement(), "ellipse", attr, callback); } this.image = function(attr, callback) { return this.create(new TransElement(), "image", attr, callback); } this.path = function(attr, callback) { return this.create(new PathElement(), "path", attr, callback); } this.pathSymbol = function(attr, callback) { return this.create(new PathSymbolElement(), "path", attr, callback); } this.pathRect = function(attr, callback) { return this.create(new PathRectElement(), "path", attr, callback); } this.polyline = function(attr, callback) { return this.create(new PolyElement(), "polyline", attr, callback); } this.polygon = function(attr, callback) { return this.create(new PolyElement(), "polygon", attr, callback); } this.pattern = function(attr, callback) { return this.create(new Element(), "pattern", attr, callback); } this.mask = function(attr, callback) { return this.create(new Element(), "mask", attr, callback); } this.clipPath = function(attr, callback) { return this.create(new Element(), "clipPath", attr, callback); } this.linearGradient = function(attr, callback) { return this.create(new Element(), "linearGradient", attr, callback); } this.radialGradient = function(attr, callback) { return this.create(new Element(), "radialGradient", attr, callback); } this.filter = function(attr, callback) { return this.create(new Element(), "filter", attr, callback); } this.foreignObject = function(attr, callback) { return this.create(new TransElement(), "foreignObject", attr, callback); } /** * 엘리먼트 관련 메소드 (그라데이션) * */ this.stop = function(attr) { return this.createChild(new Element(), "stop", attr); } /** * 엘리먼트 관련 메소드 (애니메이션) * */ this.animate = function(attr) { return this.createChild(new Element(), "animate", attr); } this.animateColor = function(attr) { return this.createChild(new Element(), "animateColor", attr); } this.animateMotion = function(attr) { return this.createChild(new Element(), "animateMotion", attr); } this.animateTransform = function(attr) { return this.createChild(new Element(), "animateTransform", attr); } this.mpath = function(attr) { return this.createChild(new Element(), "mpath", attr); } this.set = function(attr) { return this.createChild(new Element(), "set", attr); } /** * 엘리먼트 관련 메소드 (필터) * */ this.feBlend = function(attr) { return this.createChild(new Element(), "feBlend", attr); } this.feColorMatrix = function(attr) { return this.createChild(new Element(), "feColorMatrix", attr); } this.feComponentTransfer = function(attr) { return this.createChild(new Element(), "feComponentTransfer", attr); } this.feComposite = function(attr) { return this.createChild(new Element(), "feComposite", attr); } this.feConvolveMatrix = function(attr) { return this.createChild(new Element(), "feConvolveMatrix", attr); } this.feDiffuseLighting = function(attr) { return this.createChild(new Element(), "feDiffuseLighting", attr); } this.feDisplacementMap = function(attr) { return this.createChild(new Element(), "feDisplacementMap", attr); } this.feFlood = function(attr) { return this.createChild(new Element(), "feFlood", attr); } this.feGaussianBlur = function(attr) { return this.createChild(new Element(), "feGaussianBlur", attr); } this.feImage = function(attr) { return this.createChild(new Element(), "feImage", attr); } this.feMerge = function(attr, callback) { return this.createChild(new Element(), "feMerge", attr, callback); } this.feMergeNode = function(attr) { return this.createChild(new Element(), "feMergeNode", attr); } this.feMorphology = function(attr) { return this.createChild(new Element(), "feMorphology", attr); } this.feOffset = function(attr) { return this.createChild(new Element(), "feOffset", attr); } this.feSpecularLighting = function(attr) { return this.createChild(new Element(), "feSpecularLighting", attr); } this.feTile = function(attr) { return this.createChild(new Element(), "feTile", attr); } this.feTurbulence = function(attr) { return this.createChild(new Element(), "feTurbulence", attr); } } SVGBase.create = function(name, attr, callback) { if(globalObj == null) { globalObj = new SVGBase(); } return globalObj.custom(name, attr, callback); } return SVGBase; });