Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

js.d3_cloud

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

js.d3_cloud - pypi Package Compare versions

Comparing version
1.0.1
to
1.1.2
+8
-0
CHANGES.rst
CHANGES
*******
1.1.2 (2015-07-13)
==================
- Change to using iLanguage's fork of d3-cloud because it's now being
maintained. This adds numerous features and fixes. See
https://github.com/iLanguage/d3-cloud.
[davidjb]
1.0.1 (2012-12-21)

@@ -5,0 +13,0 @@ ==================

+14
-6
Metadata-Version: 1.0
Name: js.d3-cloud
Version: 1.0.1
Version: 1.1.2
Summary: Fanstatic packaging of D3 Word Cloud Layout

@@ -18,3 +18,3 @@ Home-page: https://github.com/davidjb/js.d3_cloud

.. _`fanstatic`: http://fanstatic.org
.. _`D3 Word Cloud Layout`: https://github.com/jasondavies/d3-cloud
.. _`D3 Word Cloud Layout`: https://github.com/iLanguage/d3-cloud

@@ -42,3 +42,3 @@ This requires integration between your web framework and ``fanstatic``,

This process requires installation of the package for development - the
suggested method to do this is via the `Buildout` within this package:
suggested method to do this is via the `Buildout` within this package::

@@ -53,7 +53,7 @@ cd js.d3_cloud

In order to obtain a newer version of of this library, do the following::
In order to obtain a newer version of this library, do the following::
pushd js/d3_cloud/resources
wget https://github.com/jasondavies/d3-cloud/raw/master/d3.layout.cloud.js -O d3.layout.cloud.js
wget https://github.com/jasondavies/d3-cloud/raw/master/LICENSE -O LICENSE
wget https://github.com/iLanguage/d3-cloud/raw/master/src/d3.layout.cloud.js -O d3.layout.cloud.js
wget https://github.com/iLanguage/d3-cloud/raw/master/LICENSE -O LICENSE
popd

@@ -81,2 +81,10 @@ #Edit changelog, setup.py for versions, etc

1.1.2 (2015-07-13)
==================
- Change to using iLanguage's fork of d3-cloud because it's now being
maintained. This adds numerous features and fixes. See
https://github.com/iLanguage/d3-cloud.
[davidjb]
1.0.1 (2012-12-21)

@@ -83,0 +91,0 @@ ==================

fanstatic
setuptools
js.d3
js.d3>=3.0
from fanstatic import Library, Resource
from js.d3 import d3
library = Library('d3_word_cloud', 'resources')
d3_cloud = Resource(library, 'd3.layout.cloud.js',
minified='d3.layout.cloud.min.js',
depends=(d3,)
)
library = Library(
'd3_word_cloud',
'resources'
)
d3_cloud = Resource(
library,
'd3.layout.cloud.js',
minified='d3.layout.cloud.min.js',
depends=(d3,),
)
// Word cloud layout by Jason Davies, http://www.jasondavies.com/word-cloud/
// Algorithm due to Jonathan Feinberg, http://static.mrfeinberg.com/bv_ch03.pdf
(function(exports) {
function cloud() {
var size = [256, 256],
text = cloudText,
font = cloudFont,
fontSize = cloudFontSize,
fontStyle = cloudFontNormal,
fontWeight = cloudFontNormal,
rotate = cloudRotate,
padding = cloudPadding,
spiral = archimedeanSpiral,
words = [],
timeInterval = Infinity,
event = d3.dispatch("word", "end"),
timer = null,
cloud = {};
(function() {
if (typeof define === "function" && define.amd) define(["d3"], cloud);
else cloud(this.d3);
function cloud(d3) {
var random = Math.random;
d3.layout.cloud = function cloud() {
var DEFAULT_WIDTH = 256,
DEFAULT_HEIGHT = 256,
size = [DEFAULT_WIDTH, DEFAULT_HEIGHT],
startPoint = null,
text = cloudText,
font = cloudFont,
fontSize = cloudFontSize,
fontStyle = cloudFontNormal,
fontWeight = cloudFontNormal,
rotate = cloudRotate,
padding = cloudPadding,
spiral = archimedeanSpiral,
words = [],
timeInterval = Infinity,
event = d3.dispatch("word", "end"),
timer = null,
overflow = false,
cloud = {};
cloud.start = function() {
var board = zeroArray((size[0] >> 5) * size[1]),
bounds = null,
n = words.length,
i = -1,
tags = [],
data = words.map(function(d, i) {
return {
text: text.call(this, d, i),
font: font.call(this, d, i),
style: fontStyle.call(this, d, i),
weight: fontWeight.call(this, d, i),
rotate: rotate.call(this, d, i),
size: ~~fontSize.call(this, d, i),
padding: cloudPadding.call(this, d, i)
};
}).sort(function(a, b) { return b.size - a.size; });
bounds = null,
n = words.length,
i = -1,
tags = [],
data = words.map(function(d, i) {
d.text = text.call(this, d, i);
d.font = font.call(this, d, i);
d.style = fontStyle.call(this, d, i);
d.weight = fontWeight.call(this, d, i);
d.rotate = rotate.call(this, d, i);
d.size = ~~fontSize.call(this, d, i);
d.padding = padding.call(this, d, i);
return d;
}).sort(function(a, b) {
return b.size - a.size;
});

@@ -45,17 +55,45 @@ if (timer) clearInterval(timer);

function step() {
var start = +new Date,
d;
while (+new Date - start < timeInterval && ++i < n && timer) {
d = data[i];
d.x = (size[0] * (Math.random() + .5)) >> 1;
d.y = (size[1] * (Math.random() + .5)) >> 1;
var start = Date.now(),
x, y, nsi;
while (Date.now() - start < timeInterval && ++i < n && timer) {
var d = data[i];
if (startPoint) {
x = d.x = startPoint[0];
y = d.y = startPoint[1];
} else {
x = d.x = (size[0] * (random() + 0.5)) >> 1;
y = d.y = (size[1] * (random() + 0.5)) >> 1;
}
nsi = i + 1;
cloudSprite(d, data, i);
if (place(board, d, bounds)) {
tags.push(d);
event.word(d);
if (bounds) cloudBounds(bounds, d);
else bounds = [{x: d.x + d.x0, y: d.y + d.y0}, {x: d.x + d.x1, y: d.y + d.y1}];
// Temporary hack
d.x -= size[0] >> 1;
d.y -= size[1] >> 1;
while (d.hasText) {
if (place(board, d, bounds)) {
tags.push(d);
event.word(d);
if (bounds) cloudBounds(bounds, d);
else bounds = [{
x: d.x + d.x0,
y: d.y + d.y0
}, {
x: d.x + d.x1,
y: d.y + d.y1
}];
// Temporary hack
d.x -= size[0] >> 1;
d.y -= size[1] >> 1;
break;
} else {
// reset
delete d.sprite;
d.sprite = null;
d.x = x;
d.y = y;
// decrement the size until it fits
d.size = nsi < data.length ? data[nsi++].size : d.size - (d.size >> 3);
if (~~d.size > 0) {
cloudSprite(d, data, i);
} else {
d.hasText = false;
}
}
}

@@ -68,3 +106,3 @@ }

}
}
};

@@ -79,19 +117,19 @@ cloud.stop = function() {

cloud.timeInterval = function(x) {
if (!arguments.length) return timeInterval;
timeInterval = x == null ? Infinity : x;
return cloud;
};
function place(board, tag, bounds) {
var perimeter = [{x: 0, y: 0}, {x: size[0], y: size[1]}],
startX = tag.x,
startY = tag.y,
maxDelta = Math.sqrt(size[0] * size[0] + size[1] * size[1]),
s = spiral(size),
dt = Math.random() < .5 ? 1 : -1,
t = -dt,
dxdy,
dx,
dy;
var perimeter = [{
x: 0,
y: 0
}, {
x: size[0],
y: size[1]
}],
startX = tag.x,
startY = tag.y,
maxDelta = Math.sqrt(size[0] * size[0] + size[1] * size[1]),
s = spiral(size),
dt = random() < 0.5 ? 1 : -1,
t = -dt,
dxdy,
dx,
dy;

@@ -102,3 +140,3 @@ while (dxdy = s(t += dt)) {

if (Math.min(dx, dy) > maxDelta) break;
if (Math.min(Math.abs(dx), Math.abs(dy)) >= maxDelta) break;

@@ -109,3 +147,7 @@ tag.x = startX + dx;

if (tag.x + tag.x0 < 0 || tag.y + tag.y0 < 0 ||
tag.x + tag.x1 > size[0] || tag.y + tag.y1 > size[1]) continue;
tag.x + tag.x1 > size[0] || tag.y + tag.y1 > size[1]) {
if (!overflow) {
continue;
}
}
// TODO only check for collisions within current bounds.

@@ -115,10 +157,10 @@ if (!bounds || !cloudCollide(tag, board, size[0])) {

var sprite = tag.sprite,
w = tag.width >> 5,
sw = size[0] >> 5,
lx = tag.x - (w << 4),
sx = lx & 0x7f,
msx = 32 - sx,
h = tag.y1 - tag.y0,
x = (tag.y + tag.y0) * sw + (lx >> 5),
last;
w = tag.width >> 5,
sw = size[0] >> 5,
lx = tag.x - (w << 4),
sx = lx & 0x7f,
msx = 32 - sx,
h = tag.y1 - tag.y0,
x = (tag.y + tag.y0) * sw + (lx >> 5),
last;
for (var j = 0; j < h; j++) {

@@ -139,59 +181,62 @@ last = 0;

cloud.words = function(x) {
if (!arguments.length) return words;
words = x;
return cloud;
cloud.timeInterval = function(_) {
return arguments.length ? (timeInterval = _ === null ? Infinity : _, cloud) : timeInterval;
};
cloud.size = function(x) {
cloud.words = function(_) {
return arguments.length ? (words = _, cloud) : words;
};
cloud.size = function(_) {
if (!arguments.length) return size;
size = [+x[0], +x[1]];
return cloud;
if (!_[0] || _[0] < 0) _[0] = DEFAULT_WIDTH;
if (!_[1] || _[1] < 1) _[1] = DEFAULT_HEIGHT;
return arguments.length ? (size = [+_[0], +_[1]], cloud) : size;
};
cloud.font = function(x) {
if (!arguments.length) return font;
font = d3.functor(x);
return cloud;
cloud.font = function(_) {
return arguments.length ? (font = d3.functor(_), cloud) : font;
};
cloud.fontStyle = function(x) {
if (!arguments.length) return fontStyle;
fontStyle = d3.functor(x);
return cloud;
cloud.fontStyle = function(_) {
return arguments.length ? (fontStyle = d3.functor(_), cloud) : fontStyle;
};
cloud.fontWeight = function(x) {
if (!arguments.length) return fontWeight;
fontWeight = d3.functor(x);
return cloud;
cloud.fontWeight = function(_) {
return arguments.length ? (fontWeight = d3.functor(_), cloud) : fontWeight;
};
cloud.rotate = function(x) {
if (!arguments.length) return rotate;
rotate = d3.functor(x);
return cloud;
cloud.rotate = function(_) {
return arguments.length ? (rotate = d3.functor(_), cloud) : rotate;
};
cloud.text = function(x) {
if (!arguments.length) return text;
text = d3.functor(x);
return cloud;
cloud.text = function(_) {
return arguments.length ? (text = d3.functor(_), cloud) : text;
};
cloud.spiral = function(x) {
if (!arguments.length) return spiral;
spiral = spirals[x + ""] || x;
return cloud;
cloud.spiral = function(_) {
return arguments.length ? (spiral = spirals[_] || _, cloud) : spiral;
};
cloud.fontSize = function(x) {
if (!arguments.length) return fontSize;
fontSize = d3.functor(x);
cloud.fontSize = function(_) {
return arguments.length ? (fontSize = d3.functor(_), cloud) : fontSize;
};
cloud.padding = function(_) {
return arguments.length ? (padding = d3.functor(_), cloud) : padding;
};
cloud.random = function(_) {
return arguments.length ? (random = _, cloud) : random;
};
cloud.startPoint = function(x) {
if (!arguments.length) return startPoint;
startPoint = [+x[0], +x[1]];
return cloud;
};
cloud.padding = function(x) {
if (!arguments.length) return padding;
padding = d3.functor(x);
cloud.overflow = function(x) {
if (!arguments.length) return overflow;
overflow = d3.functor(x);
return cloud;

@@ -201,3 +246,3 @@ };

return d3.rebind(cloud, event, "on");
}
};

@@ -221,3 +266,3 @@ function cloudText(d) {

function cloudRotate() {
return (~~(Math.random() * 6) - 3) * 30;
return (~~(random() * 6) - 3) * 30;
}

@@ -235,6 +280,6 @@

var x = 0,
y = 0,
maxh = 0,
n = data.length;
di--;
y = 0,
maxh = 0,
n = data.length;
--di;
while (++di < n) {

@@ -245,10 +290,10 @@ d = data[di];

var w = c.measureText(d.text + "m").width * ratio,
h = d.size << 1;
h = d.size << 1;
if (d.rotate) {
var sr = Math.sin(d.rotate * cloudRadians),
cr = Math.cos(d.rotate * cloudRadians),
wcr = w * cr,
wsr = w * sr,
hcr = h * cr,
hsr = h * sr;
cr = Math.cos(d.rotate * cloudRadians),
wcr = w * cr,
wsr = w * sr,
hcr = h * cr,
hsr = h * sr;
w = (Math.max(Math.abs(wcr + hsr), Math.abs(wcr - hsr)) + 0x1f) >> 5 << 5;

@@ -269,2 +314,3 @@ h = ~~Math.max(Math.abs(wsr + hcr), Math.abs(wsr - hcr));

c.fillText(d.text, 0, 0);
if (d.padding) c.lineWidth = 2 * d.padding, c.strokeText(d.text, 0, 0);
c.restore();

@@ -279,28 +325,24 @@ d.width = w;

d.y0 = -d.y1;
d.hasText = true;
x += w;
}
var pixels = c.getImageData(0, 0, (cw << 5) / ratio, ch / ratio).data,
sprite = [];
sprite = [];
while (--di >= 0) {
d = data[di];
if (!d.hasText) continue;
var w = d.width,
w32 = w >> 5,
h = d.y1 - d.y0,
p = d.padding;
w32 = w >> 5,
h = d.y1 - d.y0;
// Zero the buffer
for (var i = 0; i < h * w32; i++) sprite[i] = 0;
x = d.xoff;
if (x == null) return;
if (x === null) return;
y = d.yoff;
var seen = 0,
seenRow = -1;
seenRow = -1;
for (var j = 0; j < h; j++) {
for (var i = 0; i < w; i++) {
var k = w32 * j + (i >> 5),
m = pixels[((y + j) * (cw << 5) + (x + i)) << 2] ? 1 << (31 - (i % 32)) : 0;
if (p) {
if (j) sprite[k - w32] |= m;
if (j < w - 1) sprite[k + w32] |= m;
m |= (m << 1) | (m >> 1);
}
m = pixels[((y + j) * (cw << 5) + (x + i)) << 2] ? 1 << (31 - (i % 32)) : 0;
sprite[k] |= m;

@@ -326,14 +368,13 @@ seen |= m;

var sprite = tag.sprite,
w = tag.width >> 5,
lx = tag.x - (w << 4),
sx = lx & 0x7f,
msx = 32 - sx,
h = tag.y1 - tag.y0,
x = (tag.y + tag.y0) * sw + (lx >> 5),
last;
w = tag.width >> 5,
lx = tag.x - (w << 4),
sx = lx & 0x7f,
msx = 32 - sx,
h = tag.y1 - tag.y0,
x = (tag.y + tag.y0) * sw + (lx >> 5),
last;
for (var j = 0; j < h; j++) {
last = 0;
for (var i = 0; i <= w; i++) {
if (((last << msx) | (i < w ? (last = sprite[j * w + i]) >>> sx : 0))
& board[x + i]) return true;
if (((last << msx) | (i < w ? (last = sprite[j * w + i]) >>> sx : 0)) & board[x + i]) return true;
}

@@ -347,3 +388,3 @@ x += sw;

var b0 = bounds[0],
b1 = bounds[1];
b1 = bounds[1];
if (d.x + d.x0 < b0.x) b0.x = d.x + d.x0;

@@ -362,3 +403,3 @@ if (d.y + d.y0 < b0.y) b0.y = d.y + d.y0;

return function(t) {
return [e * (t *= .1) * Math.cos(t), t * Math.sin(t)];
return [e * (t *= 0.1) * Math.cos(t), t * Math.sin(t)];
};

@@ -369,5 +410,5 @@ }

var dy = 4,
dx = dy * size[0] / size[1],
x = 0,
y = 0;
dx = dy * size[0] / size[1],
x = 0,
y = 0;
return function(t) {

@@ -377,6 +418,14 @@ var sign = t < 0 ? -1 : 1;

switch ((Math.sqrt(1 + 4 * sign * t) - sign) & 3) {
case 0: x += dx; break;
case 1: y += dy; break;
case 2: x -= dx; break;
default: y -= dy; break;
case 0:
x += dx;
break;
case 1:
y += dy;
break;
case 2:
x -= dx;
break;
default:
y -= dy;
break;
}

@@ -390,3 +439,3 @@ return [x, y];

var a = [],
i = -1;
i = -1;
while (++i < n) a[i] = 0;

@@ -397,6 +446,6 @@ return a;

var cloudRadians = Math.PI / 180,
cw = 1 << 11 >> 5,
ch = 1 << 11,
canvas,
ratio = 1;
cw = 1 << 11 >> 5,
ch = 1 << 11,
canvas,
ratio = 1;

@@ -410,5 +459,4 @@ if (typeof document !== "undefined") {

canvas.height = ch / ratio;
} else {
// node-canvas support
var Canvas = require("canvas");
} else if (!!Canvas) {
// Attempt to use node-canvas.
canvas = new Canvas(cw << 5, ch);

@@ -418,10 +466,10 @@ }

var c = canvas.getContext("2d"),
spirals = {
archimedean: archimedeanSpiral,
rectangular: rectangularSpiral
};
c.fillStyle = "red";
spirals = {
archimedean: archimedeanSpiral,
rectangular: rectangularSpiral
};
c.fillStyle = c.strokeStyle = "red";
c.textAlign = "center";
exports.cloud = cloud;
})(typeof exports === "undefined" ? d3.layout || (d3.layout = {}) : exports);
}
})();

@@ -1,1 +0,1 @@

(function(x){function g(){var L=[256,256],J=r,z=s,K=b,C=k,H=k,D=t,I=n,E=u,G=[],F=Infinity,c=d3.dispatch("word","end"),y=null,A={};A.start=function(){var O=m((L[0]>>5)*L[1]),Q=null,S=G.length,N=-1,M=[],R=G.map(function(U,T){return{text:J.call(this,U,T),font:z.call(this,U,T),style:C.call(this,U,T),weight:H.call(this,U,T),rotate:D.call(this,U,T),size:~~K.call(this,U,T),padding:n.call(this,U,T)}}).sort(function(U,T){return T.size-U.size});if(y){clearInterval(y)}y=setInterval(P,0);P();return A;function P(){var U=+new Date,T;while(+new Date-U<F&&++N<S&&y){T=R[N];T.x=(L[0]*(Math.random()+0.5))>>1;T.y=(L[1]*(Math.random()+0.5))>>1;q(T,R,N);if(B(O,T,Q)){M.push(T);c.word(T);if(Q){i(Q,T)}else{Q=[{x:T.x+T.x0,y:T.y+T.y0},{x:T.x+T.x1,y:T.y+T.y1}]}T.x-=L[0]>>1;T.y-=L[1]>>1}}if(N>=S){A.stop();c.end(M,Q)}}};A.stop=function(){if(y){clearInterval(y);y=null}return A};A.timeInterval=function(M){if(!arguments.length){return F}F=M==null?Infinity:M;return A};function B(Q,aj,P){var N=[{x:0,y:0},{x:L[0],y:L[1]}],ah=aj.x,ag=aj.y,M=Math.sqrt(L[0]*L[0]+L[1]*L[1]),X=E(L),Y=Math.random()<0.5?1:-1,W=-Y,ad,V,T;while(ad=X(W+=Y)){V=~~ad[0];T=~~ad[1];if(Math.min(V,T)>M){break}aj.x=ah+V;aj.y=ag+T;if(aj.x+aj.x0<0||aj.y+aj.y0<0||aj.x+aj.x1>L[0]||aj.y+aj.y1>L[1]){continue}if(!P||!j(aj,Q,L[0])){if(!P||f(aj,P)){var ab=aj.sprite,U=aj.width>>5,aa=L[0]>>5,O=aj.x-(U<<4),Z=O&127,ai=32-Z,af=aj.y1-aj.y0,S=(aj.y+aj.y0)*aa+(O>>5),R;for(var ac=0;ac<af;ac++){R=0;for(var ae=0;ae<=U;ae++){Q[S+ae]|=(R<<ai)|(ae<U?(R=ab[ac*U+ae])>>>Z:0)}S+=aa}delete aj.sprite;return true}}}return false}A.words=function(M){if(!arguments.length){return G}G=M;return A};A.size=function(M){if(!arguments.length){return L}L=[+M[0],+M[1]];return A};A.font=function(M){if(!arguments.length){return z}z=d3.functor(M);return A};A.fontStyle=function(M){if(!arguments.length){return C}C=d3.functor(M);return A};A.fontWeight=function(M){if(!arguments.length){return H}H=d3.functor(M);return A};A.rotate=function(M){if(!arguments.length){return D}D=d3.functor(M);return A};A.text=function(M){if(!arguments.length){return J}J=d3.functor(M);return A};A.spiral=function(M){if(!arguments.length){return E}E=a[M+""]||M;return A};A.fontSize=function(M){if(!arguments.length){return K}K=d3.functor(M);return A};A.padding=function(M){if(!arguments.length){return I}I=d3.functor(M);return A};return d3.rebind(A,c,"on")}function r(c){return c.text}function s(){return"serif"}function k(){return"normal"}function b(c){return Math.sqrt(c.value)}function t(){return(~~(Math.random()*6)-3)*30}function n(){return 1}function q(V,W,T){if(V.sprite){return}v.clearRect(0,0,(e<<5)/h,l/h);var E=0,D=0,G=0,L=W.length;T--;while(++T<L){V=W[T];v.save();v.font=V.style+" "+V.weight+" "+~~((V.size+1)/h)+"px "+V.font;var F=v.measureText(V.text+"m").width*h,S=V.size<<1;if(V.rotate){var O=Math.sin(V.rotate*w),C=Math.cos(V.rotate*w),z=F*C,H=F*O,U=S*C,B=S*O;F=(Math.max(Math.abs(z+B),Math.abs(z-B))+31)>>5<<5;S=~~Math.max(Math.abs(H+U),Math.abs(H-U))}else{F=(F+31)>>5<<5}if(S>G){G=S}if(E+F>=(e<<5)){E=0;D+=G;G=0}if(D+S>=l){break}v.translate((E+(F>>1))/h,(D+(S>>1))/h);if(V.rotate){v.rotate(V.rotate*w)}v.fillText(V.text,0,0);v.restore();V.width=F;V.height=S;V.xoff=E;V.yoff=D;V.x1=F>>1;V.y1=S>>1;V.x0=-V.x1;V.y0=-V.y1;E+=F}var I=v.getImageData(0,0,(e<<5)/h,l/h).data,K=[];while(--T>=0){V=W[T];var F=V.width,A=F>>5,S=V.y1-V.y0,J=V.padding;for(var R=0;R<S*A;R++){K[R]=0}E=V.xoff;if(E==null){return}D=V.yoff;var c=0,Q=-1;for(var P=0;P<S;P++){for(var R=0;R<F;R++){var N=A*P+(R>>5),M=I[((D+P)*(e<<5)+(E+R))<<2]?1<<(31-(R%32)):0;if(J){if(P){K[N-A]|=M}if(P<F-1){K[N+A]|=M}M|=(M<<1)|(M>>1)}K[N]|=M;c|=M}if(c){Q=P}else{V.y0++;S--;P--;D++}}V.y1=V.y0+Q;V.sprite=K.slice(0,(V.y1-V.y0)*A)}}function j(J,C,G){G>>=5;var I=J.sprite,F=J.width>>5,c=J.x-(F<<4),E=c&127,B=32-E,A=J.y1-J.y0,D=(J.y+J.y0)*G+(c>>5),H;for(var y=0;y<A;y++){H=0;for(var z=0;z<=F;z++){if(((H<<B)|(z<F?(H=I[y*F+z])>>>E:0))&C[D+z]){return true}}D+=G}return false}function i(z,A){var y=z[0],c=z[1];if(A.x+A.x0<y.x){y.x=A.x+A.x0}if(A.y+A.y0<y.y){y.y=A.y+A.y0}if(A.x+A.x1>c.x){c.x=A.x+A.x1}if(A.y+A.y1>c.y){c.y=A.y+A.y1}}function f(y,c){return y.x+y.x1>c[0].x&&y.x+y.x0<c[1].x&&y.y+y.y1>c[0].y&&y.y+y.y0<c[1].y}function u(c){var y=c[0]/c[1];return function(z){return[y*(z*=0.1)*Math.cos(z),z*Math.sin(z)]}}function p(B){var z=4,A=z*B[0]/B[1],c=0,C=0;return function(D){var y=D<0?-1:1;switch((Math.sqrt(1+4*y*D)-y)&3){case 0:c+=A;break;case 1:C+=z;break;case 2:c-=A;break;default:C-=z;break}return[c,C]}}function m(z){var c=[],y=-1;while(++y<z){c[y]=0}return c}var w=Math.PI/180,e=1<<11>>5,l=1<<11,d,h=1;if(typeof document!=="undefined"){d=document.createElement("canvas");d.width=1;d.height=1;h=Math.sqrt(d.getContext("2d").getImageData(0,0,1,1).data.length>>2);d.width=(e<<5)/h;d.height=l/h}else{var o=require("canvas");d=new o(e<<5,l)}var v=d.getContext("2d"),a={archimedean:u,rectangular:p};v.fillStyle="red";v.textAlign="center";x.cloud=g})(typeof exports==="undefined"?d3.layout||(d3.layout={}):exports);
(function(){if(typeof define==="function"&&define.amd){define(["d3"],a)}else{a(this.d3)}function a(y){var b=Math.random;y.layout.cloud=function i(){var A=256,N=256,I=[A,N],K=null,F=s,H=t,c=e,z=m,E=m,Q=u,G=p,M=v,J=[],L=Infinity,P=y.dispatch("word","end"),D=null,O=false,B={};B.start=function(){var T=o((I[0]>>5)*I[1]),V=null,X=J.length,S=-1,R=[],W=J.map(function(Z,Y){Z.text=F.call(this,Z,Y);Z.font=H.call(this,Z,Y);Z.style=z.call(this,Z,Y);Z.weight=E.call(this,Z,Y);Z.rotate=Q.call(this,Z,Y);Z.size=~~c.call(this,Z,Y);Z.padding=G.call(this,Z,Y);return Z}).sort(function(Z,Y){return Y.size-Z.size});if(D){clearInterval(D)}D=setInterval(U,0);U();return B;function U(){var ac=Date.now(),Y,ab,Z;while(Date.now()-ac<L&&++S<X&&D){var aa=W[S];if(K){Y=aa.x=K[0];ab=aa.y=K[1]}else{Y=aa.x=(I[0]*(b()+0.5))>>1;ab=aa.y=(I[1]*(b()+0.5))>>1}Z=S+1;r(aa,W,S);while(aa.hasText){if(C(T,aa,V)){R.push(aa);P.word(aa);if(V){k(V,aa)}else{V=[{x:aa.x+aa.x0,y:aa.y+aa.y0},{x:aa.x+aa.x1,y:aa.y+aa.y1}]}aa.x-=I[0]>>1;aa.y-=I[1]>>1;break}else{delete aa.sprite;aa.sprite=null;aa.x=Y;aa.y=ab;aa.size=Z<W.length?W[Z++].size:aa.size-(aa.size>>3);if(~~aa.size>0){r(aa,W,S)}else{aa.hasText=false}}}}if(S>=X){B.stop();P.end(R,V)}}};B.stop=function(){if(D){clearInterval(D);D=null}return B};function C(V,ao,U){var S=[{x:0,y:0},{x:I[0],y:I[1]}],am=ao.x,al=ao.y,R=Math.sqrt(I[0]*I[0]+I[1]*I[1]),ac=M(I),ad=b()<0.5?1:-1,ab=-ad,ai,aa,Y;while(ai=ac(ab+=ad)){aa=~~ai[0];Y=~~ai[1];if(Math.min(Math.abs(aa),Math.abs(Y))>=R){break}ao.x=am+aa;ao.y=al+Y;if(ao.x+ao.x0<0||ao.y+ao.y0<0||ao.x+ao.x1>I[0]||ao.y+ao.y1>I[1]){if(!O){continue}}if(!U||!l(ao,V,I[0])){if(!U||h(ao,U)){var ag=ao.sprite,Z=ao.width>>5,af=I[0]>>5,T=ao.x-(Z<<4),ae=T&127,an=32-ae,ak=ao.y1-ao.y0,X=(ao.y+ao.y0)*af+(T>>5),W;for(var ah=0;ah<ak;ah++){W=0;for(var aj=0;aj<=Z;aj++){V[X+aj]|=(W<<an)|(aj<Z?(W=ag[ah*Z+aj])>>>ae:0)}X+=af}delete ao.sprite;return true}}}return false}B.timeInterval=function(R){return arguments.length?(L=R===null?Infinity:R,B):L};B.words=function(R){return arguments.length?(J=R,B):J};B.size=function(R){if(!arguments.length){return I}if(!R[0]||R[0]<0){R[0]=A}if(!R[1]||R[1]<1){R[1]=N}return arguments.length?(I=[+R[0],+R[1]],B):I};B.font=function(R){return arguments.length?(H=y.functor(R),B):H};B.fontStyle=function(R){return arguments.length?(z=y.functor(R),B):z};B.fontWeight=function(R){return arguments.length?(E=y.functor(R),B):E};B.rotate=function(R){return arguments.length?(Q=y.functor(R),B):Q};B.text=function(R){return arguments.length?(F=y.functor(R),B):F};B.spiral=function(R){return arguments.length?(M=d[R]||R,B):M};B.fontSize=function(R){return arguments.length?(c=y.functor(R),B):c};B.padding=function(R){return arguments.length?(G=y.functor(R),B):G};B.random=function(R){return arguments.length?(b=R,B):b};B.startPoint=function(R){if(!arguments.length){return K}K=[+R[0],+R[1]];return B};B.overflow=function(R){if(!arguments.length){return O}O=y.functor(R);return B};return y.rebind(B,P,"on")};function s(c){return c.text}function t(){return"serif"}function m(){return"normal"}function e(c){return Math.sqrt(c.value)}function u(){return(~~(b()*6)-3)*30}function p(){return 1}function r(U,V,S){if(U.sprite){return}w.clearRect(0,0,(g<<5)/j,n/j);var E=0,D=0,G=0,K=V.length;--S;while(++S<K){U=V[S];w.save();w.font=U.style+" "+U.weight+" "+~~((U.size+1)/j)+"px "+U.font;var F=w.measureText(U.text+"m").width*j,R=U.size<<1;if(U.rotate){var N=Math.sin(U.rotate*x),C=Math.cos(U.rotate*x),z=F*C,H=F*N,T=R*C,B=R*N;F=(Math.max(Math.abs(z+B),Math.abs(z-B))+31)>>5<<5;R=~~Math.max(Math.abs(H+T),Math.abs(H-T))}else{F=(F+31)>>5<<5}if(R>G){G=R}if(E+F>=(g<<5)){E=0;D+=G;G=0}if(D+R>=n){break}w.translate((E+(F>>1))/j,(D+(R>>1))/j);if(U.rotate){w.rotate(U.rotate*x)}w.fillText(U.text,0,0);if(U.padding){w.lineWidth=2*U.padding,w.strokeText(U.text,0,0)}w.restore();U.width=F;U.height=R;U.xoff=E;U.yoff=D;U.x1=F>>1;U.y1=R>>1;U.x0=-U.x1;U.y0=-U.y1;U.hasText=true;E+=F}var I=w.getImageData(0,0,(g<<5)/j,n/j).data,J=[];while(--S>=0){U=V[S];if(!U.hasText){continue}var F=U.width,A=F>>5,R=U.y1-U.y0;for(var Q=0;Q<R*A;Q++){J[Q]=0}E=U.xoff;if(E===null){return}D=U.yoff;var c=0,P=-1;for(var O=0;O<R;O++){for(var Q=0;Q<F;Q++){var M=A*O+(Q>>5),L=I[((D+O)*(g<<5)+(E+Q))<<2]?1<<(31-(Q%32)):0;J[M]|=L;c|=L}if(c){P=O}else{U.y0++;R--;O--;D++}}U.y1=U.y0+P;U.sprite=J.slice(0,(U.y1-U.y0)*A)}}function l(K,D,H){H>>=5;var J=K.sprite,G=K.width>>5,c=K.x-(G<<4),F=c&127,C=32-F,B=K.y1-K.y0,E=(K.y+K.y0)*H+(c>>5),I;for(var z=0;z<B;z++){I=0;for(var A=0;A<=G;A++){if(((I<<C)|(A<G?(I=J[z*G+A])>>>F:0))&D[E+A]){return true}}E+=H}return false}function k(A,B){var z=A[0],c=A[1];if(B.x+B.x0<z.x){z.x=B.x+B.x0}if(B.y+B.y0<z.y){z.y=B.y+B.y0}if(B.x+B.x1>c.x){c.x=B.x+B.x1}if(B.y+B.y1>c.y){c.y=B.y+B.y1}}function h(z,c){return z.x+z.x1>c[0].x&&z.x+z.x0<c[1].x&&z.y+z.y1>c[0].y&&z.y+z.y0<c[1].y}function v(c){var z=c[0]/c[1];return function(A){return[z*(A*=0.1)*Math.cos(A),A*Math.sin(A)]}}function q(B){var z=4,A=z*B[0]/B[1],c=0,C=0;return function(E){var D=E<0?-1:1;switch((Math.sqrt(1+4*D*E)-D)&3){case 0:c+=A;break;case 1:C+=z;break;case 2:c-=A;break;default:C-=z;break}return[c,C]}}function o(A){var c=[],z=-1;while(++z<A){c[z]=0}return c}var x=Math.PI/180,g=1<<11>>5,n=1<<11,f,j=1;if(typeof document!=="undefined"){f=document.createElement("canvas");f.width=1;f.height=1;j=Math.sqrt(f.getContext("2d").getImageData(0,0,1,1).data.length>>2);f.width=(g<<5)/j;f.height=n/j}else{if(!!Canvas){f=new Canvas(g<<5,n)}}var w=f.getContext("2d"),d={archimedean:v,rectangular:q};w.fillStyle=w.strokeStyle="red";w.textAlign="center"}})();

@@ -1,2 +0,2 @@

Copyright (c) 2012, Jason Davies.
Copyright (c) 2013, Jason Davies.
All rights reserved.

@@ -3,0 +3,0 @@

Metadata-Version: 1.0
Name: js.d3_cloud
Version: 1.0.1
Version: 1.1.2
Summary: Fanstatic packaging of D3 Word Cloud Layout

@@ -18,3 +18,3 @@ Home-page: https://github.com/davidjb/js.d3_cloud

.. _`fanstatic`: http://fanstatic.org
.. _`D3 Word Cloud Layout`: https://github.com/jasondavies/d3-cloud
.. _`D3 Word Cloud Layout`: https://github.com/iLanguage/d3-cloud

@@ -42,3 +42,3 @@ This requires integration between your web framework and ``fanstatic``,

This process requires installation of the package for development - the
suggested method to do this is via the `Buildout` within this package:
suggested method to do this is via the `Buildout` within this package::

@@ -53,7 +53,7 @@ cd js.d3_cloud

In order to obtain a newer version of of this library, do the following::
In order to obtain a newer version of this library, do the following::
pushd js/d3_cloud/resources
wget https://github.com/jasondavies/d3-cloud/raw/master/d3.layout.cloud.js -O d3.layout.cloud.js
wget https://github.com/jasondavies/d3-cloud/raw/master/LICENSE -O LICENSE
wget https://github.com/iLanguage/d3-cloud/raw/master/src/d3.layout.cloud.js -O d3.layout.cloud.js
wget https://github.com/iLanguage/d3-cloud/raw/master/LICENSE -O LICENSE
popd

@@ -81,2 +81,10 @@ #Edit changelog, setup.py for versions, etc

1.1.2 (2015-07-13)
==================
- Change to using iLanguage's fork of d3-cloud because it's now being
maintained. This adds numerous features and fixes. See
https://github.com/iLanguage/d3-cloud.
[davidjb]
1.0.1 (2012-12-21)

@@ -83,0 +91,0 @@ ==================

@@ -10,3 +10,3 @@ js.d3_cloud

.. _`fanstatic`: http://fanstatic.org
.. _`D3 Word Cloud Layout`: https://github.com/jasondavies/d3-cloud
.. _`D3 Word Cloud Layout`: https://github.com/iLanguage/d3-cloud

@@ -34,3 +34,3 @@ This requires integration between your web framework and ``fanstatic``,

This process requires installation of the package for development - the
suggested method to do this is via the `Buildout` within this package:
suggested method to do this is via the `Buildout` within this package::

@@ -45,7 +45,7 @@ cd js.d3_cloud

In order to obtain a newer version of of this library, do the following::
In order to obtain a newer version of this library, do the following::
pushd js/d3_cloud/resources
wget https://github.com/jasondavies/d3-cloud/raw/master/d3.layout.cloud.js -O d3.layout.cloud.js
wget https://github.com/jasondavies/d3-cloud/raw/master/LICENSE -O LICENSE
wget https://github.com/iLanguage/d3-cloud/raw/master/src/d3.layout.cloud.js -O d3.layout.cloud.js
wget https://github.com/iLanguage/d3-cloud/raw/master/LICENSE -O LICENSE
popd

@@ -52,0 +52,0 @@ #Edit changelog, setup.py for versions, etc

@@ -0,1 +1,4 @@

[aliases]
minify_d3_cloud = minify_js --charset utf-8 --sources 'js/d3_cloud/resources/d3.layout.cloud.js' --output 'js/d3_cloud/resources/%s.min.js'
[egg_info]

@@ -6,4 +9,1 @@ tag_build =

[aliases]
minify_d3_cloud = minify_js --charset utf-8 --sources 'js/d3_cloud/resources/d3.layout.cloud.js' --output 'js/d3_cloud/resources/%s.min.js'

@@ -11,3 +11,3 @@ from setuptools import setup, find_packages

version = '1.0.1'
version = '1.1.2'

@@ -45,3 +45,3 @@ def read(*rnames):

'setuptools',
'js.d3',
'js.d3>=3.0',
],

@@ -48,0 +48,0 @@ entry_points={