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