Fix d3.geo.circle Polygon exterior insertion.

This commit is contained in:
Jason Davies 2012-11-14 13:07:19 +00:00
Родитель 18de5cd5c1
Коммит 0bb3d29539
4 изменённых файлов: 15 добавлений и 5 удалений

3
d3.js поставляемый
Просмотреть файл

@ -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]);

2
d3.min.js поставляемый

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Просмотреть файл

@ -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);
}
}
}
},