_text.html 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>Text</title>
  5. <script src="../dev-lib/sea.js"></script>
  6. <script>
  7. seajs.config({
  8. base: '../src'
  9. });
  10. define('start', function (require) {
  11. var Paper = require('graphic/paper');
  12. var Rect = require('graphic/rect');
  13. var Group = require('graphic/group');
  14. var Color = require('graphic/color');
  15. var Text = require('graphic/text');
  16. var Circle = require('graphic/circle');
  17. var utils = require('core/utils');
  18. var paper = new Paper(document.body);
  19. window.t = new Text();
  20. paper.addShape(t);
  21. var rb = new Rect().stroke('red');
  22. paper.addShape(rb);
  23. window.p = new Circle(1).fill('#00ff00');
  24. paper.addShape(p);
  25. setInterval(function() {
  26. var box = t.getRenderBox('top');
  27. rb.setPosition(box.x, box.y).setSize(box.width, box.height);
  28. }, 15);
  29. t.setContent('this is a test').translate(100, 100);
  30. p.translate(100, 100);
  31. });
  32. seajs.use('start');
  33. </script>
  34. <style>
  35. body, div, html {
  36. margin: 0;
  37. padding: 0;
  38. overflow: hidden;
  39. background: #333;
  40. }
  41. </style>
  42. </head>
  43. <body>
  44. </body>
  45. </html>