viewbox.html 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>ViewBox Example</title>
  5. <!-- 正式发布的时候, 只需替换掉相应的脚本文件即可 -->
  6. <!-- dev 版本 示例所需脚本文件 start -->
  7. <script src="../dev-lib/sea.js"></script>
  8. <script>
  9. seajs.config({
  10. base: '../src'
  11. });
  12. </script>
  13. <script src="../dev-lib/exports.js"></script>
  14. <script src="../dev-lib/dev-start.js"></script>
  15. <!-- dev 版本 示例所需脚本文件 end -->
  16. <!-- 正式版本 示例所需脚本文件 start -->
  17. <!--<script src="../dist/kitygraph.all.min.js"></script>-->
  18. <!-- 正式版本 示例所需脚本文件 end -->
  19. <script>
  20. window.onload = function () {
  21. var paper1 = new kity.Paper(document.body);
  22. var paper2 = new kity.Paper(document.body);
  23. paper1.setWidth(400).setHeight(300);
  24. paper2.setWidth(400).setHeight(300);
  25. var rect1 = new kity.Rect(60, 40, 10, 10);
  26. rect1.fill('blue');
  27. paper1.addShape(rect1);
  28. var rect2 = new kity.Rect(60, 40, 10, 10);
  29. rect2.fill('red');
  30. paper2.addShape(rect2);
  31. paper1.setViewBox(0, 0, 400, 300);
  32. paper2.setViewBox(-100, -75, 200, 150);
  33. paper1.addShape(new kity.Text('viewbox = (0, 0, 400, 300)').setX(10).setY('50%'));
  34. paper2.addShape(new kity.Text('viewbox = (-100, -75, 200, 150)').setX(-95).setY(0).setStyle({
  35. 'font-size': '6pt'
  36. }));
  37. };
  38. </script>
  39. <style>
  40. svg {
  41. border: 1px solid gray;
  42. }
  43. </style>
  44. </head>
  45. <body>
  46. </body>
  47. </html>