UNPKG

@fusioncharts/core

Version:

JavaScript Data Visualisation Library

1 lines 4.07 kB
"use strict";exports.__esModule=true;exports.default=_default;var _lib=require("../../../lib");function _default(R){var UNDEF,math=Math,mathAtan2=math.atan2,NONE="none",FILL="fill",PATH="path",CUBEPATH="cubepath";R.define&&R.define([{name:"cubepath",cubepath:function cubepath(){var paper=this,shapeDefaultAttrs={"stroke-linejoin":"round","shape-rendering":"precision",stroke:NONE},args=arguments,lastArg=args.length-1,group=args[lastArg],top,side,a,face,generateCubepath=function generateCubepath(_x,_y,_w,_h,_zw,_zh){var o=this,t=o._.cubetop,s=o._.cubeside,x=_x,y=_y,w=_w,h=_h,zw=_zw,zh=_zh;if(typeof x==="object"||x===UNDEF&&y===UNDEF&&w===UNDEF&&h===UNDEF&&zw===UNDEF&&zh===UNDEF){return this}x=(0,_lib.pluckNumber)(x,o.attrs.x,0);y=(0,_lib.pluckNumber)(y,o.attrs.y,0);w=(0,_lib.pluckNumber)(w,o.attrs.width,0);h=(0,_lib.pluckNumber)(h,o.attrs.height,0);zw=(0,_lib.pluckNumber)(zw,o.attrs.xDepth,0);zh=(0,_lib.pluckNumber)(zh,o.attrs.yDepth,0);o.attrs.x=x;o.attrs.y=y;o.attrs.width=w;o.attrs.height=h;o.attrs.xDepth=zw;o.attrs.yDepth=zh;o._attr(PATH,["M",x+w,y,"l",0,h,-w,0,0,-h,"z"]);t.attr(PATH,["M",x,y,"l",1,1,w-1,0,0,-1,zw,-zh,-w,0,"z"]);s.attr(PATH,["M",x+w-1,y+1,"l",0,h-1,1,0,zw,-zh,0,-h,-zw,zh]);return this},dropShadow=function dropShadow(dx,dy,spread,color){var o=this,topShadow=o._.cubetop,sideShadow=o._.cubeside;if(o.dropshadow){topShadow.dropshadow(dx,-dy,spread,color);sideShadow.dropshadow(dx,-dy,spread,color)}return false};group&&group.constructor===R.el.constructor?args[lastArg]=UNDEF:group=UNDEF;top=paper.path(shapeDefaultAttrs,group);side=paper.path(shapeDefaultAttrs,group);face=paper.path(shapeDefaultAttrs,group);face._.cubetop=top.follow(face,UNDEF,"before");face._.cubeside=side.follow(face,UNDEF,"before");for(a in R.fn.cubepath.ca){face.ca[a]=R.fn.cubepath.ca[a]}face._attr=face.attr;face._shadow=face.shadow;face.attr=function(name,_value){var isObject=typeof name==="object",value=_value;if(isObject){if(name.cubepath){value=[].concat(name.cubepath)}else{value=[];value.push(name.x);value.push(name.y);value.push(name.width);value.push(name.height);value.push(name.xDepth);value.push(name.yDepth)}if(name.noGradient!==UNDEF){face.attrs.noGradient=name.noGradient}}if(name===UNDEF&&value===UNDEF){return this.attrs}else if(value===UNDEF){return this.attrs[name]}if(isObject){generateCubepath.apply(this,value)}else if(name==="drop-shadow"){dropShadow.apply(this,[].concat(value))}face._attr(name);return this};face.appendTo=function(_group){_group.appendChild(face._.cubetop);_group.appendChild(face._.cubeside);_group.appendChild(face)};if(typeof args[0]==="object"){return face.attr(args[0])}return generateCubepath.apply(face,[args[0],args[1],args[2],args[3],args[4],args[5]])},fn:{_getBBox2:function _getBBox2(){var shape=this,sideBox=shape._.cubeside.getBBox(),topBox=shape._.cubetop.getBBox(),bbox=shape.getBBox();return{x:bbox.x+topBox.height,y:bbox.y-sideBox.width,width:bbox.width,height:bbox.height}},shadow:function shadow(){this._.cubeside.shadow.apply(this._.cubeside,arguments);this._.cubetop.shadow.apply(this._.cubetop,arguments);return this._shadow.apply(this,arguments)}},ca:{"stroke-linejoin":function strokeLinejoin(){return{"stroke-linejoin":"round"}},fill:function fill(_color,_nogradient){var o=this,top=o._.cubetop,side=o._.cubeside,attr=o._attr(CUBEPATH)||[0,0,0,0,0,0],color=_color,nogradient=_nogradient,width=attr[2],zw=attr[4],zh=attr[5],rgba;if(nogradient===UNDEF){nogradient=o._attr("noGradient")}color=R.color(color);if(typeof color==="object"){color=rgba="opacity"in color?"rgba("+[color.r,color.g,color.b,color.opacity]+")":"rgb("+[color.r,color.g,color.b]+")"}if(nogradient){o._attr(FILL,color);top.attr(FILL,R.tintshade(color,-.78).rgba);side.attr(FILL,R.tintshade(color,-.65).rgba)}else{o._attr(FILL,[270,R.tintshade(rgba,.55).rgba,R.tintshade(rgba,-.65).rgba].join("-"));side.attr(FILL,[270,R.tintshade(rgba,-.75).rgba,R.tintshade(rgba,-.35).rgba].join("-"));top.attr(FILL,[45+R.deg(mathAtan2(zh,zw+width)),R.tintshade(rgba,-.78).rgba,R.tintshade(rgba,.22).rgba].join("-"))}return false}}}])}