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
var stage = acgraph.create("container");
2
3
// circle path
4
var circlePath = stage.path();
5
circlePath.circularArc(100, 100, 50, 50, 0, 360);
6
7
// set the text
8
text = stage.text(0,0,"This is my custom text nicely curved along the circle.");
9
// set path
10
text.path(circlePath);
11
text.fontSize("11px");
12
13
// create a complex Spiral
14
var curvePath = stage.path();
15
16
var radius = 0;
17
var angle = 0;
18
cx = 280;
19
cy = 100;
20
curvePath.moveTo(cx, cy);
21
22
for (var n = 0; n < 150; n++) {
23
radius += 0.55;
24
angle += (Math.PI * 2) / 50;
25
x = cx + radius * Math.cos(angle);
26
y = cy + radius * Math.sin(angle);
27
curvePath.lineTo(x, y);
28
}
29
30
// set the text
31
text1 = stage.text(0,0,"This is my custom text nicely curved along the curve named spiral, it resembles a snail.");
32
// set path
33
text1.path(curvePath);
34
text1.fontSize("11px");
35
36
// circle path
37
var rectPath = stage.path();
38
rectPath.moveTo(420, 50)
39
.lineTo(585, 50)
40
.lineTo(585, 150)
41
.lineTo(420, 150)
42
.lineTo(420, 50);
43
44
// set the text
45
text = stage.text(0,0,"This is my custom text put around a rectangle. Can something be around a rectangle?");
46
// set path
47
text.path(rectPath);
48
text.fontSize("12px");