advancedcoordinates2.html 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <!DOCTYPE html>
  2. <html>
  3. <!--
  4. Copyright 2007 The Closure Library Authors. All Rights Reserved.
  5. Use of this source code is governed by the Apache License, Version 2.0.
  6. See the COPYING file for details.
  7. -->
  8. <head>
  9. <title>Graphics Advanced Coordinates Demo Page -
  10. Using Percentage Based Surface Size</title>
  11. <style type="text/css">
  12. html, body {
  13. height: 100%;
  14. }
  15. </style>
  16. <script type="text/javascript" src="../../base.js"></script>
  17. <script type="text/javascript">
  18. goog.require('goog.dom');
  19. goog.require('goog.graphics');
  20. goog.require('goog.graphics.ext');
  21. </script>
  22. </head>
  23. <body>
  24. <script type="text/javascript">
  25. var graphics = new goog.graphics.ext.Graphics('100%', '100%', 1000, 1000);
  26. graphics.setCoordOrigin(320, 0);
  27. var group = new goog.graphics.ext.Group(graphics);
  28. group.setLeft(20, true);
  29. group.setTop(20, true);
  30. group.setWidth(600, true);
  31. group.setHeight(200);
  32. // Basic shapes
  33. var fill = new goog.graphics.SolidFill('yellow');
  34. var stroke = new goog.graphics.Stroke(2, 'green');
  35. var bg = new goog.graphics.SolidFill('#eeeeee');
  36. var outline = new goog.graphics.Stroke(1, '#333333');
  37. var background = new goog.graphics.ext.Rectangle(group);
  38. background.setLeft(0, true);
  39. background.setTop(0, true);
  40. background.setWidth('100%', true);
  41. background.setHeight('100%');
  42. background.setStroke(outline);
  43. background.setFill(bg);
  44. var rect = new goog.graphics.ext.Rectangle(group);
  45. rect.setLeft('-5px', true);
  46. rect.setTop('-5px', true);
  47. rect.setWidth('10px', true);
  48. rect.setHeight('10px');
  49. rect.setStroke(stroke);
  50. rect.setFill(fill);
  51. rect = new goog.graphics.ext.Rectangle(group);
  52. rect.setRight('-5px', true);
  53. rect.setTop('-5px', true);
  54. rect.setWidth('10px', true);
  55. rect.setHeight('10px');
  56. rect.setStroke(stroke);
  57. rect.setFill(fill);
  58. rect = new goog.graphics.ext.Rectangle(group);
  59. rect.setRight('-5px', true);
  60. rect.setBottom('-5px', true);
  61. rect.setWidth('10px', true);
  62. rect.setHeight('10px');
  63. rect.setStroke(stroke);
  64. rect.setFill(fill);
  65. rect = new goog.graphics.ext.Rectangle(group);
  66. rect.setLeft('-5px', true);
  67. rect.setBottom('-5px', true);
  68. rect.setWidth('10px', true);
  69. rect.setHeight('10px');
  70. rect.setStroke(stroke);
  71. rect.setFill(fill);
  72. var image = new goog.graphics.ext.Image(group,
  73. 'http://www.google.com/intl/en_ALL/images/logo.gif');
  74. image.setRight(10, true);
  75. image.setTop(10, true);
  76. image.setWidth('276px', true);
  77. image.setHeight('110px');
  78. var ellipse = new goog.graphics.ext.Ellipse(group);
  79. ellipse.setCenter(0, true);
  80. ellipse.setMiddle(0, true);
  81. ellipse.setWidth('10%', true);
  82. ellipse.setHeight('80%');
  83. ellipse.setStroke(stroke);
  84. ellipse.setFill(fill);
  85. ellipse = new goog.graphics.ext.Ellipse(group);
  86. ellipse.setCenter(0, true);
  87. ellipse.setMiddle(0, true);
  88. ellipse.setWidth(120, true);
  89. ellipse.setHeight(60);
  90. ellipse.setStroke(stroke);
  91. ellipse.setFill(fill);
  92. var path = new goog.graphics.ext.Path().moveTo(0, 0).lineTo(20, 0).
  93. lineTo(10, 20).close();
  94. var shape = new goog.graphics.ext.Shape(group, path);
  95. shape.setLeft(10, true);
  96. shape.setTop(10, true);
  97. shape.setWidth('10%', true);
  98. shape.setHeight('10%');
  99. shape.setStroke(stroke);
  100. shape.setFill(fill);
  101. shape = new goog.graphics.ext.Shape(group, path, true);
  102. shape.setLeft(40, true);
  103. shape.setTop(10, true);
  104. shape.setWidth('10%', true);
  105. shape.setHeight('10%');
  106. shape.setStroke(stroke);
  107. shape.setFill(fill);
  108. graphics.render(document.body);
  109. </script>
  110. </body>
  111. </html>