aboutsummaryrefslogtreecommitdiff
path: root/contexts/data/lib/closure-library/closure/goog/demos/graphics/advancedcoordinates2.html
blob: f05323fe039d21622da3a46fd7da6e47b889b960 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<!DOCTYPE html>
<html>
<!--
Copyright 2007 The Closure Library Authors. All Rights Reserved.

Use of this source code is governed by the Apache License, Version 2.0.
See the COPYING file for details.
-->
<head>
  <title>Graphics Advanced Coordinates Demo Page -
    Using Percentage Based Surface Size</title>
  <style type="text/css">
    html, body {
      height: 100%;
    }
  </style>
  <script type="text/javascript" src="../../base.js"></script>
  <script type="text/javascript">
    goog.require('goog.dom');
    goog.require('goog.graphics');
    goog.require('goog.graphics.ext');
  </script>
</head>

<body>
<script type="text/javascript">
  var graphics = new goog.graphics.ext.Graphics('100%', '100%', 1000, 1000);
  graphics.setCoordOrigin(320, 0);

  var group = new goog.graphics.ext.Group(graphics);
  group.setLeft(20, true);
  group.setTop(20, true);
  group.setWidth(600, true);
  group.setHeight(200);

  // Basic shapes
  var fill = new goog.graphics.SolidFill('yellow');
  var stroke = new goog.graphics.Stroke(2, 'green');

  var bg = new goog.graphics.SolidFill('#eeeeee');
  var outline = new goog.graphics.Stroke(1, '#333333');

  var background = new goog.graphics.ext.Rectangle(group);
  background.setLeft(0, true);
  background.setTop(0, true);
  background.setWidth('100%', true);
  background.setHeight('100%');
  background.setStroke(outline);
  background.setFill(bg);

  var rect = new goog.graphics.ext.Rectangle(group);
  rect.setLeft('-5px', true);
  rect.setTop('-5px', true);
  rect.setWidth('10px', true);
  rect.setHeight('10px');
  rect.setStroke(stroke);
  rect.setFill(fill);

  rect = new goog.graphics.ext.Rectangle(group);
  rect.setRight('-5px', true);
  rect.setTop('-5px', true);
  rect.setWidth('10px', true);
  rect.setHeight('10px');
  rect.setStroke(stroke);
  rect.setFill(fill);

  rect = new goog.graphics.ext.Rectangle(group);
  rect.setRight('-5px', true);
  rect.setBottom('-5px', true);
  rect.setWidth('10px', true);
  rect.setHeight('10px');
  rect.setStroke(stroke);
  rect.setFill(fill);

  rect = new goog.graphics.ext.Rectangle(group);
  rect.setLeft('-5px', true);
  rect.setBottom('-5px', true);
  rect.setWidth('10px', true);
  rect.setHeight('10px');
  rect.setStroke(stroke);
  rect.setFill(fill);

  var image = new goog.graphics.ext.Image(group,
      'http://www.google.com/intl/en_ALL/images/logo.gif');
  image.setRight(10, true);
  image.setTop(10, true);
  image.setWidth('276px', true);
  image.setHeight('110px');

  var ellipse = new goog.graphics.ext.Ellipse(group);
  ellipse.setCenter(0, true);
  ellipse.setMiddle(0, true);
  ellipse.setWidth('10%', true);
  ellipse.setHeight('80%');
  ellipse.setStroke(stroke);
  ellipse.setFill(fill);

  ellipse = new goog.graphics.ext.Ellipse(group);
  ellipse.setCenter(0, true);
  ellipse.setMiddle(0, true);
  ellipse.setWidth(120, true);
  ellipse.setHeight(60);
  ellipse.setStroke(stroke);
  ellipse.setFill(fill);

  var path = new goog.graphics.ext.Path().moveTo(0, 0).lineTo(20, 0).
      lineTo(10, 20).close();

  var shape = new goog.graphics.ext.Shape(group, path);
  shape.setLeft(10, true);
  shape.setTop(10, true);
  shape.setWidth('10%', true);
  shape.setHeight('10%');
  shape.setStroke(stroke);
  shape.setFill(fill);

  shape = new goog.graphics.ext.Shape(group, path, true);
  shape.setLeft(40, true);
  shape.setTop(10, true);
  shape.setWidth('10%', true);
  shape.setHeight('10%');
  shape.setStroke(stroke);
  shape.setFill(fill);

  graphics.render(document.body);
</script>

</body>

</html>