Advertisement
Guest User

hexpy.py

a guest
May 16th, 2016
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.42 KB | None | 0 0
  1. #!/bin/python
  2.  
  3. head="""<?xml version="1.0" encoding="UTF-8" standalone="no"?>
  4. <svg
  5. xmlns:dc="http://purl.org/dc/elements/1.1/"
  6. xmlns:cc="http://creativecommons.org/ns#"
  7. xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  8. xmlns:svg="http://www.w3.org/2000/svg"
  9. xmlns="http://www.w3.org/2000/svg"
  10. xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
  11. xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
  12. width="210mm"
  13. height="297mm"
  14. viewBox="0 0 744.09448819 1052.3622047"
  15. id="svg4135"
  16. version="1.1"
  17. inkscape:version="0.91 r13725"
  18. sodipodi:docname="drawing.svg">
  19. <sodipodi:namedview
  20. pagecolor="#ffffff"
  21. bordercolor="#666666"
  22. borderopacity="1"
  23. objecttolerance="10"
  24. gridtolerance="10"
  25. guidetolerance="10"
  26. inkscape:pageopacity="0"
  27. inkscape:pageshadow="2"
  28. inkscape:window-width="1414"
  29. inkscape:window-height="779"
  30. id="namedview8"
  31. showgrid="false"
  32. inkscape:zoom="14.352473"
  33. inkscape:cx="26.120517"
  34. inkscape:cy="18.909715"
  35. inkscape:window-x="172"
  36. inkscape:window-y="99"
  37. inkscape:window-maximized="0"
  38. inkscape:current-layer="svg4135" />
  39. <defs
  40. id="defs4137" />
  41. <metadata
  42. id="metadata4140">
  43. <rdf:RDF>
  44. <cc:Work
  45. rdf:about="">
  46. <dc:format>image/svg+xml</dc:format>
  47. <dc:type
  48. rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
  49. <dc:title />
  50. </cc:Work>
  51. </rdf:RDF>
  52. </metadata>
  53. """
  54. bottom="</svg>"
  55.  
  56. hexagono="""
  57. <path
  58. style="fill:none;fill-opacity:1;stroke:#000000;stroke-width:1;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
  59. id="pathID"
  60. d="m XX,YY -2.7570672,4.7754 -5.5141344,0 -2.75706716,-4.7754 2.75706716,-4.7754 5.5141344,0 z" />
  61. """
  62.  
  63. basex = 12
  64. basey = 1047
  65. columna = 0
  66. id = 1
  67. incrementox = 8.278261
  68. incrementy = 9.6132
  69. salida = ""
  70. axisx=basex
  71. axisy=basey
  72.  
  73. while axisx<1487:
  74. while axisy>0:
  75. print "X:",axisx,"Y",axisy
  76. salida = salida + hexagono.replace("XX",str(axisx)).replace("YY",str(axisy)).replace("ID",str(id))
  77. axisy -= incrementy
  78. axisx += incrementox
  79. columna += 1
  80. if columna == 2:
  81. columna = 0
  82. if columna == 1:
  83. axisy = 1042.1934
  84. else:
  85. axisy = basey
  86. id += 1
  87.  
  88. f=open("hexgrid.svg","w")
  89. f.write(head)
  90. f.write(salida)
  91. f.write(bottom)
  92. f.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement