printrun-src/testfiles/grid.svg

Thu, 30 May 2019 19:02:52 +0200

author
mdd
date
Thu, 30 May 2019 19:02:52 +0200
changeset 42
ea4c43494a19
parent 15
0bbb006204fc
permissions
-rw-r--r--

bugfixes on rastered image column endings, force laser off with G0 + little offset

15
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
1 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
2 <svg xmlns="http://www.w3.org/2000/svg" onload='init()' width="150mm" height="150mm" version="1.1">
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
3 <script type='text/ecmascript'>
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
4 <![CDATA[
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
5 function getParameterByName(name)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
6 {
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
7 name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
8 var regexS = "[\\?&]" + name + "=([^&#]*)";
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
9 var regex = new RegExp(regexS);
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
10 var results = regex.exec(window.location.search);
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
11 if(results == null)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
12 return "";
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
13 else
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
14 return decodeURIComponent(results[1].replace(/\+/g, " "));
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
15 }
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
16
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
17 function init() {
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
18 var width = getParameterByName('width') || 150;
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
19 var height = getParameterByName('height') || 150;
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
20 var gridheight = getParameterByName('gridheight') || 10;
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
21 var gridwidth = getParameterByName('gridwidth') || 10;
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
22 var lineheight = getParameterByName('lineheight') || 0.5;
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
23 var linewidth = getParameterByName('linewidth') || 0.5;
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
24
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
25 var lineblockheight = (gridheight/2)-lineheight;
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
26 var lineblockwidth = (gridwidth/2)-linewidth;
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
27
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
28 console.log(lineblockheight,lineblockwidth)
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
29
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
30
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
31 document.getElementsByTagName('svg')[0].setAttribute('width',width+'mm');
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
32 document.getElementsByTagName('svg')[0].setAttribute('height',height+'mm');
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
33
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
34
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
35 document.getElementsByTagName('pattern')[0].setAttribute('height',gridheight+'mm');
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
36 document.getElementsByTagName('pattern')[0].setAttribute('width',gridwidth+'mm');
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
37
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
38 document.getElementsByClassName('background')[0].setAttribute('height',gridheight+'mm');
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
39 document.getElementsByClassName('background')[0].setAttribute('width',gridwidth+'mm');
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
40
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
41 var blocks = document.getElementsByClassName('block');
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
42 for (var i in blocks){
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
43 if (blocks[i] instanceof SVGRectElement){
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
44 blocks[i].setAttribute('height', lineblockheight+'mm');
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
45 blocks[i].setAttribute('width', lineblockwidth+'mm');
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
46 }
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
47 }
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
48
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
49 document.getElementsByClassName('topright')[0].setAttribute('x',lineblockwidth+'mm');
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
50 document.getElementsByClassName('bottomleft')[0].setAttribute('y',lineblockheight+'mm');
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
51 document.getElementsByClassName('bottomright')[0].setAttribute('x',lineblockwidth+'mm');
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
52 document.getElementsByClassName('bottomright')[0].setAttribute('y',lineblockheight+'mm');
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
53
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
54 }
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
55 ]]>
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
56 </script>
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
57
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
58 <defs>
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
59 <pattern id="grd" patternUnits="userSpaceOnUse" width="10mm" height="10mm">
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
60 <rect class="background" width="10mm" height="10mm" fill="red"/>
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
61 <rect class="block topleft" width="4.9mm" height="4.9mm"/>
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
62 <rect class="block topright" width="4.9mm" height="4.9mm" x="4.9mm"/>
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
63 <rect class="block bottomleft" width="4.9mm" height="4.9mm" y="4.9mm"/>
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
64 <rect class="block bottomright" width="4.9mm" height="4.9mm" x="4.9mm" y="4.9mm"/>
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
65 </pattern>
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
66 </defs>
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
67 <rect height="100%" width="100%" fill="url(#grd)"/>
0bbb006204fc Added printrun sourcecode from
mbayer
parents:
diff changeset
68 </svg>

mercurial