patternbrush.html 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>PatternBrush 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. paper.setWidth(400).setHeight(300);
  23. var rect = new kity.Rect(200, 100, 40, 40);
  24. rect.fill(new kity.PatternBrush().pipe( function() {
  25. var colors = ['red', 'blue', 'yellow', 'green'];
  26. this.setWidth(40);
  27. this.setHeight(40);
  28. this.addShapes([
  29. new kity.Circle(5, 10, 10).fill(colors.shift()),
  30. new kity.Circle(5, 30, 10).fill(colors.shift()),
  31. new kity.Circle(5, 10, 30).fill(colors.shift()),
  32. new kity.Circle(5, 30, 30).fill(colors.shift())
  33. ]);
  34. paper.addResource(this);
  35. }));
  36. paper.addShape(rect);
  37. };
  38. </script>
  39. </head>
  40. <body>
  41. </body>
  42. </html>