-
Notifications
You must be signed in to change notification settings - Fork 1.6k
/
issue-689-spec.js
116 lines (110 loc) · 3.75 KB
/
issue-689-spec.js
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
const expect = require('chai').expect;
const Coord = require('@antv/coord/lib/index');
describe('#689 极坐标图形在画布内', () => {
it('锐角扇形 宽画布', () => {
const width = 800;
const height = 400;
const startAngle = Math.PI * (8 / 6);
const endAngle = Math.PI * (10 / 6);
const coord = new Coord.Polar({
start: { x: 0, y: height },
end: { x: width, y: 0 },
startAngle,
endAngle
});
for (let i = startAngle; i <= endAngle; i += Math.PI / 180) {
const point = {
x: Math.cos(i) * coord.radius + coord.center.x,
y: Math.sin(i) * coord.radius + coord.center.y
};
expect(point.x >= 0 && point.x <= width).to.be.true;
expect(point.y >= 0 && point.y <= height).to.be.true;
}
expect(coord.center.y >= 0 && coord.center.y <= height).to.be.true;
expect(coord.center.x >= 0 && coord.center.x <= width).to.be.true;
});
it('锐角扇形 宽画布 反向', () => {
const width = 800;
const height = 400;
const startAngle = Math.PI * (10 / 6);
const endAngle = Math.PI * (8 / 6);
const coord = new Coord.Polar({
start: { x: 0, y: height },
end: { x: width, y: 0 },
startAngle,
endAngle
});
for (let i = startAngle; i <= endAngle; i += Math.PI / 180) {
const point = {
x: Math.cos(i) * coord.radius + coord.center.x,
y: Math.sin(i) * coord.radius + coord.center.y
};
expect(point.x >= 0 && point.x <= width).to.be.true;
expect(point.y >= 0 && point.y <= height).to.be.true;
}
expect(coord.center.y >= 0 && coord.center.y <= height).to.be.true;
expect(coord.center.x >= 0 && coord.center.x <= width).to.be.true;
});
it('锐角扇形 高画布', () => {
const width = 400;
const height = 800;
const startAngle = Math.PI * (7 / 6);
const endAngle = Math.PI * (8 / 6);
const coord = new Coord.Polar({
start: { x: 0, y: height },
end: { x: width, y: 0 },
startAngle,
endAngle
});
for (let i = startAngle; i <= endAngle; i += Math.PI / 180) {
const point = {
x: Math.cos(i) * coord.radius + coord.center.x,
y: Math.sin(i) * coord.radius + coord.center.y
};
expect(point.x >= 0 && point.x <= width).to.be.true;
expect(point.y >= 0 && point.y <= height).to.be.true;
}
expect(coord.center.y >= 0 && coord.center.y <= height).to.be.true;
expect(coord.center.x >= 0 && coord.center.x <= width).to.be.true;
});
it('钝角扇形 宽画布', () => {
const width = 800;
const height = 400;
const startAngle = Math.PI * (5 / 6);
const endAngle = Math.PI * (15 / 6);
const coord = new Coord.Polar({
start: { x: 0, y: height },
end: { x: width, y: 0 },
startAngle,
endAngle
});
for (let i = startAngle; i <= endAngle; i += Math.PI / 180) {
const point = {
x: Math.cos(i) * coord.radius + coord.center.x,
y: Math.sin(i) * coord.radius + coord.center.y
};
expect(point.x >= 0 && point.x <= width).to.be.true;
expect(point.y >= 0 && point.y <= height).to.be.true;
}
});
it('钝角扇形 高画布', () => {
const width = 400;
const height = 800;
const startAngle = Math.PI * (1 / 6);
const endAngle = Math.PI * (12 / 6);
const coord = new Coord.Polar({
start: { x: 0, y: height },
end: { x: width, y: 0 },
startAngle,
endAngle
});
for (let i = startAngle; i <= endAngle; i += Math.PI / 180) {
const point = {
x: Math.cos(i) * coord.radius + coord.center.x,
y: Math.sin(i) * coord.radius + coord.center.y
};
expect(point.x >= 0 && point.x <= width).to.be.true;
expect(point.y >= 0 && point.y <= height).to.be.true;
}
});
});