Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html  PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
        
  <head>
    <title>SVGKit Minimal</title>
    <!-- START Required for IE to support  inlined SVG -->
    <object id="AdobeSVG" width="1" height="1" 
    classid="clsid:78156a80-c6a1-4bbf-8e6a-3cd390eeb4e2"></object>
    <?import namespace="svg" implementation="#AdobeSVG"?>
    <!-- END   Required for IE to support inlined SVG -->
    <script type="text/javascript"
    src="http://companje.nl/svgkit/MochiKit/MochiKit.js"></script>
    <script type="text/javascript"
    src="http://companje.nl/svgkit/SVGKit/SVGKit.js" ></script>
    
  </head>
  <body>
    <div id="mydiv"></div>
    <textarea id="txt" style="width:100%; height:200px"></textarea>
  </body>
</html>
 
width = 800;
height = 800;
scale = 1;
offset = [0,0];
mill = 6;
material = 18;
m = material;
boorgatDiameter = 6.5;
noFill = "fill:none;stroke:1";
  
svg = new SVGKit(width,height);
style = svg.STYLE();
//svg.attributes.width=width+"mm";
style.textContent = "* {fill:none;stroke:1} .red {stroke:red;} LINE {stroke:red;} POLYLINE {stroke:blue}";
root = svg.G();
svg.translate(root,width/2,height/2);
svg.scale(root,scale,scale);
svg.translate(root,offset[0],offset[1]);
//svg.append(style);
svg.append(root);
//root.appendChild(svg.CIRCLE({r:2,"class":"red"})); //origin
//Circles
var innerRadius = 322;
var outerRadius = 390;
appendChildNodes(
  root, 
  svg.CIRCLE({cx:0, cy:0, r:outerRadius, style:noFill}),
  svg.CIRCLE({cx:0, cy:0, r:innerRadius, style:noFill})
);
             
//Poles
var poleDist = 234;
var poleA = 140;
var poleB = 222;
var poleC = 340;
var poles;
function vierkantje(x,y,w,h) {
  x-=w/2;
  y-=h/2;
  
  var v = svg.G();
  var p = [];
  p[0] = {style:noFill, x1:x,           y1:y+mill/2,    x2:x+w-mill/2,   y2:y+mill/2};
  p[1] = {style:noFill, x1:x+w-mill/2,  y1:y,           x2:x+w-mill/2,   y2:y+h-mill/2};
  p[2] = {style:noFill, x1:x+w,         y1:y+h-mill/2,  x2:x+mill/2,     y2:y+h-mill/2};
  p[3] = {style:noFill, x1:x+mill/2,    y1:y+h,         x2:x+mill/2,     y2:y+mill/2};
    
  for (i=0; i<4; i++) {
    appendChildNodes(v,svg.LINE(p[i]));
  }
  
  return v;
}
appendChildNodes(
  poles = svg.G(),
  vierkantje(-poleDist/2,-poleA,m,m),
  vierkantje(-poleDist/2,-poleB,m,m),
  vierkantje(-poleDist/2,-poleC,m,m),
  vierkantje(poleDist/2,-poleA,m,m),
  vierkantje(poleDist/2,-poleB,m,m),
  vierkantje(poleDist/2,-poleC,m,m)
);
for (i=0; i<3; i++) {
  var poles2 = poles.cloneNode(true); //recursive
  if (i>0) svg.rotate(poles2,i*120); //prevent bug when rotating 0 degrees
  appendChildNodes(root,poles2);
}
//Wheels
var wheelW=80;
var wheelBoldsDist=70;
var wheelH=22-mill;
var wheelY=-wheelH/2-17;
var wheelsY=-338;
var wheelsAngleOffset=0.1; //115;
    
appendChildNodes(
  wheels = svg.G(),
  boorgat(-wheelBoldsDist/2,0),
  boorgat(wheelBoldsDist/2,0),
  svg.RECT({style:noFill, x:-wheelW/2,y:wheelY,width:wheelW,height:wheelH,rx:wheelH/2,ry:wheelH/2})        
);
for (i=0; i<6; i++) {
  var wheels2 = wheels.cloneNode(true); //recursive
  svg.rotate(wheels2,i*60+wheelsAngleOffset); //note: never rotate 0 degrees
  svg.translate(wheels2,0,-338);
  appendChildNodes(root,wheels2);
}
function boorgat(x,y) {
  return svg.CIRCLE({style:noFill, r:(boorgatDiameter-mill)/2,cx:x,cy:y});
}
//Lockers
var lockerY = -338;
var lockerAngleOffset = 85; //75;
appendChildNodes(locker = svg.G(),
  boorgat(-48/2,0),
  boorgat(48/2,0),
  svg.RECT({style:noFill, x:-5,y:-8,width:10-mill,height:16-mill,rx:6,ry:6})
);
for (i=0; i<3; i++) {
  var locker2 = locker.cloneNode(true); //recursive
  svg.rotate(locker2,i*120+lockerAngleOffset); //note: never rotate 0 degrees
  svg.translate(locker2,0,lockerY);
  appendChildNodes(root,locker2);
}
appendChildNodes('mydiv', svg.htmlElement);
txt.value = txt.innerText = svg.toXML();
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers