Skip to content

Commit

Permalink
Merge branch 'clip-extent'
Browse files Browse the repository at this point in the history
  • Loading branch information
mbostock committed Mar 21, 2013
2 parents 51228cc + 3de9ef3 commit b9e35eb
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 20 deletions.
2 changes: 1 addition & 1 deletion component.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "d3",
"version": "3.1.0",
"version": "3.1.1",
"main": "./d3.js"
}
10 changes: 4 additions & 6 deletions d3.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
d3 = function() {
var d3 = {
version: "3.1.0"
version: "3.1.1"
};
if (!Date.now) Date.now = function() {
return +new Date();
Expand Down Expand Up @@ -2642,7 +2642,7 @@ d3 = function() {
return code;
}
}
var d3_geo_clipViewMAX = 1e15;
var d3_geo_clipViewMAX = 1e9;
function d3_geo_clipView(x0, y0, x1, y1) {
return function(listener) {
var listener_ = listener, bufferListener = d3_geo_clipBufferListener(), segments, polygon, ring;
Expand Down Expand Up @@ -2725,6 +2725,8 @@ d3 = function() {
if (v_) listener.lineEnd();
}
function linePoint(x, y) {
x = Math.max(-d3_geo_clipViewMAX, Math.min(d3_geo_clipViewMAX, x));
y = Math.max(-d3_geo_clipViewMAX, Math.min(d3_geo_clipViewMAX, y));
var v = visible(x, y);
if (polygon) ring.push([ x, y ]);
if (first) {
Expand Down Expand Up @@ -2765,10 +2767,6 @@ d3 = function() {
return ca !== cb ? ca - cb : ca === 0 ? b[1] - a[1] : ca === 1 ? a[0] - b[0] : ca === 2 ? a[1] - b[1] : b[0] - a[0];
}
function clipLine(a, b) {
a[0] = Math.max(-d3_geo_clipViewMAX, Math.min(d3_geo_clipViewMAX, a[0]));
a[1] = Math.max(-d3_geo_clipViewMAX, Math.min(d3_geo_clipViewMAX, a[1]));
b[0] = Math.max(-d3_geo_clipViewMAX, Math.min(d3_geo_clipViewMAX, b[0]));
b[1] = Math.max(-d3_geo_clipViewMAX, Math.min(d3_geo_clipViewMAX, b[1]));
var dx = b[0] - a[0], dy = b[1] - a[1], t = [ 0, 1 ];
if (Math.abs(dx) < ε && Math.abs(dy) < ε) return x0 <= a[0] && a[0] <= x1 && y0 <= a[1] && a[1] <= y1;
if (d3_geo_clipViewT(x0 - a[0], dx, t) && d3_geo_clipViewT(a[0] - x1, -dx, t) && d3_geo_clipViewT(y0 - a[1], dy, t) && d3_geo_clipViewT(a[1] - y1, -dy, t)) {
Expand Down
10 changes: 5 additions & 5 deletions d3.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "d3",
"version": "3.1.0",
"version": "3.1.1",
"description": "A small, free JavaScript library for manipulating documents based on data.",
"keywords": [
"dom",
Expand Down
9 changes: 3 additions & 6 deletions src/geo/clip-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import "../math/trigonometry";
import "clip";
import "clip-polygon";

var d3_geo_clipViewMAX = 1e15;
var d3_geo_clipViewMAX = 1e9;

function d3_geo_clipView(x0, y0, x1, y1) {
return function(listener) {
Expand Down Expand Up @@ -113,6 +113,8 @@ function d3_geo_clipView(x0, y0, x1, y1) {
}

function linePoint(x, y) {
x = Math.max(-d3_geo_clipViewMAX, Math.min(d3_geo_clipViewMAX, x));
y = Math.max(-d3_geo_clipViewMAX, Math.min(d3_geo_clipViewMAX, y));
var v = visible(x, y);
if (polygon) ring.push([x, y]);
if (first) {
Expand Down Expand Up @@ -169,11 +171,6 @@ function d3_geo_clipView(x0, y0, x1, y1) {

// Liang–Barsky line clipping.
function clipLine(a, b) {
a[0] = Math.max(-d3_geo_clipViewMAX, Math.min(d3_geo_clipViewMAX, a[0]));
a[1] = Math.max(-d3_geo_clipViewMAX, Math.min(d3_geo_clipViewMAX, a[1]));
b[0] = Math.max(-d3_geo_clipViewMAX, Math.min(d3_geo_clipViewMAX, b[0]));
b[1] = Math.max(-d3_geo_clipViewMAX, Math.min(d3_geo_clipViewMAX, b[1]));

var dx = b[0] - a[0],
dy = b[1] - a[1],
t = [0, 1];
Expand Down
2 changes: 1 addition & 1 deletion src/start.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
d3 = (function(){
var d3 = {version: "3.1.0"}; // semver
var d3 = {version: "3.1.1"}; // semver

0 comments on commit b9e35eb

Please sign in to comment.