Fix d3.geo.circle Polygon exterior insertion.
This commit is contained in:
Родитель
18de5cd5c1
Коммит
0bb3d29539
|
@ -5634,12 +5634,11 @@
|
|||
}
|
||||
function clipLine(coordinates, context, winding) {
|
||||
if (!(n = coordinates.length)) return;
|
||||
var point0 = rotate(coordinates[0]), inside = visible(point0), keepWinding = inside && winding != null, n;
|
||||
var point0 = rotate(coordinates[0]), inside = visible(point0), keepWinding = winding != null, n;
|
||||
if (inside) context.moveTo(point0[0], point0[1]);
|
||||
for (var i = 1; i < n; i++) {
|
||||
var point1 = rotate(coordinates[i]), v = visible(point1);
|
||||
if (v !== inside) {
|
||||
keepWinding = false;
|
||||
if (inside = v) {
|
||||
point0 = intersect(point1, point0);
|
||||
context.moveTo(point0[0], point0[1]);
|
||||
|
|
Различия файлов скрыты, потому что одна или несколько строк слишком длинны
|
@ -163,14 +163,13 @@ function d3_geo_circleClip(degrees, rotate) {
|
|||
if (!(n = coordinates.length)) return;
|
||||
var point0 = rotate(coordinates[0]),
|
||||
inside = visible(point0),
|
||||
keepWinding = inside && winding != null,
|
||||
keepWinding = winding != null,
|
||||
n;
|
||||
if (inside) context.moveTo(point0[0], point0[1]);
|
||||
for (var i = 1; i < n; i++) {
|
||||
var point1 = rotate(coordinates[i]),
|
||||
v = visible(point1);
|
||||
if (v !== inside) {
|
||||
keepWinding = false;
|
||||
if (inside = v) {
|
||||
// outside going in
|
||||
point0 = intersect(point1, point0);
|
||||
|
|
|
@ -257,6 +257,18 @@ suite.addBatch({
|
|||
{type: "point", x: 170, y: 160},
|
||||
{type: "point", x: 170, y: 165}
|
||||
]);
|
||||
},
|
||||
"Polygon": {
|
||||
"inserts exterior along clip edge if polygon interior surrounds it": function(path) {
|
||||
path({type: "Polygon", coordinates: [[[80, -80], [80, 80], [-80, 80], [-80, -80], [80, -80]]]});
|
||||
var buffer = testContext.buffer();
|
||||
assert.equal(buffer.filter(function(d) { return d.type === "moveTo"; }).length, 2);
|
||||
},
|
||||
"inserts exterior along clip edge if polygon exterior surrounds it": function(path) {
|
||||
path({type: "Polygon", coordinates: [[[100, -80], [100, 80], [-100, 80], [-100, -80], [100, -80]]]});
|
||||
var buffer = testContext.buffer();
|
||||
assert.equal(buffer.filter(function(d) { return d.type === "moveTo"; }).length, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
Загрузка…
Ссылка в новой задаче