HTMLcopy
1
<div id="container"></div>
CSScopy
6
1
html, body, #container {
2
width: 100%;
3
height: 100%;
4
margin: 0;
5
padding: 0;
6
}
JavaScriptcopy
x
1
// create a stage
2
var stage = acgraph.create("container");
3
4
stage.scale(0.7, 0.7, 0, 0);
5
// set layers of stage
6
var layer_cube = stage.layer(); // layer for the cube
7
var layer_cylinder = stage.layer(); // layer for the cylinder
8
var layer_prism = stage.layer(); // layer for the hexagonal prism
9
var layer_main_shadow = stage.layer(); // layer for the big shadow under the figures
10
var layer_5 = stage.layer();
11
12
// creating the cube
13
14
var rect = acgraph.math.Rect(50, 250, 100, 200);
15
var fill = {keys:["#666","#888", "#ccc"], angle:135, mode:rect};
16
var rect_2 = acgraph.math.Rect(50, 200, 200, 100);
17
var fill_2 = {keys:["#666","#666", "#ccc"], angle:185, mode:rect_2};
18
19
var cube_top = layer_cube.path().moveTo(200, 200)
20
.lineTo(300, 250)
21
.lineTo(150, 300)
22
.lineTo(50, 250)
23
.close()
24
.fill(["#888", "#f0f0f0", "#f0f0f0"],150)
25
.stroke(fill_2,1);
26
27
var cube_side = layer_cube.path().moveTo(50, 250)
28
.lineTo(150, 300)
29
.lineTo(150, 450)
30
.lineTo(50, 400)
31
.close()
32
.fill(["#999","#f0f0f0", "white"], 135)
33
.stroke(fill,1);
34
35
var cube_back = layer_cube.path().moveTo(150, 300)
36
.lineTo(300, 250)
37
.lineTo(300, 400)
38
.lineTo(150, 450)
39
.close()
40
.fill("#aaa")
41
.stroke("1px #666");
42
43
layer_cube.zIndex(1);
44
45
// the shadow on a separate layer
46
var cube_shadow_prism = layer_5.path().moveTo(231, 365)
47
.lineTo(360, 315)
48
.lineTo(390, 325)
49
.lineTo(310, 355)
50
.lineTo(258, 375)
51
.close()
52
.moveTo(230,365)
53
.lineTo(200,400)
54
.lineTo(215,460)
55
.lineTo(255,480)
56
.lineTo(255,375)
57
.close()
58
.fill("#888")
59
.stroke("none");
60
61
var prism_shadow = layer_5.path().moveTo(445,415)
62
.lineTo(850,550)
63
.lineTo(410,550)
64
.lineTo(265,485)
65
.close()
66
.fill(["#aaa","#ccc 0.5","white 0"],-90)
67
.stroke(null);
68
69
layer_5.zIndex(5);
70
71
72
// creating the cylinder
73
var ellipse_top = layer_cylinder.ellipse(50,50,150,30)
74
.fill(["#f0f0f0", "#f0f0f0", "#aaa"],-30)
75
.zIndex(3);
76
77
var ellipse_body = layer_cylinder.path().moveTo(-100, 50)
78
.lineTo(-100, 350)
79
.arcTo(150, 30, 180, -180)
80
.lineTo(200, 50)
81
.arcTo(-150, 30, 180, 180)
82
.close()
83
.fill(["white", "#aaa", "#888"],-40)
84
.stroke("1px black")
85
.zIndex(2);
86
87
var ellipse_shadow_cube = layer_cylinder.path().moveTo(-45,375)
88
.lineTo(110,405)
89
.lineTo(315,373)
90
.lineTo(200,350)
91
.close()
92
.stroke(null)
93
.fill("#848484");
94
95
96
var ellipse_shadow_prism_top = layer_cylinder.path().moveTo(520,485)
97
.lineTo(680,517)
98
.lineTo(465,558)
99
.lineTo(300,523)
100
.fill("#888")
101
.stroke(null)
102
.close();
103
104
var ellipse_shadow_prism_middle = layer_cylinder.path().moveTo(680,520)
105
.lineTo(750,592)
106
.lineTo(515,640)
107
.lineTo(465,560)
108
.fill("#898989")
109
.stroke(null)
110
.close();
111
112
// moving the cylinder
113
layer_cylinder.translate(650,50);
114
115
// scaling the cylinder
116
layer_cylinder.scale(0.3, 0.6, 0, 0);
117
118
layer_cylinder.zIndex(3);
119
120
121
// creating the prism
122
123
var prism_hex_edge = layer_prism.path().moveTo(200,400)
124
.lineTo(215,460)
125
.lineTo(265,485)
126
.lineTo(300,435)
127
.lineTo(285,385)
128
.lineTo(230,365)
129
.close()
130
.stroke("1px #444")
131
.fill("#aaa");
132
133
var prism_top_edge = layer_prism.path().moveTo(230,365)
134
.lineTo(400,300)
135
.lineTo(455,320)
136
.lineTo(285,385)
137
.stroke("1px #666")
138
.fill("#aaa")
139
.close();
140
141
var prism_middle_edge = layer_prism.path().moveTo(285,385)
142
.lineTo(300,435)
143
.lineTo(470,365)
144
.stroke("1px #666")
145
.lineTo(455,320)
146
.close()
147
.fill("#929292");
148
149
var prism_bottom_edge = layer_prism.path().moveTo(300,435)
150
.lineTo(470,365)
151
.lineTo(445,415)
152
.lineTo(265,485)
153
.stroke("1px #777")
154
.close()
155
.fill("#848484");
156
157
layer_prism.zIndex(1);
158
159
160
// creating the big shadow under everything
161
layer_main_shadow.path().moveTo(50,400)
162
.lineTo(445,415)
163
.lineTo(850,550)
164
.lineTo(350,550)
165
.close()
166
.stroke(null)
167
.fill(["#aaa","white"],270);
168
169
// remove the cylinder layer
170
layer_cylinder.remove();