Guest User

Untitled

a guest
Jul 18th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en" dir="ltr">
  3. <head>
  4. <meta charset="utf-8">
  5. <title></title>
  6. <style>
  7. svg{background:grey;width:400px;height:400px}
  8. </style>
  9. </head>
  10. <body>
  11. <svg viewBox="0 0 100 100">
  12. <path id="lamelle" d="M6,0 a6 6 0 0 0 -6 6h7a1.5 1.5 0 0 1 0 3h-7a6 6 0 0 0 6 6h10c5 0 5 -5 10 -5h20a 5 5 0 0 0 0 -10z" stroke="red"/>
  13. </svg>
  14. <svg viewBox="0 0 100 100">
  15. <path id="lamelle2" d="M0,0" stroke="red"/>
  16. </svg>
  17. <textarea id="ta">
  18.  
  19. </textarea>
  20. <script>
  21. function flatten(src,dest,num){
  22. var l = src.getTotalLength()
  23. var p = src.getPointAtLength(0)
  24. var d = `M${p.x} ${p.y}`
  25. var pl=`polygon([[${p.x},${p.y}]`
  26. var ia=[0]
  27. n=0
  28. for(var i = (l/num);i<=l;i+=(l/num)){
  29. n++
  30. ia.push(n)
  31. p = src.getPointAtLength(i)
  32. d+=`L${p.x} ${p.y}`
  33. pl+=`,[${p.x},${p.y}]`
  34. }
  35. pl+=`],[[${ia.join(",")}]])`
  36. ta.value=pl
  37. dest.setAttribute("d",d+"z")
  38. }
  39. flatten(lamelle,lamelle2,200)
  40. </script>
  41. </body>
  42. </html>
Add Comment
Please, Sign In to add comment