summaryrefslogtreecommitdiff
path: root/script/primatives.js
blob: 69a646520df26b8f6fa8f38635440ec891e0cecc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
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;
}