renderbox.html 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>Boundary Box 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 paper = new kity.Paper(document.body);
  22. function rbox(shape) {
  23. var box = shape.getRenderBox();
  24. return new kity.Rect(box.width | 0, box.height | 0, (box.x | 0) + .5, (box.y | 0) + .5).stroke('green');
  25. }
  26. paper.setWidth(600).setHeight(400);
  27. var rect = new kity.Rect(100, 50)
  28. .setTranslate(20, 20)
  29. .fill('blue').setOpacity(0.3);
  30. var triangle = new kity.RegularPolygon(3, 50)
  31. .setTranslate(200, 50).setRotate(90)
  32. .fill('blue').setOpacity(0.3);
  33. var circle = new kity.Circle(30, 205, 35)
  34. .setScale(1.5)
  35. .fill('blue').setOpacity(0.3);
  36. paper.addShapes([rect, triangle, circle]);
  37. paper.addShapes([rect, triangle, circle].map(rbox));
  38. };
  39. </script>
  40. </head>
  41. <body>
  42. </body>
  43. </html>