From 769fcf719320e5b9c740f455630aeb44b3deb575 Mon Sep 17 00:00:00 2001 From: Niel Mishra Date: Fri, 11 Sep 2015 15:55:11 +0530 Subject: First Commit --- script/primatives.js | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100755 script/primatives.js (limited to 'script/primatives.js') diff --git a/script/primatives.js b/script/primatives.js new file mode 100755 index 0000000..69a6465 --- /dev/null +++ b/script/primatives.js @@ -0,0 +1,79 @@ +Schematic.prototype.createtext = function(str,color,x,y){ + var svg; + + svg = document.createElementNS(this.svgNs, 'text'); + svg.setAttributeNS(null, 'x', x); + svg.setAttributeNS(null, 'y', y); + svg.setAttributeNS(null, 'font-size', this.fontsize); + svg.setAttributeNS(null, 'fill', color); + svg.setAttributeNS(null, 'stroke-width', '0px'); + + svg.appendChild(document.createTextNode(str)); + return svg; +} + + +Schematic.prototype.createtspan=function(str,dx,dy){ + var tspan = document.createElementNS(this.svgNs, 'tspan'); + tspan.setAttributeNS(null, 'dx', dx); + tspan.setAttributeNS(null, 'dy', dy); + tspan.appendChild(document.createTextNode(str)); + return tspan; +} + + +Schematic.prototype.createline = function(lineColor,lineWidth,left, top,right,bottom){ + var svg; + + + svg = document.createElementNS(this.svgNs, 'line'); + + svg.setAttributeNS(null, 'x1', left); + svg.setAttributeNS(null, 'y1', top); + svg.setAttributeNS(null, 'x2', right); + svg.setAttributeNS(null, 'y2', bottom ); + + if (lineColor.length == 0) + lineColor = 'none'; + svg.setAttributeNS(null, 'stroke', lineColor); + svg.setAttributeNS(null, 'stroke-width', lineWidth); + + return svg; + +} + +Schematic.prototype.createrect = function(color,opacity,x, y,width,height){ + + var svg = document.createElementNS(this.svgNs, 'rect'); + svg.setAttributeNS(null, 'x', x); + svg.setAttributeNS(null, 'y', y); + svg.setAttributeNS(null, 'width', width); + svg.setAttributeNS(null, 'height', height); + svg.setAttributeNS(null, 'fill-opacity', opacity); + svg.setAttributeNS(null, 'fill', color); + svg.setAttributeNS(null, 'stroke', color); + svg.setAttributeNS(null, 'stroke-width', '1'); + return svg; + +} + + +Schematic.prototype.createdot =function(lineColor,x,y,radius){ + + var svg; + + + svg = this.container.ownerDocument.createElementNS(this.svgNs, 'circle'); + svg.setAttributeNS(null, 'cx', x); + svg.setAttributeNS(null, 'cy', y); + svg.setAttributeNS(null, 'r', radius ); + + if (lineColor.length == 0) + lineColor = 'none'; + svg.setAttributeNS(null, 'stroke', lineColor); + svg.setAttributeNS(null, 'fill', lineColor); + + return svg; +} + + -- cgit