jui.define("util.svg.base3d", [ "util.base", "util.math", "util.color" ], function(_, math, color) {
/**
* @class util.svg.base3d
* SVG 3d module
*
* @extends util.svg.base
* @requires util.base
* @requires util.math
* @requires util.color
* @alias SVG3d
*/
var SVG3d = function() {
this.rect3d = function(fill, width, height, degree, depth) {
var self = this;
var radian = math.radian(degree),
x1 = 0,
y1 = 0,
w1 = width,
h1 = height;
var x2 = Math.cos(radian) * depth,
y2 = Math.sin(radian) * depth,
w2 = width + x2,
h2 = height + y2;
var g = self.group({}, function() {
self.path({
fill: color.lighten(fill, 0.15),
stroke: color.lighten(fill, 0.15)
}).MoveTo(x2, x1)
.LineTo(w2, y1)
.LineTo(w1, y2)
.LineTo(x1, y2);
self.path({
fill: fill,
stroke: fill
}).MoveTo(x1, y2)
.LineTo(x1, h2)
.LineTo(w1, h2)
.LineTo(w1, y2);
self.path({
fill: color.darken(fill, 0.2),
stroke: color.darken(fill, 0.2)
}).MoveTo(w1, h2)
.LineTo(w2, h1)
.LineTo(w2, y1)
.LineTo(w1, y2);
});
return g;
}
this.cylinder3d = function(fill, width, height, degree, depth, rate) {
var self = this;
var radian = math.radian(degree),
rate = (rate == undefined) ? 1 : (rate == 0) ? 0.01 : rate,
r = width / 2,
tr = r * rate,
l = (Math.cos(radian) * depth) / 2,
d = (Math.sin(radian) * depth) / 2,
key = _.createId("cylinder3d");
var g = self.group({}, function() {
self.ellipse({
fill: color.darken(fill, 0.05),
"fill-opacity": 0.85,
stroke: color.darken(fill, 0.05),
rx: r,
ry: d,
cx: r,
cy: height
}).translate(l, d);
self.path({
fill: "url(#" + key + ")",
"fill-opacity": 0.85,
stroke: fill
}).MoveTo(r - tr, d)
.LineTo(0, height)
.Arc(r, d, 0, 0, 0, width, height)
.LineTo(r + tr, d)
.Arc(r + tr, d, 0, 0, 1, r - tr, d)
.translate(l, d);
self.ellipse({
fill: color.lighten(fill, 0.2),
"fill-opacity": 0.95,
stroke: color.lighten(fill, 0.2),
rx: r * rate,
ry: d * rate,
cx: r,
cy: d
}).translate(l, d);
self.linearGradient({
id: key,
x1: "100%",
x2: "0%",
y1: "0%",
y2: "0%"
}, function() {
self.stop({
offset: "0%",
"stop-color": color.lighten(fill, 0.15)
});
self.stop({
offset: "33.333333333333336%",
"stop-color": color.darken(fill, 0.2)
});
self.stop({
offset: "66.66666666666667%",
"stop-color": color.darken(fill, 0.2)
});
self.stop({
offset: "100%",
"stop-color": color.lighten(fill, 0.15)
});
});
});
return g;
}
}
return SVG3d;
}, "util.svg.base");