graphics-vml.js revision a00d11bb8925157bd9fcc0e0fb5fc697c53726ea
/**
* VMLGraphics is a fallback drawing api used for basic drawing operations when SVG is not available.
*
* @class VMLGraphics
* @constructor
*/
var VMLGraphics = function(config) {
};
/**
* @private
*/
VMLGraphics.prototype = {
initializer: function(config) {
this.node = this._createGraphics();
this.setSize(w, h);
this._initProps();
},
/**
* @private
*/
beginBitmapFill: function(config) {
var fill = {};
this._fillProps = fill;
{
this._gradientBox = {
};
}
else
{
this._gradientBox = null;
}
},
/**
* @private
*/
if (color) {
this._fillProps = {
type:"solid",
};
}
this._fillColor = color;
this._fill = 1;
}
return this;
},
/**
* @private
*/
beginGradientFill: function(config) {
fill = {
},
i = 0,
oi,
for(;i < len; ++i)
{
}
if(type === "linear")
{
if(config)
{
}
{
}
else if(rotation <= 270)
{
}
else if(rotation <= 360)
{
}
else
{
rotation = 270;
}
}
else if(type === "radial")
{
fill.alignshape = false;
}
{
this._gradientBox = {
};
}
else
{
this._gradientBox = null;
}
this._fillProps = fill;
},
/**
* @private
*/
clear: function() {
this._path = '';
this._removeChildren(this.node);
},
/**
* @private
*/
destroy: function()
{
this._removeChildren(this.node);
},
/**
* @private
*/
_removeChildren: function(node)
{
if(node.hasChildNodes())
{
var child;
while(node.firstChild)
{
this._removeChildren(child);
}
}
},
/**
* @private
*/
toggleVisible: function(val)
{
},
/**
* @private
*/
{
i = 0,
len;
if(children)
{
for(; i < len; ++i)
{
}
}
},
/**
* @private
*/
this._shape = "shape";
this._path += ' c ' + Math.round(cp1x) + ", " + Math.round(cp1y) + ", " + Math.round(cp2x) + ", " + Math.round(cp2y) + ", " + x + ", " + y;
this._trackSize(x, y);
},
/**
* @private
*/
},
/**
* @private
*/
drawCircle: function(x, y, r) {
this._x = x - r;
this._y = y - r;
this._shape = "oval";
this._draw();
},
/**
* @private
*/
drawEllipse: function(x, y, w, h) {
this._width = w;
this._height = h;
this._x = x;
this._y = y;
this._shape = "oval";
this._draw();
},
/**
* @private
*/
drawRect: function(x, y, w, h) {
this._x = x;
this._y = y;
this._width = w;
this._height = h;
this.moveTo(x, y);
this.lineTo(x + w, y);
this.lineTo(x + w, y + h);
this.lineTo(x, y + h);
this.lineTo(x, y);
this._draw();
},
/**
* @private
*/
this._x = x;
this._y = y;
this._width = w;
this._height = h;
this.quadraticCurveTo(x, y + h, x + ew, y + h);
this.quadraticCurveTo(x + w, y + h, x + w, y + h - eh);
this.quadraticCurveTo(x + w, y, x + w - ew, y);
this.quadraticCurveTo(x, y, x, y + eh);
this._draw();
},
/**
* @private
*/
{
this._drawingComplete = false;
this._path += this._getWedgePath({x:x, y:y, startAngle:startAngle, arc:arc, radius:radius, yRadius:yRadius});
this._shape = "shape";
this._draw();
},
/**
* @private
*/
_getWedgePath: function(config)
{
var x = config.x,
y = config.y,
path;
{
arc = 360;
}
startAngle *= -65535;
arc *= 65536;
path = " m " + x + " " + y + " ae " + x + " " + y + " " + radius + " " + yRadius + " " + startAngle + " " + arc;
return path;
},
/**
* @private
*/
end: function() {
if(this._shape)
{
this._draw();
}
this._initProps();
},
/**
* @private
*/
lineGradientStyle: function() {
},
/**
* @private
*/
this._stroke = 1;
this._strokeColor = color;
},
/**
* @private
*/
i,
len;
}
this._shape = "shape";
this._path += ' l ';
for (i = 0; i < len; ++i) {
}
},
/**
* @private
*/
moveTo: function(x, y) {
},
/**
* @private
*/
setSize: function(w, h) {
w = Math.round(w);
h = Math.round(h);
this._canvasWidth = w;
this._canvasHeight = h;
},
/**
* @private
*/
setPosition: function(x, y)
{
x = Math.round(x);
y = Math.round(y);
},
/**
* @private
*/
render: function(parentNode) {
this.setSize(w, h);
this._initProps();
return this;
},
/**
* @private
*/
_shape: null,
/**
* @private
*/
_trackSize: function(w, h) {
if (w > this._width) {
this._width = w;
}
if (h > this._height) {
this._height = h;
}
},
/**
* @private
*/
_initProps: function() {
this._fillColor = null;
this._strokeColor = null;
this._strokeOpacity = null;
this._strokeWeight = 0;
this._fillProps = null;
this._path = '';
this._width = 0;
this._height = 0;
this._x = 0;
this._y = 0;
this._fill = null;
this._stroke = 0;
this._stroked = false;
},
/**
* @private
*/
_clearPath: function()
{
this._shape = null;
this._path = '';
this._width = 0;
this._height = 0;
this._x = 0;
this._y = 0;
},
/**
* @private
*/
_draw: function()
{
fillProps = this._fillProps;
this.setSize(w, h);
if(this._path)
{
if(this._fill || this._fillProps)
{
this._path += ' x';
}
if(this._stroke)
{
this._path += ' e';
}
}
else
{
}
if (this._fill) {
}
else
{
}
{
}
} else {
}
if (fillProps) {
}
this._clearPath();
},
/**
* @private
*/
_getFill: function() {
w = this._width,
h = this._height,
fillProps = this._fillProps,
prop,
pct,
i = 0,
colorstring = "",
len,
cx = 50,
cy = 50;
if(this._gradientBox)
{
cx= Math.round( (this._gradientBox.width/2 - ((this._x - this._gradientBox.tx) * hyp/w))/(w * w/hyp) * 100);
cy = Math.round( (this._gradientBox.height/2 - ((this._y - this._gradientBox.ty) * hyp/h))/(h * h/hyp) * 100);
}
{
for(;i < len; ++i) {
}
{
}
}
}
}
{
}
return fill;
},
/**
* @private
*/
_createGraphics: function() {
return group;
},
/**
* @private
*/
_createGraphicNode: function(type)
{
return document.createElement('<' + type + ' xmlns="urn:schemas-microsft.com:vml" class="vml' + type + '"/>');
},
/**
* @private
*/
_getNodeShapeType: function(type)
{
var shape = "shape";
{
}
return shape;
},
/**
* @private
*/
circle: "oval",
ellipse: "oval",
rect: "rect"
},
/**
* @private
*/
},
/**
* @private
*/
{
}
};
if(!document.createElementNS)
{
Y.log('using VML');
Y.Graphic = VMLGraphics;
}