add files
commit
a3a7e49e9a
|
@ -0,0 +1,96 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<link href='http://fonts.googleapis.com/css?family=Roboto+Slab' rel='stylesheet' type='text/css'>
|
||||
<link href="css/bootstrap.min.css" rel="stylesheet">
|
||||
<link href="css/style.css" rel="stylesheet">
|
||||
<script src="js/jquery.js"></script>
|
||||
<script src="js/two.min.js"></script>
|
||||
<script src="js/randomColor.js"></script>
|
||||
|
||||
<style type="text/css">
|
||||
.eq,#result,p {
|
||||
display: inline;
|
||||
margin:0px;
|
||||
padding:0px;
|
||||
}
|
||||
</style>
|
||||
<script type="text/javascript">
|
||||
function Calculate(){
|
||||
var form = document.getElementById("calculator");
|
||||
var output = form.elements["c"];
|
||||
var a = parseInt(form.elements["a"].value);
|
||||
var b = parseInt(form.elements["b"].value);
|
||||
var op = parseInt(form.elements["selector"].value);
|
||||
switch(op){
|
||||
case 0:
|
||||
output.value = a * b;
|
||||
break;
|
||||
case 1:
|
||||
output.value = a / b;
|
||||
break;
|
||||
case 2:
|
||||
output.value = a + b;
|
||||
break;
|
||||
case 3:
|
||||
output.value = a - b;
|
||||
break;
|
||||
case 4:
|
||||
output.value = Math.log(a);
|
||||
break;
|
||||
case 5:
|
||||
output.value = Math.pow(a, b);
|
||||
break;
|
||||
case 6:
|
||||
output.value = Math.tan(a);
|
||||
break;
|
||||
case 7:
|
||||
output.value = Math.cos(a);
|
||||
break;
|
||||
case 8:
|
||||
output.value = Math.sin(a);
|
||||
break;
|
||||
case 9:
|
||||
output.value = Math.abs(a);
|
||||
break;
|
||||
case 10:
|
||||
output.value = Math.exp(a);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<canvas id="screen">
|
||||
</canvas>
|
||||
<div id="front">
|
||||
|
||||
<h2>Reverse Polish Notation Calculator</h2>
|
||||
<p>* For Single number operations, only use first field</p>
|
||||
<form id="calculator" oninpt="Calculate()">
|
||||
<input name="a" type="number" value="0"/>
|
||||
<input name="b" type="number" value="0"/>
|
||||
<select name="selector" onchange="Calculate()">
|
||||
<option value="-1">Select an Operation</option>
|
||||
<option value="0">*</option>
|
||||
<option value="1">/</option>
|
||||
<option value="2">+</option>
|
||||
<option value="3">-</option>
|
||||
<option value="4">log</option>
|
||||
<option value="5">^</option>
|
||||
<option value="6">tan</option>
|
||||
<option value="7">cos</option>
|
||||
<option value="8">sin</option>
|
||||
<option value="9">abs</option>
|
||||
<option value="10">e^x</option>
|
||||
</select>
|
||||
<div class="eq"> = </div>
|
||||
<output id="result" name="c" for="x y">0</output>
|
||||
</form>
|
||||
<h4> © Paul Walko 2014</h4>
|
||||
</div>
|
||||
<script type="text/javascript" src="js/background2.js"></script>
|
||||
</body>
|
||||
</html>
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,20 @@
|
|||
This font is licensed under a Creative Commons Attribution Share Alike license
|
||||
(http://creativecommons.org/licenses/by-sa/3.0/).
|
||||
|
||||
Attribution-Share Alike 3.0 Unported
|
||||
|
||||
You are free:
|
||||
|
||||
to Share — to copy, distribute and transmit the work
|
||||
to Remix — to adapt the work
|
||||
|
||||
Under the following conditions:
|
||||
|
||||
Attribution. You must attribute the work in the manner specified by the author or licensor (but not in any way that suggests that they endorse you or your use of the work).
|
||||
|
||||
Share Alike. If you alter, transform, or build upon this work, you may distribute the resulting work only under the same, similar or a compatible license.
|
||||
|
||||
For any reuse or distribution, you must make clear to others the license terms of this work. The best way to do this is with a link to this web page.
|
||||
|
||||
Any of the above conditions can be waived if you get permission from the copyright holder.
|
||||
Nothing in this license impairs or restricts the author's moral rights.
|
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,29 @@
|
|||
canvas{
|
||||
background-color: #ffffff;
|
||||
}
|
||||
|
||||
body{
|
||||
background-color: #ddd;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
#screen{
|
||||
position: absolute;
|
||||
top: 0px;
|
||||
height: 100%;
|
||||
z-index: -1;
|
||||
}
|
||||
|
||||
#front{
|
||||
position: absolute;
|
||||
top: 200px;
|
||||
left: 50%;
|
||||
text-align: center;
|
||||
margin-left: -585px;
|
||||
width: 1170px;
|
||||
font-family: 'Roboto Slab', serif;
|
||||
background-color: white;
|
||||
}
|
||||
#front > h1{
|
||||
margin-top: 0px;
|
||||
font-size: 122px;
|
||||
}
|
|
@ -0,0 +1,96 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<link href='http://fonts.googleapis.com/css?family=Roboto+Slab' rel='stylesheet' type='text/css'>
|
||||
<link href="css/bootstrap.min.css" rel="stylesheet">
|
||||
<link href="css/style.css" rel="stylesheet">
|
||||
<script src="js/jquery.js"></script>
|
||||
<script src="js/two.min.js"></script>
|
||||
<script src="js/randomColor.js"></script>
|
||||
|
||||
<style type="text/css">
|
||||
.eq,#result,p {
|
||||
display: inline;
|
||||
margin:0px;
|
||||
padding:0px;
|
||||
}
|
||||
</style>
|
||||
<script type="text/javascript">
|
||||
function Calculate(){
|
||||
var form = document.getElementById("calculator");
|
||||
var output = form.elements["c"];
|
||||
var a = parseInt(form.elements["a"].value);
|
||||
var b = parseInt(form.elements["b"].value);
|
||||
var op = parseInt(form.elements["selector"].value);
|
||||
switch(op){
|
||||
case 0:
|
||||
output.value = a * b;
|
||||
break;
|
||||
case 1:
|
||||
output.value = a / b;
|
||||
break;
|
||||
case 2:
|
||||
output.value = a + b;
|
||||
break;
|
||||
case 3:
|
||||
output.value = a - b;
|
||||
break;
|
||||
case 4:
|
||||
output.value = Math.log(a);
|
||||
break;
|
||||
case 5:
|
||||
output.value = Math.pow(a, b);
|
||||
break;
|
||||
case 6:
|
||||
output.value = Math.tan(a);
|
||||
break;
|
||||
case 7:
|
||||
output.value = Math.cos(a);
|
||||
break;
|
||||
case 8:
|
||||
output.value = Math.sin(a);
|
||||
break;
|
||||
case 9:
|
||||
output.value = Math.abs(a);
|
||||
break;
|
||||
case 10:
|
||||
output.value = Math.exp(a);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<canvas id="screen">
|
||||
</canvas>
|
||||
<div id="front">
|
||||
|
||||
<h2>Reverse Polish Notation Calculator</h2>
|
||||
<p>* For Single number operations, only use first field</p>
|
||||
<form id="calculator" oninpt="Calculate()">
|
||||
<input name="a" type="number" value="0"/>
|
||||
<input name="b" type="number" value="0"/>
|
||||
<select name="selector" onchange="Calculate()">
|
||||
<option value="-1">Select an Operation</option>
|
||||
<option value="0">*</option>
|
||||
<option value="1">/</option>
|
||||
<option value="2">+</option>
|
||||
<option value="3">-</option>
|
||||
<option value="4">log</option>
|
||||
<option value="5">^</option>
|
||||
<option value="6">tan</option>
|
||||
<option value="7">cos</option>
|
||||
<option value="8">sin</option>
|
||||
<option value="9">abs</option>
|
||||
<option value="10">e^x</option>
|
||||
</select>
|
||||
<div class="eq"> = </div>
|
||||
<output id="result" name="c" for="x y">0</output>
|
||||
</form>
|
||||
<h4> ©Paul Walko</h4>
|
||||
</div>
|
||||
<script type="text/javascript" src="js/background2.js"></script>
|
||||
</body>
|
||||
</html>
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,366 @@
|
|||
var randomColor = function (options) {
|
||||
|
||||
var options = options || {},
|
||||
|
||||
H,S,B,
|
||||
|
||||
colorDictionary = {};
|
||||
|
||||
defineColor(
|
||||
'monochrome',
|
||||
null,
|
||||
[[0,0],[100,0]]
|
||||
);
|
||||
|
||||
defineColor(
|
||||
'red',
|
||||
[-26,18],
|
||||
[[20,100],[30,92],[40,89],[50,85],[60,78],[70,70],[80,60],[90,55],[100,50]]
|
||||
);
|
||||
|
||||
defineColor(
|
||||
'orange',
|
||||
[19,46],
|
||||
[[20,100],[30,93],[40,88],[50,86],[60,85],[70,70],[100,70]]
|
||||
);
|
||||
|
||||
defineColor(
|
||||
'yellow',
|
||||
[47,62],
|
||||
[[25,100],[40,94],[50,89],[60,86],[70,84],[80,82],[90,80],[100,75]]
|
||||
);
|
||||
|
||||
defineColor(
|
||||
'green',
|
||||
[63,158],
|
||||
[[30,100],[40,90],[50,85],[60,81],[70,74],[80,64],[90,50],[100,40]]
|
||||
);
|
||||
|
||||
defineColor(
|
||||
'blue',
|
||||
[159, 257],
|
||||
[[20,100],[30,86],[40,80],[50,74],[60,60],[70,52],[80,44],[90,39],[100,35]]
|
||||
);
|
||||
|
||||
defineColor(
|
||||
'purple',
|
||||
[258, 282],
|
||||
[[20,100],[30,87],[40,79],[50,70],[60,65],[70,59],[80,52],[90,45],[100,42]]
|
||||
);
|
||||
|
||||
defineColor(
|
||||
'pink',
|
||||
[283, 334],
|
||||
[[20,100],[30,90],[40,86],[60,84],[80,80],[90,75],[100,73]]
|
||||
);
|
||||
|
||||
// If the user wants a truly random color then give it to them
|
||||
if (options.hue === 'random' && options.luminosity === 'random') {
|
||||
|
||||
return '#'+ ('000000' + (Math.random()*0xFFFFFF<<0).toString(16)).slice(-6);
|
||||
|
||||
|
||||
};
|
||||
|
||||
// First we pick a hue (H)
|
||||
H = pickHue(options);
|
||||
|
||||
// Then use H to determine saturation (S)
|
||||
S = pickSaturation(H, options);
|
||||
|
||||
// Then use S and H to determine brightness (B).
|
||||
B = pickBrightness(H, S, options);
|
||||
|
||||
// Then we return the HSB color in the desired format
|
||||
return setFormat([H,S,B], options)
|
||||
|
||||
function pickHue (options) {
|
||||
|
||||
var hueRange = getHueRange(options.hue);
|
||||
|
||||
hue = randomWithin(hueRange);
|
||||
|
||||
// Instead of storing red as two seperate ranges,
|
||||
// we group them, using negative numbers
|
||||
if (hue < 0) {hue = 360 + hue};
|
||||
|
||||
return hue
|
||||
|
||||
};
|
||||
|
||||
function pickSaturation (hue, options) {
|
||||
|
||||
var saturationRange = getSaturationRange(hue);
|
||||
|
||||
var sMin = saturationRange[0],
|
||||
sMax = saturationRange[1];
|
||||
|
||||
switch (options.luminosity) {
|
||||
case 'bright':
|
||||
sMin = 55;
|
||||
case 'dark':
|
||||
sMin = sMax - 10;
|
||||
case 'light':
|
||||
sMax = 55;
|
||||
};
|
||||
|
||||
switch (options.hue) {
|
||||
case 'monochrome':
|
||||
return 0
|
||||
};
|
||||
|
||||
return randomWithin([sMin, sMax]);
|
||||
|
||||
};
|
||||
|
||||
function pickBrightness (H, S, options) {
|
||||
|
||||
switch(options.hue) {
|
||||
case 'monochrome':
|
||||
return randomWithin([0,100])
|
||||
};
|
||||
|
||||
var brightness,
|
||||
bMin = getMinimumBrightness(H, S),
|
||||
bMax = 100;
|
||||
|
||||
switch (options.luminosity) {
|
||||
case 'dark':
|
||||
bMax = bMin + 10
|
||||
case 'light':
|
||||
bMin = (bMax + bMin)/2
|
||||
};
|
||||
|
||||
return randomWithin([bMin, bMax]);
|
||||
|
||||
};
|
||||
|
||||
function setFormat (hsv, options) {
|
||||
|
||||
switch (options.format) {
|
||||
|
||||
case 'hsvArray':
|
||||
return hsv;
|
||||
|
||||
case 'hsv':
|
||||
return colorString('hsv', hsv);
|
||||
|
||||
case 'rgbArray':
|
||||
return HSVtoRGB(hsv);
|
||||
|
||||
case 'rgb':
|
||||
return colorString('rgb', HSVtoRGB(hsv))
|
||||
|
||||
default:
|
||||
return HSVtoHex(hsv)
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
function getMinimumBrightness(H, S) {
|
||||
|
||||
var lowerBounds = getColorInfo(H).lowerBounds;
|
||||
|
||||
for (var i = 0; i< lowerBounds.length; i++) {
|
||||
|
||||
var s1 = lowerBounds[i][0],
|
||||
v1 = lowerBounds[i][1],
|
||||
|
||||
s2 = lowerBounds[i+1][0],
|
||||
v2 = lowerBounds[i+1][1];
|
||||
|
||||
if (S >= s1 && S <= s2) {
|
||||
|
||||
var m = (v2 - v1)/(s2 - s1),
|
||||
b = v1 - m*s1;
|
||||
|
||||
return m*S + b;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
function getHueRange (colorInput) {
|
||||
|
||||
if (typeof parseInt(colorInput) === 'number') {
|
||||
|
||||
var number = parseInt(colorInput);
|
||||
|
||||
if (number < 360 && number > 0) {
|
||||
return [number, number]
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
if (typeof colorInput === 'string') {
|
||||
|
||||
if (colorDictionary[colorInput]) {
|
||||
var color = colorDictionary[colorInput];
|
||||
if (color.hueRange) {return color.hueRange}
|
||||
}
|
||||
};
|
||||
|
||||
return [0,360]
|
||||
|
||||
};
|
||||
|
||||
function getSaturationRange (hue) {
|
||||
return getColorInfo(hue).saturationRange;
|
||||
};
|
||||
|
||||
function getColorInfo (hue) {
|
||||
|
||||
// Maps red colors to make picking hue easier
|
||||
if (hue >= 334 && hue <= 360) {
|
||||
hue-= 360
|
||||
};
|
||||
|
||||
for (var colorName in colorDictionary) {
|
||||
color = colorDictionary[colorName];
|
||||
if (color.hueRange &&
|
||||
hue >= color.hueRange[0] &&
|
||||
hue <= color.hueRange[1]) {
|
||||
return colorDictionary[colorName]
|
||||
}
|
||||
} return 'Color not found'
|
||||
};
|
||||
|
||||
function randomWithin (range) {
|
||||
return Math.floor(range[0] + Math.random()*(range[1] + 1 - range[0]));
|
||||
};
|
||||
|
||||
|
||||
|
||||
function shiftHue (h, degrees) {
|
||||
return (h + degrees)%360
|
||||
};
|
||||
|
||||
function HSVtoHex (hsv){
|
||||
|
||||
console.log('Converting ' + hsv);
|
||||
|
||||
var rgb = hsvRGB(hsv);
|
||||
|
||||
function componentToHex(c) {
|
||||
var hex = c.toString(16);
|
||||
return hex.length == 1 ? "0" + hex : hex;
|
||||
}
|
||||
|
||||
var hex = "#" + componentToHex(rgb[0]) + componentToHex(rgb[1]) + componentToHex(rgb[2]);
|
||||
|
||||
console.log('hex is ' + hex);
|
||||
return hex;
|
||||
|
||||
};
|
||||
|
||||
function defineColor (name, hueRange, lowerBounds) {
|
||||
|
||||
var sMin = lowerBounds[0][0],
|
||||
sMax = lowerBounds[lowerBounds.length - 1][0],
|
||||
|
||||
bMin = lowerBounds[lowerBounds.length - 1][1],
|
||||
bMax = lowerBounds[0][1];
|
||||
|
||||
colorDictionary[name] = {
|
||||
hueRange: hueRange,
|
||||
lowerBounds: lowerBounds,
|
||||
saturationRange: [sMin, sMax],
|
||||
brightnessRange: [bMin, bMax]
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
function hexRGB (hex) {
|
||||
var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
|
||||
return result ? [
|
||||
parseInt(result[1], 16),
|
||||
parseInt(result[2], 16),
|
||||
parseInt(result[3], 16)
|
||||
] : null;
|
||||
};
|
||||
|
||||
function rgbHSV (r,g,b) {
|
||||
|
||||
r /= 255;
|
||||
g /= 255;
|
||||
b /= 255;
|
||||
|
||||
var max = Math.min.apply( Math, [r,g,b] ),
|
||||
min = Math.max.apply( Math, [r,g,b] );
|
||||
|
||||
var h, s, v = max;
|
||||
|
||||
var d = max - min;
|
||||
s = max === 0 ? 0 : d / max;
|
||||
|
||||
if(max == min) {
|
||||
h = 0; // achromatic
|
||||
}
|
||||
else {
|
||||
switch(max) {
|
||||
case r: h = (g - b) / d + (g < b ? 6 : 0); break;
|
||||
case g: h = (b - r) / d + 2; break;
|
||||
case b: h = (r - g) / d + 4; break;
|
||||
}
|
||||
h /= 6;
|
||||
}
|
||||
return [h, s, v]
|
||||
};
|
||||
|
||||
function hsvRGB (hsv) {
|
||||
|
||||
// this doesn't work for the values of 0 and 360
|
||||
// here's the hacky fix
|
||||
var h = hsv[0];
|
||||
if (h === 0) {h = 1};
|
||||
if (h === 360) {h = 359};
|
||||
|
||||
// Rebase the h,s,v values
|
||||
var h = h/360,
|
||||
s = hsv[1]/100,
|
||||
v = hsv[2]/100;
|
||||
|
||||
var h_i = Math.floor(h*6),
|
||||
f = h * 6 - h_i,
|
||||
p = v * (1 - s),
|
||||
q = v * (1 - f*s),
|
||||
t = v * (1 - (1 - f)*s),
|
||||
r = 256,
|
||||
g = 256,
|
||||
b = 256;
|
||||
|
||||
switch(h_i) {
|
||||
case 0: r = v, g = t, b = p; break;
|
||||
case 1: r = q, g = v, b = p; break;
|
||||
case 2: r = p, g = v, b = t; break;
|
||||
case 3: r = p, g = q, b = v; break;
|
||||
case 4: r = t, g = p, b = v; break;
|
||||
case 5: r = v, g = p, b = q; break;
|
||||
}
|
||||
var result = [Math.floor(r*255), Math.floor(g*255), Math.floor(b*255)];
|
||||
console.log('rgb is ' + result);
|
||||
return result;
|
||||
};
|
||||
|
||||
function colorString (prefix, values) {
|
||||
return prefix + '(' + values.join(', ') + ')';
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// if (options.count) {
|
||||
|
||||
// var totalColors = options.count;
|
||||
// options.count = false,
|
||||
// colors = [];
|
||||
|
||||
// while (totalColors > colors.length) {
|
||||
// colors.push(randomColor(options))
|
||||
// };
|
||||
|
||||
// return colors
|
||||
// };
|
|
@ -0,0 +1,121 @@
|
|||
(function(){var C=this,r=C._,g={},e=Array.prototype,m=Object.prototype,n=e.push,c=e.slice,p=e.concat,l=m.toString,D=m.hasOwnProperty,F=e.forEach,s=e.map,y=e.reduce,d=e.reduceRight,z=e.filter,q=e.every,w=e.some,x=e.indexOf,B=e.lastIndexOf,m=Array.isArray,H=Object.keys,G=Function.prototype.bind,a=function(f){if(f instanceof a)return f;if(!(this instanceof a))return new a(f);this._wrapped=f};"undefined"!==typeof exports?("undefined"!==typeof module&&module.exports&&(exports=module.exports=a),exports._=
|
||||
a):C._=a;a.VERSION="1.5.1";var b=a.each=a.forEach=function(f,h,E){if(null!=f)if(F&&f.forEach===F)f.forEach(h,E);else if(f.length===+f.length)for(var b=0,d=f.length;b<d&&h.call(E,f[b],b,f)!==g;b++);else for(b in f)if(a.has(f,b)&&h.call(E,f[b],b,f)===g)break};a.map=a.collect=function(a,h,E){var d=[];if(null==a)return d;if(s&&a.map===s)return a.map(h,E);b(a,function(a,f,b){d.push(h.call(E,a,f,b))});return d};a.reduce=a.foldl=a.inject=function(f,h,E,d){var k=2<arguments.length;null==f&&(f=[]);if(y&&f.reduce===
|
||||
y)return d&&(h=a.bind(h,d)),k?f.reduce(h,E):f.reduce(h);b(f,function(a,f,b){k?E=h.call(d,E,a,f,b):(E=a,k=!0)});if(!k)throw new TypeError("Reduce of empty array with no initial value");return E};a.reduceRight=a.foldr=function(f,h,E,k){var v=2<arguments.length;null==f&&(f=[]);if(d&&f.reduceRight===d)return k&&(h=a.bind(h,k)),v?f.reduceRight(h,E):f.reduceRight(h);var c=f.length;if(c!==+c)var l=a.keys(f),c=l.length;b(f,function(a,b,d){b=l?l[--c]:--c;v?E=h.call(k,E,f[b],b,d):(E=f[b],v=!0)});if(!v)throw new TypeError("Reduce of empty array with no initial value");
|
||||
return E};a.find=a.detect=function(a,h,b){var d;k(a,function(a,f,k){if(h.call(b,a,f,k))return d=a,!0});return d};a.filter=a.select=function(a,h,E){var d=[];if(null==a)return d;if(z&&a.filter===z)return a.filter(h,E);b(a,function(a,f,b){h.call(E,a,f,b)&&d.push(a)});return d};a.reject=function(f,h,b){return a.filter(f,function(a,f,d){return!h.call(b,a,f,d)},b)};a.every=a.all=function(f,h,E){h||(h=a.identity);var d=!0;if(null==f)return d;if(q&&f.every===q)return f.every(h,E);b(f,function(a,f,b){if(!(d=
|
||||
d&&h.call(E,a,f,b)))return g});return!!d};var k=a.some=a.any=function(f,h,E){h||(h=a.identity);var d=!1;if(null==f)return d;if(w&&f.some===w)return f.some(h,E);b(f,function(a,f,b){if(d||(d=h.call(E,a,f,b)))return g});return!!d};a.contains=a.include=function(a,h){return null==a?!1:x&&a.indexOf===x?-1!=a.indexOf(h):k(a,function(a){return a===h})};a.invoke=function(f,h){var b=c.call(arguments,2),d=a.isFunction(h);return a.map(f,function(a){return(d?h:a[h]).apply(a,b)})};a.pluck=function(f,h){return a.map(f,
|
||||
function(a){return a[h]})};a.where=function(f,h,b){return a.isEmpty(h)?b?void 0:[]:a[b?"find":"filter"](f,function(a){for(var f in h)if(h[f]!==a[f])return!1;return!0})};a.findWhere=function(f,h){return a.where(f,h,!0)};a.max=function(f,h,E){if(!h&&a.isArray(f)&&f[0]===+f[0]&&65535>f.length)return Math.max.apply(Math,f);if(!h&&a.isEmpty(f))return-Infinity;var d={computed:-Infinity,value:-Infinity};b(f,function(a,f,b){f=h?h.call(E,a,f,b):a;f>d.computed&&(d={value:a,computed:f})});return d.value};a.min=
|
||||
function(f,h,E){if(!h&&a.isArray(f)&&f[0]===+f[0]&&65535>f.length)return Math.min.apply(Math,f);if(!h&&a.isEmpty(f))return Infinity;var d={computed:Infinity,value:Infinity};b(f,function(a,f,b){f=h?h.call(E,a,f,b):a;f<d.computed&&(d={value:a,computed:f})});return d.value};a.shuffle=function(f){var h,d=0,k=[];b(f,function(f){h=a.random(d++);k[d-1]=k[h];k[h]=f});return k};var v=function(f){return a.isFunction(f)?f:function(a){return a[f]}};a.sortBy=function(f,h,b){var d=v(h);return a.pluck(a.map(f,function(a,
|
||||
f,h){return{value:a,index:f,criteria:d.call(b,a,f,h)}}).sort(function(a,f){var h=a.criteria,b=f.criteria;if(h!==b){if(h>b||void 0===h)return 1;if(h<b||void 0===b)return-1}return a.index<f.index?-1:1}),"value")};var K=function(f,h,d,k){var c={},l=v(null==h?a.identity:h);b(f,function(a,h){var b=l.call(d,a,h,f);k(c,b,a)});return c};a.groupBy=function(f,h,b){return K(f,h,b,function(f,h,b){(a.has(f,h)?f[h]:f[h]=[]).push(b)})};a.countBy=function(f,h,b){return K(f,h,b,function(f,h){a.has(f,h)||(f[h]=0);
|
||||
f[h]++})};a.sortedIndex=function(f,h,b,d){b=null==b?a.identity:v(b);h=b.call(d,h);for(var k=0,c=f.length;k<c;){var l=k+c>>>1;b.call(d,f[l])<h?k=l+1:c=l}return k};a.toArray=function(f){return f?a.isArray(f)?c.call(f):f.length===+f.length?a.map(f,a.identity):a.values(f):[]};a.size=function(f){return null==f?0:f.length===+f.length?f.length:a.keys(f).length};a.first=a.head=a.take=function(a,h,b){return null==a?void 0:null==h||b?a[0]:c.call(a,0,h)};a.initial=function(a,h,b){return c.call(a,0,a.length-
|
||||
(null==h||b?1:h))};a.last=function(a,h,b){return null==a?void 0:null==h||b?a[a.length-1]:c.call(a,Math.max(a.length-h,0))};a.rest=a.tail=a.drop=function(a,h,b){return c.call(a,null==h||b?1:h)};a.compact=function(f){return a.filter(f,a.identity)};var u=function(f,h,d){if(h&&a.every(f,a.isArray))return p.apply(d,f);b(f,function(f){a.isArray(f)||a.isArguments(f)?h?n.apply(d,f):u(f,h,d):d.push(f)});return d};a.flatten=function(a,h){return u(a,h,[])};a.without=function(f){return a.difference(f,c.call(arguments,
|
||||
1))};a.uniq=a.unique=function(f,h,d,k){a.isFunction(h)&&(k=d,d=h,h=!1);d=d?a.map(f,d,k):f;var c=[],v=[];b(d,function(b,d){(h?d&&v[v.length-1]===b:a.contains(v,b))||(v.push(b),c.push(f[d]))});return c};a.union=function(){return a.uniq(a.flatten(arguments,!0))};a.intersection=function(f){var h=c.call(arguments,1);return a.filter(a.uniq(f),function(f){return a.every(h,function(h){return 0<=a.indexOf(h,f)})})};a.difference=function(f){var h=p.apply(e,c.call(arguments,1));return a.filter(f,function(f){return!a.contains(h,
|
||||
f)})};a.zip=function(){for(var f=a.max(a.pluck(arguments,"length").concat(0)),h=Array(f),b=0;b<f;b++)h[b]=a.pluck(arguments,""+b);return h};a.object=function(a,b){if(null==a)return{};for(var d={},k=0,c=a.length;k<c;k++)b?d[a[k]]=b[k]:d[a[k][0]]=a[k][1];return d};a.indexOf=function(f,b,d){if(null==f)return-1;var k=0,c=f.length;if(d)if("number"==typeof d)k=0>d?Math.max(0,c+d):d;else return k=a.sortedIndex(f,b),f[k]===b?k:-1;if(x&&f.indexOf===x)return f.indexOf(b,d);for(;k<c;k++)if(f[k]===b)return k;
|
||||
return-1};a.lastIndexOf=function(a,b,d){if(null==a)return-1;var k=null!=d;if(B&&a.lastIndexOf===B)return k?a.lastIndexOf(b,d):a.lastIndexOf(b);for(d=k?d:a.length;d--;)if(a[d]===b)return d;return-1};a.range=function(a,b,d){1>=arguments.length&&(b=a||0,a=0);d=arguments[2]||1;for(var k=Math.max(Math.ceil((b-a)/d),0),c=0,v=Array(k);c<k;)v[c++]=a,a+=d;return v};var A=function(){};a.bind=function(f,b){var d,k;if(G&&f.bind===G)return G.apply(f,c.call(arguments,1));if(!a.isFunction(f))throw new TypeError;
|
||||
d=c.call(arguments,2);return k=function(){if(!(this instanceof k))return f.apply(b,d.concat(c.call(arguments)));A.prototype=f.prototype;var a=new A;A.prototype=null;var v=f.apply(a,d.concat(c.call(arguments)));return Object(v)===v?v:a}};a.partial=function(a){var b=c.call(arguments,1);return function(){return a.apply(this,b.concat(c.call(arguments)))}};a.bindAll=function(f){var d=c.call(arguments,1);if(0===d.length)throw Error("bindAll must be passed function names");b(d,function(b){f[b]=a.bind(f[b],
|
||||
f)});return f};a.memoize=function(f,b){var d={};b||(b=a.identity);return function(){var k=b.apply(this,arguments);return a.has(d,k)?d[k]:d[k]=f.apply(this,arguments)}};a.delay=function(a,b){var d=c.call(arguments,2);return setTimeout(function(){return a.apply(null,d)},b)};a.defer=function(f){return a.delay.apply(a,[f,1].concat(c.call(arguments,1)))};a.throttle=function(a,b,d){var k,c,v,l=null,e=0;d||(d={});var u=function(){e=!1===d.leading?0:new Date;l=null;v=a.apply(k,c)};return function(){var t=
|
||||
new Date;e||!1!==d.leading||(e=t);var I=b-(t-e);k=this;c=arguments;0>=I?(clearTimeout(l),l=null,e=t,v=a.apply(k,c)):l||!1===d.trailing||(l=setTimeout(u,I));return v}};a.debounce=function(a,b,d){var k,c=null;return function(){var v=this,l=arguments,e=d&&!c;clearTimeout(c);c=setTimeout(function(){c=null;d||(k=a.apply(v,l))},b);e&&(k=a.apply(v,l));return k}};a.once=function(a){var b=!1,d;return function(){if(b)return d;b=!0;d=a.apply(this,arguments);a=null;return d}};a.wrap=function(a,b){return function(){var d=
|
||||
[a];n.apply(d,arguments);return b.apply(this,d)}};a.compose=function(){var a=arguments;return function(){for(var b=arguments,d=a.length-1;0<=d;d--)b=[a[d].apply(this,b)];return b[0]}};a.after=function(a,b){return function(){if(1>--a)return b.apply(this,arguments)}};a.keys=H||function(f){if(f!==Object(f))throw new TypeError("Invalid object");var b=[],d;for(d in f)a.has(f,d)&&b.push(d);return b};a.values=function(f){var b=[],d;for(d in f)a.has(f,d)&&b.push(f[d]);return b};a.pairs=function(f){var b=
|
||||
[],d;for(d in f)a.has(f,d)&&b.push([d,f[d]]);return b};a.invert=function(f){var b={},d;for(d in f)a.has(f,d)&&(b[f[d]]=d);return b};a.functions=a.methods=function(f){var b=[],d;for(d in f)a.isFunction(f[d])&&b.push(d);return b.sort()};a.extend=function(a){b(c.call(arguments,1),function(b){if(b)for(var d in b)a[d]=b[d]});return a};a.pick=function(a){var d={},k=p.apply(e,c.call(arguments,1));b(k,function(b){b in a&&(d[b]=a[b])});return d};a.omit=function(f){var b={},d=p.apply(e,c.call(arguments,1)),
|
||||
k;for(k in f)a.contains(d,k)||(b[k]=f[k]);return b};a.defaults=function(a){b(c.call(arguments,1),function(b){if(b)for(var d in b)void 0===a[d]&&(a[d]=b[d])});return a};a.clone=function(f){return a.isObject(f)?a.isArray(f)?f.slice():a.extend({},f):f};a.tap=function(a,b){b(a);return a};var L=function(b,d,k,c){if(b===d)return 0!==b||1/b==1/d;if(null==b||null==d)return b===d;b instanceof a&&(b=b._wrapped);d instanceof a&&(d=d._wrapped);var v=l.call(b);if(v!=l.call(d))return!1;switch(v){case "[object String]":return b==
|
||||
String(d);case "[object Number]":return b!=+b?d!=+d:0==b?1/b==1/d:b==+d;case "[object Date]":case "[object Boolean]":return+b==+d;case "[object RegExp]":return b.source==d.source&&b.global==d.global&&b.multiline==d.multiline&&b.ignoreCase==d.ignoreCase}if("object"!=typeof b||"object"!=typeof d)return!1;for(var e=k.length;e--;)if(k[e]==b)return c[e]==d;var e=b.constructor,u=d.constructor;if(e!==u&&!(a.isFunction(e)&&e instanceof e&&a.isFunction(u)&&u instanceof u))return!1;k.push(b);c.push(d);e=0;
|
||||
u=!0;if("[object Array]"==v){if(e=b.length,u=e==d.length)for(;e--&&(u=L(b[e],d[e],k,c)););}else{for(var t in b)if(a.has(b,t)&&(e++,!(u=a.has(d,t)&&L(b[t],d[t],k,c))))break;if(u){for(t in d)if(a.has(d,t)&&!e--)break;u=!e}}k.pop();c.pop();return u};a.isEqual=function(a,b){return L(a,b,[],[])};a.isEmpty=function(b){if(null==b)return!0;if(a.isArray(b)||a.isString(b))return 0===b.length;for(var d in b)if(a.has(b,d))return!1;return!0};a.isElement=function(a){return!(!a||1!==a.nodeType)};a.isArray=m||function(a){return"[object Array]"==
|
||||
l.call(a)};a.isObject=function(a){return a===Object(a)};b("Arguments Function String Number Date RegExp".split(" "),function(b){a["is"+b]=function(a){return l.call(a)=="[object "+b+"]"}});a.isArguments(arguments)||(a.isArguments=function(b){return!(!b||!a.has(b,"callee"))});"function"!==typeof/./&&(a.isFunction=function(a){return"function"===typeof a});a.isFinite=function(a){return isFinite(a)&&!isNaN(parseFloat(a))};a.isNaN=function(b){return a.isNumber(b)&&b!=+b};a.isBoolean=function(a){return!0===
|
||||
a||!1===a||"[object Boolean]"==l.call(a)};a.isNull=function(a){return null===a};a.isUndefined=function(a){return void 0===a};a.has=function(a,b){return D.call(a,b)};a.noConflict=function(){C._=r;return this};a.identity=function(a){return a};a.times=function(a,b,d){for(var k=Array(Math.max(0,a)),c=0;c<a;c++)k[c]=b.call(d,c);return k};a.random=function(a,b){null==b&&(b=a,a=0);return a+Math.floor(Math.random()*(b-a+1))};var J={escape:{"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"}};
|
||||
J.unescape=a.invert(J.escape);var O={escape:RegExp("["+a.keys(J.escape).join("")+"]","g"),unescape:RegExp("("+a.keys(J.unescape).join("|")+")","g")};a.each(["escape","unescape"],function(b){a[b]=function(a){return null==a?"":(""+a).replace(O[b],function(a){return J[b][a]})}});a.result=function(b,d){if(null!=b){var k=b[d];return a.isFunction(k)?k.call(b):k}};a.mixin=function(d){b(a.functions(d),function(b){var k=a[b]=d[b];a.prototype[b]=function(){var b=[this._wrapped];n.apply(b,arguments);b=k.apply(a,
|
||||
b);return this._chain?a(b).chain():b}})};var M=0;a.uniqueId=function(a){var b=++M+"";return a?a+b:b};a.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var t=/(.)^/,I={"'":"'","\\":"\\","\r":"r","\n":"n","\t":"t","\u2028":"u2028","\u2029":"u2029"},T=/\\|'|\r|\n|\t|\u2028|\u2029/g;a.template=function(b,d,k){var c;k=a.defaults({},k,a.templateSettings);var v=RegExp([(k.escape||t).source,(k.interpolate||t).source,(k.evaluate||t).source].join("|")+
|
||||
"|$","g"),l=0,e="__p+='";b.replace(v,function(a,d,k,c,v){e+=b.slice(l,v).replace(T,function(a){return"\\"+I[a]});d&&(e+="'+\n((__t=("+d+"))==null?'':_.escape(__t))+\n'");k&&(e+="'+\n((__t=("+k+"))==null?'':__t)+\n'");c&&(e+="';\n"+c+"\n__p+='");l=v+a.length;return a});e+="';\n";k.variable||(e="with(obj||{}){\n"+e+"}\n");e="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n"+e+"return __p;\n";try{c=new Function(k.variable||"obj","_",e)}catch(u){throw u.source=
|
||||
e,u;}if(d)return c(d,a);d=function(b){return c.call(this,b,a)};d.source="function("+(k.variable||"obj")+"){\n"+e+"}";return d};a.chain=function(b){return a(b).chain()};a.mixin(a);b("pop push reverse shift sort splice unshift".split(" "),function(b){var d=e[b];a.prototype[b]=function(){var k=this._wrapped;d.apply(k,arguments);"shift"!=b&&"splice"!=b||0!==k.length||delete k[0];return this._chain?a(k).chain():k}});b(["concat","join","slice"],function(b){var d=e[b];a.prototype[b]=function(){var b=d.apply(this._wrapped,
|
||||
arguments);return this._chain?a(b).chain():b}});a.extend(a.prototype,{chain:function(){this._chain=!0;return this},value:function(){return this._wrapped}})}).call(this);var Backbone=Backbone||{};
|
||||
(function(){var C=[].slice,r=function(e,m,g){var c;e=-1;var p=m.length;switch(g.length){case 0:for(;++e<p;)(c=m[e]).callback.call(c.ctx);break;case 1:for(;++e<p;)(c=m[e]).callback.call(c.ctx,g[0]);break;case 2:for(;++e<p;)(c=m[e]).callback.call(c.ctx,g[0],g[1]);break;case 3:for(;++e<p;)(c=m[e]).callback.call(c.ctx,g[0],g[1],g[2]);break;default:for(;++e<p;)(c=m[e]).callback.apply(c.ctx,g)}},g=Backbone.Events={on:function(e,g,n){this._events||(this._events={});(this._events[e]||(this._events[e]=[])).push({callback:g,
|
||||
context:n,ctx:n||this});return this},once:function(e,g,n){var c=this,p=_.once(function(){c.off(e,p);g.apply(this,arguments)});p._callback=g;this.on(e,p,n);return this},off:function(e,g,n){var c,p,l,D,r,s,y,d;if(!this._events)return this;if(!e&&!g&&!n)return this._events={},this;D=e?[e]:_.keys(this._events);r=0;for(s=D.length;r<s;r++)if(e=D[r],c=this._events[e]){l=[];if(g||n)for(y=0,d=c.length;y<d;y++)p=c[y],(g&&g!==(p.callback._callback||p.callback)||n&&n!==p.context)&&l.push(p);this._events[e]=l}return this},
|
||||
trigger:function(e){if(!this._events)return this;var g=C.call(arguments,1),n=this._events[e],c=this._events.all;n&&r(this,n,g);c&&r(this,c,arguments);return this},listenTo:function(e,g,n){var c=this._listeners||(this._listeners={}),p=e._listenerId||(e._listenerId=_.uniqueId("l"));c[p]=e;e.on(g,n||this,this);return this},stopListening:function(e,g,n){var c=this._listeners;if(c){if(e)e.off(g,n,this),g||n||delete c[e._listenerId];else{for(var p in c)c[p].off(null,null,this);this._listeners={}}return this}}};
|
||||
g.bind=g.on;g.unbind=g.off;"undefined"!==typeof exports&&("undefined"!==typeof module&&module.exports&&(exports=module.exports=g),exports.Backbone=exports.Backbone||Backbone)})();(function(){function C(e,c){var p=(new Date).getTime(),l=Math.max(0,16-(p-g)),m=r.setTimeout(function(){e(p+l)},l);g=p+l;return m}var r=this,g=0,e=["ms","moz","webkit","o"];if("undefined"!==typeof exports)"undefined"!==typeof module&&module.exports&&(exports=module.exports=C),exports.requestAnimationFrame=C;else{for(var m=0;m<e.length&&!r.requestAnimationFrame;++m)r.requestAnimationFrame=r[e[m]+"RequestAnimationFrame"],r.cancelAnimationFrame=r[e[m]+"CancelAnimationFrame"]||r[e[m]+"CancelRequestAnimationFrame"];
|
||||
r.requestAnimationFrame||(r.requestAnimationFrame=C);r.cancelAnimationFrame||(r.cancelAnimationFrame=function(e){clearTimeout(e)})}})();(function(){function C(){var a=document.body.getBoundingClientRect(),b=this.width=a.width,a=this.height=a.height;this.renderer.setSize(b,a,this.ratio);this.trigger(d.Events.resize,b,a)}var r=this,g=r.Two||{},e=Math.sin,m=Math.cos,n=Math.atan2,c=Math.sqrt,p=Math.PI,l=2*p,D=p/2,F=Math.pow,s=0,y={hasEventListeners:_.isFunction(r.addEventListener),bind:function(a,b,d,c){this.hasEventListeners?a.addEventListener(b,d,!!c):a.attachEvent("on"+b,d);return this},unbind:function(a,b,d,c){this.hasEventListeners?
|
||||
a.removeEventListeners(b,d,!!c):a.detachEvent("on"+b,d);return this}},d=r.Two=function(a){a=_.defaults(a||{},{fullscreen:!1,width:640,height:480,type:d.Types.svg,autostart:!1});_.each(a,function(a,d){"fullscreen"!==d&&("width"!==d&&"height"!==d&&"autostart"!==d)&&(this[d]=a)},this);_.isElement(a.domElement)&&(this.type=d.Types[a.domElement.tagName.toLowerCase()]);this.renderer=new d[this.type](this);d.Utils.setPlaying.call(this,a.autostart);this.frameCount=0;a.fullscreen?(a=_.bind(C,this),_.extend(document.body.style,
|
||||
{overflow:"hidden",margin:0,padding:0,top:0,left:0,right:0,bottom:0,position:"fixed"}),_.extend(this.renderer.domElement.style,{display:"block",top:0,left:0,right:0,bottom:0,position:"fixed"}),y.bind(r,"resize",a),a()):_.isElement(a.domElement)||(this.renderer.setSize(a.width,a.height,this.ratio),this.width=a.width,this.height=a.height);this.scene=this.renderer.scene;d.Instances.push(this)};_.extend(d,{Array:r.Float32Array||Array,Types:{webgl:"WebGLRenderer",svg:"SVGRenderer",canvas:"CanvasRenderer"},
|
||||
Version:"v0.4.0",Identifier:"two-",Properties:{hierarchy:"hierarchy",demotion:"demotion"},Events:{play:"play",pause:"pause",update:"update",render:"render",resize:"resize",change:"change",remove:"remove",insert:"insert"},Commands:{move:"M",line:"L",curve:"C",close:"Z"},Resolution:8,Instances:[],noConflict:function(){r.Two=g;return this},uniqueId:function(){var a=s;s++;return a},Utils:{release:function(a){_.isObject(a)&&(_.isFunction(a.unbind)&&a.unbind(),a.vertices&&(_.isFunction(a.vertices.unbind)&&
|
||||
a.vertices.unbind(),_.each(a.vertices,function(a){_.isFunction(a.unbind)&&a.unbind()})),a.children&&_.each(a.children,function(a){d.Utils.release(a)}))},Curve:{CollinearityEpsilon:F(10,-30),RecursionLimit:16,CuspLimit:0,Tolerance:{distance:0.25,angle:0,epsilon:0.01}},devicePixelRatio:r.devicePixelRatio||1,getBackingStoreRatio:function(a){return a.webkitBackingStorePixelRatio||a.mozBackingStorePixelRatio||a.msBackingStorePixelRatio||a.oBackingStorePixelRatio||a.backingStorePixelRatio||1},getRatio:function(a){return d.Utils.devicePixelRatio/
|
||||
H(a)},setPlaying:function(a){this.playing=!!a;return this},getComputedMatrix:function(a,b){var k=[];b=b&&b.identity()||new d.Matrix;for(var c=a;c&&c._matrix;)k.push(c._matrix),c=c.parent;k.reverse();_.each(k,function(a){a=a.elements;b.multiply(a[0],a[1],a[2],a[3],a[4],a[5],a[6],a[7],a[8],a[9])});return b},applySvgAttributes:function(a,b){_.each(a.attributes,function(a,d){switch(a.nodeName){case "visibility":b.visible=!!a.nodeValue;break;case "stroke-linecap":b.cap=a.nodeValue;break;case "stroke-linejoin":b.join=
|
||||
a.nodeValue;break;case "stroke-miterlimit":b.miter=a.nodeValue;break;case "stroke-width":b.linewidth=parseFloat(a.nodeValue);break;case "stroke-opacity":case "fill-opacity":case "opacity":b.opacity=a.nodeValue;break;case "fill":b.fill=a.nodeValue;break;case "stroke":b.stroke=a.nodeValue}});return b},read:{svg:function(){return d.Utils.read.g.apply(this,arguments)},g:function(a){var b=new d.Group;this.add(b);_.each(a.childNodes,function(a){var c=a.nodeName;c&&(c=c.replace(/svg\:/ig,"").toLowerCase(),
|
||||
c in d.Utils.read&&(a=d.Utils.read[c].call(this,a),b.add(a)))},this);return d.Utils.applySvgAttributes(a,b)},polygon:function(a,b){var k=[];a.getAttribute("points").replace(/([\d\.?]+),([\d\.?]+)/g,function(a,b,c){k.push(new d.Anchor(parseFloat(b),parseFloat(c)))});var c=(new d.Polygon(k,!b)).noStroke();c.fill="black";return d.Utils.applySvgAttributes(a,c)},polyline:function(a){return d.Utils.read.polygon(a,!0)},path:function(a){var b,k,c,e=!1,l=!1,g=a.getAttribute("d").match(/[a-df-z][^a-df-z]*/ig),
|
||||
p=g.length-1,g=_.flatten(_.map(g,function(a,g){var m,t,I=a[0],q=I.toLowerCase();c=a.slice(1).trim();c=c.replace(/(-?\d+(?:\.\d*)?)[eE]([+\-]?\d+)/g,function(a,b,d){return parseFloat(b)*Math.pow(10,d)});c=c.split(/[\s,]+|(?=\s?[+\-])/);e=I===q;var f,h,w,n;switch(q){case "z":g>=p?l=!0:(t=b.x,m=b.y,m=new d.Anchor(t,m,void 0,void 0,void 0,void 0,d.Commands.close));break;case "m":case "l":t=parseFloat(c[0]);m=parseFloat(c[1]);m=new d.Anchor(t,m,void 0,void 0,void 0,void 0,"m"===q?d.Commands.move:d.Commands.line);
|
||||
e&&m.addSelf(b);b=m;break;case "h":case "v":t="h"===q?"x":"y";I="x"===t?"y":"x";m=new d.Anchor(void 0,void 0,void 0,void 0,void 0,void 0,d.Commands.line);m[t]=parseFloat(c[0]);m[I]=b[I];e&&(m[t]+=b[t]);b=m;break;case "s":case "c":m=b.x;I=b.y;k||(k=(new d.Vector).copy(b));"c"===q?(f=parseFloat(c[0]),t=parseFloat(c[1]),q=parseFloat(c[2]),h=parseFloat(c[3]),w=parseFloat(c[4]),n=parseFloat(c[5])):(h=d.Utils.getReflection(b,k,e),f=h.x,t=h.y,q=parseFloat(c[0]),h=parseFloat(c[1]),w=parseFloat(c[2]),n=parseFloat(c[3]));
|
||||
e&&(f+=m,t+=I,q+=m,h+=I,w+=m,n+=I);_.isObject(b.controls)||d.Anchor.AppendCurveProperties(b);b.controls.right.set(f-b.x,t-b.y);b=m=new d.Anchor(w,n,q-w,h-n,void 0,void 0,d.Commands.curve);k=m.controls.left;break;case "t":case "q":m=b.x;I=b.y;k||(k=(new d.Vector).copy(b));k.isZero()?(f=m,t=I):(f=k.x,I=k.y);"q"===q?(q=parseFloat(c[0]),h=parseFloat(c[1]),w=parseFloat(c[1]),n=parseFloat(c[2])):(h=d.Utils.getReflection(b,k,e),q=h.x,h=h.y,w=parseFloat(c[0]),n=parseFloat(c[1]));e&&(f+=m,t+=I,q+=m,h+=I,w+=
|
||||
m,n+=I);_.isObject(b.controls)||d.Anchor.AppendCurveProperties(b);b.controls.right.set(f-b.x,t-b.y);b=m=new d.Anchor(w,n,q-w,h-n,void 0,void 0,d.Commands.curve);k=m.controls.left;break;case "a":throw new d.Utils.Error("not yet able to interpret Elliptical Arcs.");}return m}));if(!(1>=g.length))return g=_.compact(g),g=(new d.Polygon(g,l,void 0,!0)).noStroke(),g.fill="black",d.Utils.applySvgAttributes(a,g)},circle:function(a){var b=parseFloat(a.getAttribute("cx")),c=parseFloat(a.getAttribute("cy")),
|
||||
v=parseFloat(a.getAttribute("r")),g=d.Resolution,u=_.map(_.range(g),function(a){var b=a/g*l;a=v*m(b);b=v*e(b);return new d.Anchor(a,b)},this),u=(new d.Polygon(u,!0,!0)).noStroke();u.translation.set(b,c);u.fill="black";return d.Utils.applySvgAttributes(a,u)},ellipse:function(a){var b=parseFloat(a.getAttribute("cx")),c=parseFloat(a.getAttribute("cy")),v=parseFloat(a.getAttribute("rx")),g=parseFloat(a.getAttribute("ry")),u=d.Resolution,p=_.map(_.range(u),function(a){var b=a/u*l;a=v*m(b);b=g*e(b);return new d.Anchor(a,
|
||||
b)},this),p=(new d.Polygon(p,!0,!0)).noStroke();p.translation.set(b,c);p.fill="black";return d.Utils.applySvgAttributes(a,p)},rect:function(a){var b=parseFloat(a.getAttribute("x")),c=parseFloat(a.getAttribute("y")),e=parseFloat(a.getAttribute("width")),l=parseFloat(a.getAttribute("height")),e=e/2,l=l/2,g=[new d.Anchor(e,l),new d.Anchor(-e,l),new d.Anchor(-e,-l),new d.Anchor(e,-l)],g=(new d.Polygon(g,!0)).noStroke();g.translation.set(b+e,c+l);g.fill="black";return d.Utils.applySvgAttributes(a,g)},
|
||||
line:function(a){var b=parseFloat(a.getAttribute("x1")),c=parseFloat(a.getAttribute("y1")),e=parseFloat(a.getAttribute("x2")),l=parseFloat(a.getAttribute("y2")),e=(e-b)/2,l=(l-c)/2,g=[new d.Anchor(-e,-l),new d.Anchor(e,l)],g=(new d.Polygon(g)).noFill();g.translation.set(b+e,c+l);return d.Utils.applySvgAttributes(a,g)}},subdivide:function(a,b,c,e,l,g,m,p,q){q=q||d.Utils.Curve.RecursionLimit;var w=q+1;return _.map(_.range(0,w),function(q){var t=q/w;q=G(t,a,c,l,m);t=G(t,b,e,g,p);return new d.Anchor(q,
|
||||
t)})},getPointOnCubicBezier:function(a,b,d,c,e){var l=1-a;return l*l*l*b+3*l*l*a*d+3*l*a*a*c+a*a*a*e},getCurveFromPoints:function(a,b){for(var c=a.length,e=c-1,l=0;l<c;l++){var g=a[l];_.isObject(g.controls)||d.Anchor.AppendCurveProperties(g);var m=b?B(l-1,c):Math.max(l-1,0),p=b?B(l+1,c):Math.min(l+1,e);x(a[m],g,a[p]);g._command=0===l?d.Commands.move:d.Commands.curve;g.controls.left.x=_.isNumber(g.controls.left.x)?g.controls.left.x:g.x;g.controls.left.y=_.isNumber(g.controls.left.y)?g.controls.left.y:
|
||||
g.y;g.controls.right.x=_.isNumber(g.controls.right.x)?g.controls.right.x:g.x;g.controls.right.y=_.isNumber(g.controls.right.y)?g.controls.right.y:g.y}},getControlPoints:function(a,b,c){var l=w(a,b),g=w(c,b);a=z(a,b);c=z(c,b);var q=(l+g)/2;b.u=_.isObject(b.controls.left)?b.controls.left:new d.Vector(0,0);b.v=_.isObject(b.controls.right)?b.controls.right:new d.Vector(0,0);if(1E-4>a||1E-4>c)return b._relative||(b.controls.left.copy(b),b.controls.right.copy(b)),b;a*=0.33;c*=0.33;q=g<l?q+D:q-D;b.controls.left.x=
|
||||
m(q)*a;b.controls.left.y=e(q)*a;q-=p;b.controls.right.x=m(q)*c;b.controls.right.y=e(q)*c;b._relative||(b.controls.left.x+=b.x,b.controls.left.y+=b.y,b.controls.right.x+=b.x,b.controls.right.y+=b.y);return b},getReflection:function(a,b,c){var e=b.distanceTo(d.Vector.zero);b=w(d.Vector.zero,b);return new d.Vector(e*Math.cos(b)+(c?0:a.x),e*Math.sin(b)+(c?0:a.y))},angleBetween:function(a,b){var d,c;if(4<=arguments.length)return d=arguments[0]-arguments[2],c=arguments[1]-arguments[3],n(c,d);d=a.x-b.x;
|
||||
c=a.y-b.y;return n(c,d)},distanceBetweenSquared:function(a,b){var d=a.x-b.x,c=a.y-b.y;return d*d+c*c},distanceBetween:function(a,b){return c(q(a,b))},mod:function(a,b){for(;0>a;)a+=b;return a%b},Collection:function(){Array.call(this);1<arguments.length?Array.prototype.push.apply(this,arguments):arguments[0]&&Array.isArray(arguments[0])&&Array.prototype.push.apply(this,arguments[0])},Error:function(a){this.name="two.js";this.message=a}}});d.Utils.Error.prototype=Error();d.Utils.Error.prototype.constructor=
|
||||
d.Utils.Error;d.Utils.Collection.prototype=[];d.Utils.Collection.constructor=d.Utils.Collection;_.extend(d.Utils.Collection.prototype,Backbone.Events,{pop:function(){var a=Array.prototype.pop.apply(this,arguments);this.trigger(d.Events.remove,[a]);return a},shift:function(){var a=Array.prototype.shift.apply(this,arguments);this.trigger(d.Events.remove,[a]);return a},push:function(){var a=Array.prototype.push.apply(this,arguments);this.trigger(d.Events.insert,arguments);return a},unshift:function(){var a=
|
||||
Array.prototype.unshift.apply(this,arguments);this.trigger(d.Events.insert,arguments);return a},splice:function(){var a=Array.prototype.splice.apply(this,arguments),b;this.trigger(d.Events.remove,a);2<arguments.length&&(b=this.slice(arguments[0],arguments.length-2),this.trigger(d.Events.insert,b));return a}});var z=d.Utils.distanceBetween,q=d.Utils.distanceBetweenSquared,w=d.Utils.angleBetween,x=d.Utils.getControlPoints,B=d.Utils.mod,H=d.Utils.getBackingStoreRatio,G=d.Utils.getPointOnCubicBezier;
|
||||
_.extend(d.prototype,Backbone.Events,{appendTo:function(a){a.appendChild(this.renderer.domElement);return this},play:function(){d.Utils.setPlaying.call(this,!0);return this.trigger(d.Events.play)},pause:function(){this.playing=!1;return this.trigger(d.Events.pause)},update:function(){var a=!!this._lastFrame,b=(r.performance&&r.performance.now?r.performance:Date).now();this.frameCount++;a&&(this.timeDelta=parseFloat((b-this._lastFrame).toFixed(3)));this._lastFrame=b;var a=this.width,b=this.height,
|
||||
c=this.renderer;a===c.width&&b===c.height||c.setSize(a,b,this.ratio);this.trigger(d.Events.update,this.frameCount,this.timeDelta);return this.render()},render:function(){this.renderer.render();return this.trigger(d.Events.render,this.frameCount)},add:function(a){var b=a;_.isArray(a)||(b=_.toArray(arguments));this.scene.add(b);return this},remove:function(a){var b=a;_.isArray(a)||(b=_.toArray(arguments));this.scene.remove(b);return this},clear:function(){this.scene.remove(_.toArray(this.scene.children));
|
||||
return this},makeLine:function(a,b,c,e){c=(c-a)/2;e=(e-b)/2;var l=[new d.Anchor(-c,-e),new d.Anchor(c,e)],l=(new d.Polygon(l)).noFill();l.translation.set(a+c,b+e);this.scene.add(l);return l},makeRectangle:function(a,b,c,e){c/=2;e/=2;e=[new d.Anchor(c,e),new d.Anchor(-c,e),new d.Anchor(-c,-e),new d.Anchor(c,-e)];e=new d.Polygon(e,!0);e.translation.set(a,b);this.scene.add(e);return e},makeCircle:function(a,b,d){return this.makeEllipse(a,b,d,d)},makeEllipse:function(a,b,c,g){var q=d.Resolution,p=_.map(_.range(q),
|
||||
function(a){var b=a/q*l;a=c*m(b);b=g*e(b);return new d.Anchor(a,b)},this),p=new d.Polygon(p,!0,!0);p.translation.set(a,b);this.scene.add(p);return p},makeCurve:function(a){var b=arguments.length,c=a;if(!_.isArray(a))for(var c=[],e=0;e<b;e+=2){var l=arguments[e];if(!_.isNumber(l))break;c.push(new d.Anchor(l,arguments[e+1]))}var b=arguments[b-1],c=new d.Polygon(c,!(_.isBoolean(b)&&b),!0),b=c.getBoundingClientRect(),g=b.left+b.width/2,m=b.top+b.height/2;_.each(c.vertices,function(a){a.x-=g;a.y-=m});
|
||||
c.translation.set(g,m);this.scene.add(c);return c},makePolygon:function(a){var b=arguments.length,c=a;if(!_.isArray(a))for(var c=[],e=0;e<b;e+=2){var l=arguments[e];if(!_.isNumber(l))break;c.push(new d.Anchor(l,arguments[e+1]))}b=arguments[b-1];c=new d.Polygon(c,!(_.isBoolean(b)&&b));b=c.getBoundingClientRect();c.center().translation.set(b.left+b.width/2,b.top+b.height/2);this.scene.add(c);return c},makeGroup:function(a){var b=a;_.isArray(a)||(b=_.toArray(arguments));var c=new d.Group;this.scene.add(c);
|
||||
c.add(b);return c},interpret:function(a){var b=a.tagName.toLowerCase();if(!(b in d.Utils.read))return null;a=d.Utils.read[b].call(this,a);this.add(a);return a}});(function(){requestAnimationFrame(arguments.callee);_.each(d.Instances,function(a){a.playing&&a.update()})})();"function"===typeof define&&define.amd?define(function(){return d}):"undefined"!=typeof module&&module.exports&&(module.exports=d)})();(function(){var C,r,g,e,m=Two.Vector=function(c,e){this.x=c||0;this.y=e||0};_.extend(m,{zero:new Two.Vector});_.extend(m.prototype,Backbone.Events,{set:function(c,e){this.x=c;this.y=e;return this},copy:function(c){this.x=c.x;this.y=c.y;return this},clear:function(){this.y=this.x=0;return this},clone:function(){return new m(this.x,this.y)},add:function(c,e){this.x=c.x+e.x;this.y=c.y+e.y;return this},addSelf:function(c){this.x+=c.x;this.y+=c.y;return this},sub:function(c,e){this.x=c.x-e.x;this.y=c.y-
|
||||
e.y;return this},subSelf:function(c){this.x-=c.x;this.y-=c.y;return this},multiplySelf:function(c){this.x*=c.x;this.y*=c.y;return this},multiplyScalar:function(c){this.x*=c;this.y*=c;return this},divideScalar:function(c){c?(this.x/=c,this.y/=c):this.set(0,0);return this},negate:function(){return this.multiplyScalar(-1)},dot:function(c){return this.x*c.x+this.y*c.y},lengthSquared:function(){return this.x*this.x+this.y*this.y},length:function(){return Math.sqrt(this.lengthSquared())},normalize:function(){return this.divideScalar(this.length())},
|
||||
distanceTo:function(c){return Math.sqrt(this.distanceToSquared(c))},distanceToSquared:function(c){g=this.x-c.x;e=this.y-c.y;return g*g+e*e},setLength:function(c){return this.normalize().multiplyScalar(c)},equals:function(c){return 1E-4>this.distanceTo(c)},lerp:function(c,e){C=(c.x-this.x)*e+this.x;r=(c.y-this.y)*e+this.y;return this.set(C,r)},isZero:function(){return 1E-4>this.length()},toString:function(){return this.x+","+this.y},toObject:function(){return{x:this.x,y:this.y}}});var n={set:function(c,
|
||||
e){this._x=c;this._y=e;return this.trigger(Two.Events.change)},copy:function(c){this._x=c.x;this._y=c.y;return this.trigger(Two.Events.change)},clear:function(){this._y=this._x=0;return this.trigger(Two.Events.change)},clone:function(){return new m(this._x,this._y)},add:function(c,e){this._x=c.x+e.x;this._y=c.y+e.y;return this.trigger(Two.Events.change)},addSelf:function(c){this._x+=c.x;this._y+=c.y;return this.trigger(Two.Events.change)},sub:function(c,e){this._x=c.x-e.x;this._y=c.y-e.y;return this.trigger(Two.Events.change)},
|
||||
subSelf:function(c){this._x-=c.x;this._y-=c.y;return this.trigger(Two.Events.change)},multiplySelf:function(c){this._x*=c.x;this._y*=c.y;return this.trigger(Two.Events.change)},multiplyScalar:function(c){this._x*=c;this._y*=c;return this.trigger(Two.Events.change)},divideScalar:function(c){return c?(this._x/=c,this._y/=c,this.trigger(Two.Events.change)):this.clear()},negate:function(){return this.multiplyScalar(-1)},dot:function(c){return this._x*c.x+this._y*c.y},lengthSquared:function(){return this._x*
|
||||
this._x+this._y*this._y},length:function(){return Math.sqrt(this.lengthSquared())},normalize:function(){return this.divideScalar(this.length())},distanceTo:function(c){return Math.sqrt(this.distanceToSquared(c))},distanceToSquared:function(c){g=this._x-c.x;e=this._y-c.y;return g*g+e*e},setLength:function(c){return this.normalize().multiplyScalar(c)},equals:function(c){return 1E-4>this.distanceTo(c)},lerp:function(c,e){C=(c.x-this._x)*e+this._x;r=(c.y-this._y)*e+this._y;return this.set(C,r)},isZero:function(){return 1E-4>
|
||||
this.length()},toString:function(){return this._x+","+this._y},toObject:function(){return{x:this._x,y:this._y}}},c={get:function(){return this._x},set:function(c){this._x=c;this.trigger(Two.Events.change,"x")}},p={get:function(){return this._y},set:function(c){this._y=c;this.trigger(Two.Events.change,"y")}};Two.Vector.prototype.bind=Two.Vector.prototype.on=function(){this._bound||(this._x=this.x,this._y=this.y,Object.defineProperty(this,"x",c),Object.defineProperty(this,"y",p),_.extend(this,n),this._bound=
|
||||
!0);Backbone.Events.bind.apply(this,arguments);return this}})();(function(){var C=Two.Commands,r,g,e,m=Two.Anchor=function(c,e,g,n,r,s,y){Two.Vector.call(this,c,e);this._broadcast=_.bind(function(){this.trigger(Two.Events.change)},this);this._command=y||C.move;this._relative=!0;if(!y)return this;m.AppendCurveProperties(this);_.isNumber(g)&&(this.controls.left.x=g);_.isNumber(n)&&(this.controls.left.y=n);_.isNumber(r)&&(this.controls.right.x=r);_.isNumber(s)&&(this.controls.right.y=s)};_.extend(m,{AppendCurveProperties:function(c){c.controls={left:new Two.Vector(0,
|
||||
0),right:new Two.Vector(0,0)}}});var n={listen:function(){_.isObject(this.controls)||m.AppendCurveProperties(this);_.each(this.controls,function(c){c.bind(Two.Events.change,this._broadcast)},this);return this},ignore:function(){_.each(this.controls,function(c){c.unbind(Two.Events.change,this._broadcast)},this);return this},clone:function(){g=this.controls;e=new Two.Anchor(this.x,this.y,g&&g.left.x,g&&g.left.y,g&&g.right.x,g&&g.right.y,this.command);e.relative=this._relative;return e},toObject:function(){r=
|
||||
{x:this.x,y:this.y};this._command&&(r.command=this._command);this._relative&&(r.relative=this._relative);this.controls&&(r.controls={left:this.controls.left.toObject(),right:this.controls.right.toObject()});return r}};Object.defineProperty(m.prototype,"command",{get:function(){return this._command},set:function(c){this._command=c;this._command!==C.curve||_.isObject(this.controls)||m.AppendCurveProperties(this);return this.trigger(Two.Events.change)}});Object.defineProperty(m.prototype,"relative",
|
||||
{get:function(){return this._relative},set:function(c){if(this._relative==c)return this;this._relative=!!c;return this.trigger(Two.Events.change)}});_.extend(m.prototype,Two.Vector.prototype,n);Two.Anchor.prototype.bind=Two.Anchor.prototype.on=function(){Two.Vector.prototype.bind.apply(this,arguments);_.extend(this,n)};Two.Anchor.prototype.unbind=Two.Anchor.prototype.off=function(){Two.Vector.prototype.unbind.apply(this,arguments);_.extend(this,n)}})();(function(){_.range(6);var C=Math.cos,r=Math.sin,g=Math.tan,e,m,n,c,p,l,D,F,s,y,d,z,q,w,x,B,H,G,a,b,k,v,K,u,A,L,J,O,M,t,I,T,f,h,E,ea,P,Q,aa,da,U,V,W,X,Y,ba,ca,Z,R,$=[],fa=Two.Matrix=function(a,b,d,c,f,e){this.elements=new Two.Array(9);var g=a;_.isArray(g)||(g=_.toArray(arguments));this.identity().set(g)};_.extend(fa,{Identity:[1,0,0,0,1,0,0,0,1],Multiply:function(d,c,f){if(3>=c.length)return z,q,w,e=c[0]||0,m=c[1]||0,n=c[2]||0,p=d,z=p[0]*e+p[1]*m+p[2]*n,q=p[3]*e+p[4]*m+p[5]*n,w=p[6]*e+p[7]*m+p[8]*
|
||||
n,{x:z,y:q,z:w};x=d[0];B=d[1];H=d[2];G=d[3];a=d[4];b=d[5];k=d[6];v=d[7];K=d[8];u=c[0];A=c[1];L=c[2];J=c[3];O=c[4];M=c[5];t=c[6];I=c[7];T=c[8];f=f||new Two.Array(9);f[0]=x*u+B*J+H*t;f[1]=x*A+B*O+H*I;f[2]=x*L+B*M+H*T;f[3]=G*u+a*J+b*t;f[4]=G*A+a*O+b*I;f[5]=G*L+a*M+b*T;f[6]=k*u+v*J+K*t;f[7]=k*A+v*O+K*I;f[8]=k*L+v*M+K*T;return f}});_.extend(fa.prototype,Backbone.Events,{set:function(a,b,c,f,e,g){d=a;E=arguments.length;_.isArray(d)||(d=_.toArray(arguments));_.each(d,function(a,b){_.isNumber(a)&&(this.elements[b]=
|
||||
a)},this);return this.trigger(Two.Events.change)},identity:function(){this.set(fa.Identity);return this},multiply:function(c,e,g,m,l,p,n,s,ma){d=arguments;E=d.length;if(1>=E)return _.each(this.elements,function(a,b){this.elements[b]=a*c},this),this.trigger(Two.Events.change);if(3>=E)return z,q,w,c=c||0,e=e||0,g=g||0,l=this.elements,z=l[0]*c+l[1]*e+l[2]*g,q=l[3]*c+l[4]*e+l[5]*g,w=l[6]*c+l[7]*e+l[8]*g,{x:z,y:q,z:w};f=this.elements;h=d;x=f[0];B=f[1];H=f[2];G=f[3];a=f[4];b=f[5];k=f[6];v=f[7];K=f[8];u=
|
||||
h[0];A=h[1];L=h[2];J=h[3];O=h[4];M=h[5];t=h[6];I=h[7];T=h[8];this.elements[0]=x*u+B*J+H*t;this.elements[1]=x*A+B*O+H*I;this.elements[2]=x*L+B*M+H*T;this.elements[3]=G*u+a*J+b*t;this.elements[4]=G*A+a*O+b*I;this.elements[5]=G*L+a*M+b*T;this.elements[6]=k*u+v*J+K*t;this.elements[7]=k*A+v*O+K*I;this.elements[8]=k*L+v*M+K*T;return this.trigger(Two.Events.change)},inverse:function(a){e=this.elements;a=a||new Two.Matrix;P=e[0];Q=e[1];aa=e[2];da=e[3];U=e[4];V=e[5];W=e[6];X=e[7];Y=e[8];ba=Y*U-V*X;ca=-Y*da+
|
||||
V*W;Z=X*da-U*W;R=P*ba+Q*ca+aa*Z;if(!R)return null;R=1/R;a.elements[0]=ba*R;a.elements[1]=(-Y*Q+aa*X)*R;a.elements[2]=(V*Q-aa*U)*R;a.elements[3]=ca*R;a.elements[4]=(Y*P-aa*W)*R;a.elements[5]=(-V*P+aa*da)*R;a.elements[6]=Z*R;a.elements[7]=(-X*P+Q*W)*R;a.elements[8]=(U*P-Q*da)*R;return a},scale:function(a,b){E=arguments.length;1>=E&&(b=a);return this.multiply(a,0,0,0,b,0,0,0,1)},rotate:function(a){n=C(a);ea=r(a);return this.multiply(n,-ea,0,ea,n,0,0,0,1)},translate:function(a,b){return this.multiply(1,
|
||||
0,a,0,1,b,0,0,1)},skewX:function(a){e=g(a);return this.multiply(1,e,0,0,1,0,0,0,1)},skewY:function(a){e=g(a);return this.multiply(1,0,0,e,1,0,0,0,1)},toString:function(a){this.toArray(a,$);return $.join(" ")},toArray:function(a,b){d=this.elements;y=!!b;e=parseFloat(d[0].toFixed(3));m=parseFloat(d[1].toFixed(3));n=parseFloat(d[2].toFixed(3));c=parseFloat(d[3].toFixed(3));p=parseFloat(d[4].toFixed(3));l=parseFloat(d[5].toFixed(3));if(a){D=parseFloat(d[6].toFixed(3));F=parseFloat(d[7].toFixed(3));s=
|
||||
parseFloat(d[8].toFixed(3));if(y){b[0]=e;b[1]=c;b[2]=D;b[3]=m;b[4]=p;b[5]=F;b[6]=n;b[7]=l;b[8]=s;return}return[e,c,D,m,p,F,n,l,s]}if(y)b[0]=e,b[1]=c,b[2]=m,b[3]=p,b[4]=n,b[5]=l;else return[e,c,m,p,n,l]},clone:function(){e=this.elements[0];m=this.elements[1];n=this.elements[2];c=this.elements[3];p=this.elements[4];l=this.elements[5];D=this.elements[6];F=this.elements[7];s=this.elements[8];return new Two.Matrix(e,m,n,c,p,l,D,F,s)}})})();(function(){var C=Two.Utils.mod,r,g,e,m={version:1.1,ns:"http://www.w3.org/2000/svg",xlink:"http://www.w3.org/1999/xlink",createElement:function(c,p){e=c;g=document.createElementNS(this.ns,e);"svg"===e&&(p=_.defaults(p||{},{version:this.version}));_.isObject(p)&&m.setAttributes(g,p);return g},setAttribute:function(c,e){this.setAttribute(e,c)},setAttributes:function(c,e){_.each(e,m.setAttribute,c);return this},removeAttribute:function(c,e){this.removeAttribute(e)},removeAttributes:function(c,e){_.each(e,
|
||||
m.removeAttribute,c);return this},toString:function(c,e){var g=c.length,m=g-1,n;return _.map(c,function(s,r){var d,z=e?C(r-1,g):Math.max(r-1,0),q=e?C(r+1,g):Math.min(r+1,m);d=c[z];var w=c[q],x,B,H,z=s.x.toFixed(3),w=s.y.toFixed(3);switch(s._command){case Two.Commands.close:d=Two.Commands.close;break;case Two.Commands.curve:x=d.controls&&d.controls.right||d;H=s.controls&&s.controls.left||s;d._relative?(q=(x.x+d.x).toFixed(3),x=(x.y+d.y).toFixed(3)):(q=x.x.toFixed(3),x=x.y.toFixed(3));s._relative?(B=
|
||||
(H.x+s.x).toFixed(3),H=(H.y+s.y).toFixed(3)):(B=H.x.toFixed(3),H=H.y.toFixed(3));d=(0===r?Two.Commands.move:Two.Commands.curve)+" "+q+" "+x+" "+B+" "+H+" "+z+" "+w;break;case Two.Commands.move:n=s;d=Two.Commands.move+" "+z+" "+w;break;default:d=s._command+" "+z+" "+w}r>=m&&e&&(s._command===Two.Commands.curve&&(w=n,x=s.controls&&s.controls.right||s,z=w.controls&&w.controls.left||w,s._relative?(q=(x.x+s.x).toFixed(3),x=(x.y+s.y).toFixed(3)):(q=x.x.toFixed(3),x=x.y.toFixed(3)),w._relative?(B=(z.x+w.x).toFixed(3),
|
||||
H=(z.y+w.y).toFixed(3)):(B=z.x.toFixed(3),H=z.y.toFixed(3)),z=w.x.toFixed(3),w=w.y.toFixed(3),d+=" C "+q+" "+x+" "+B+" "+H+" "+z+" "+w),d+=" Z");return d}).join(" ")},group:{appendChild:function(c){(g=this.domElement.querySelector("#"+Two.Identifier+c))&&this.elem.appendChild(g)},removeChild:function(c){(g=this.domElement.querySelector("#"+Two.Identifier+c))&&this.elem.removeChild(g)},renderChild:function(c){m[c._renderer.type].render.call(c,this)},render:function(c){this._update();this._renderer.elem||
|
||||
(this._renderer.elem=m.createElement("g",{id:Two.Identifier+this.id}),c.appendChild(this._renderer.elem));r=this._matrix.manual||this._flagMatrix;var e={domElement:c,elem:this._renderer.elem};r&&this._renderer.elem.setAttribute("transform","matrix("+this._matrix.toString()+")");_.each(this.children,m.group.renderChild,c);this._flagAdditions&&_.each(this.additions,m.group.appendChild,e);this._flagSubtractions&&_.each(this.subtractions,m.group.removeChild,e);return this.flagReset()}},polygon:{render:function(c){this._update();
|
||||
this._renderer.elem||(this._renderer.elem=m.createElement("path",{id:Two.Identifier+this.id}),c.appendChild(this._renderer.elem));g=this._renderer.elem;(r=this._matrix.manual||this._flagMatrix)&&g.setAttribute("transform","matrix("+this._matrix.toString()+")");this._flagVertices&&(vertices=m.toString(this._vertices,this._closed),g.setAttribute("d",vertices));this._flagFill&&g.setAttribute("fill",this._fill);this._flagStroke&&g.setAttribute("stroke",this._stroke);this._flagLinewidth&&g.setAttribute("stroke-width",
|
||||
this._linewidth);this._flagOpacity&&(g.setAttribute("stroke-opacity",this._opacity),g.setAttribute("fill-opacity",this._opacity));this._flagVisible&&g.setAttribute("visibility",this._visible?"visible":"hidden");this._flagCap&&g.setAttribute("stroke-linecap",this._cap);this._flagJoin&&g.setAttribute("stroke-linejoin",this._join);this._flagMiter&&g.setAttribute("stroke-miterlimit",this.miter);return this.flagReset()}}},n=Two[Two.Types.svg]=function(c){this.domElement=c.domElement||m.createElement("svg");
|
||||
this.scene=new Two.Group;this.scene.parent=this};_.extend(n,{Utils:m});_.extend(n.prototype,Backbone.Events,{setSize:function(c,e){this.width=c;this.height=e;m.setAttributes(this.domElement,{width:c,height:e});return this},render:function(){m.group.render.call(this.scene,this.domElement);return this}})})();(function(){var C=Two.Utils.mod,r=Two.Utils.getRatio,g,e,m,n,c,p,l,D,F,s,y,d,z,q,w,x,B,H,G,a,b,k,v,K,u,A,L,J,O={group:{renderChild:function(a){O[a._renderer.type].render.call(a,this)},render:function(a){this._update();g=this._matrix.elements;a.save();a.transform(g[0],g[3],g[1],g[4],g[2],g[5]);_.each(this.children,O.group.renderChild,a);a.restore();return this.flagReset()}},polygon:{render:function(t){this._update();g=this._matrix.elements;e=this.stroke;m=this.linewidth;n=this.fill;c=this.opacity;
|
||||
p=this.visible;l=this.cap;D=this.join;F=this.miter;s=this.closed;y=this._vertices;d=y.length;z=d-1;if(!p)return this;t.save();g&&t.transform(g[0],g[3],g[1],g[4],g[2],g[5]);n&&(t.fillStyle=n);e&&(t.strokeStyle=e);m&&(t.lineWidth=m);F&&(t.miterLimit=F);D&&(t.lineJoin=D);l&&(t.lineCap=l);_.isNumber(c)&&(t.globalAlpha=c);t.beginPath();_.each(y,function(c,e){L=c.x.toFixed(3);J=c.y.toFixed(3);switch(c._command){case Two.Commands.close:t.closePath();break;case Two.Commands.curve:w=s?C(e-1,d):Math.max(e-
|
||||
1,0);q=s?C(e+1,d):Math.min(e+1,z);x=y[w];B=y[q];v=x.controls&&x.controls.right||x;K=c.controls&&c.controls.left||c;x._relative?(b=(v.x+x.x).toFixed(3),k=(v.y+x.y).toFixed(3)):(b=v.x.toFixed(3),k=v.y.toFixed(3));c._relative?(G=(K.x+c.x).toFixed(3),a=(K.y+c.y).toFixed(3)):(G=K.x.toFixed(3),a=K.y.toFixed(3));t.bezierCurveTo(b,k,G,a,L,J);e>=z&&s&&(B=H,u=c.controls&&c.controls.right||c,A=B.controls&&B.controls.left||B,c._relative?(b=(u.x+c.x).toFixed(3),k=(u.y+c.y).toFixed(3)):(b=u.x.toFixed(3),k=u.y.toFixed(3)),
|
||||
B._relative?(G=(A.x+B.x).toFixed(3),a=(A.y+B.y).toFixed(3)):(G=A.x.toFixed(3),a=A.y.toFixed(3)),L=B.x.toFixed(3),J=B.y.toFixed(3),t.bezierCurveTo(b,k,G,a,L,J));break;case Two.Commands.line:t.lineTo(L,J);break;case Two.Commands.move:H=c,t.moveTo(L,J)}});s&&t.closePath();t.fill();t.stroke();t.restore();return this.flagReset()}}},M=Two[Two.Types.canvas]=function(a){this.domElement=a.domElement||document.createElement("canvas");this.ctx=this.domElement.getContext("2d");this.overdraw=a.overdraw||!1;this.scene=
|
||||
new Two.Group;this.scene.parent=this};_.extend(M,{Utils:O});_.extend(M.prototype,Backbone.Events,{setSize:function(a,b,c){this.width=a;this.height=b;this.ratio=_.isUndefined(c)?r(this.ctx):c;this.domElement.width=a*this.ratio;this.domElement.height=b*this.ratio;_.extend(this.domElement.style,{width:a+"px",height:b+"px"});return this},render:function(){var a=1===this.ratio;a||(this.ctx.save(),this.ctx.scale(this.ratio,this.ratio));this.overdraw||this.ctx.clearRect(0,0,this.width,this.height);O.group.render.call(this.scene,
|
||||
this.ctx);a||this.ctx.restore();return this}})})();(function(){var C=Two.Matrix.Multiply,r=Two.Utils.mod,g=[1,0,0,0,1,0,0,0,1],e=new Two.Array(9),m=Two.Utils.getRatio,n,c,p,l,D,F,s,y,d,z,q,w,x,B,H,G,a,b,k,v,K,u,A,L,J,O,M,t,I,T,f,h,E,ea,P,Q,aa,da,U,V,W,X,Y,ba,ca,Z,R,$,fa,ga,N,ia,ja,ka,ha,S={canvas:document.createElement("canvas"),uv:new Two.Array([0,0,1,0,0,1,0,1,1,0,1,1]),group:{renderChild:function(a){S[a._renderer.type].render.call(a,this.gl,this.program)},render:function(a,b){this._update();n=this.parent;c=n._matrix&&n._matrix.manual||n._flagMatrix;
|
||||
p=this._matrix.manual||this._flagMatrix;if(c||p)this._renderer.matrix||(this._renderer.matrix=new Two.Array(9)),this._matrix.toArray(!0,e),C(e,n._renderer.matrix,this._renderer.matrix),this._renderer.scale=this._scale*n._renderer.scale,c&&(this._flagMatrix=!0);_.each(this.children,S.group.renderChild,{gl:a,program:b});return this.flagReset()}},polygon:{render:function(a,b){if(!this._visible||!this._opacity)return this;n=this.parent;c=n._matrix.manual||n._flagMatrix;p=this._matrix.manual||this._flagMatrix;
|
||||
l=this._flagVertices||this._flagFill||this._flagStroke||this._flagLinewidth||this._flagOpacity||this._flagVisible||this._flagCap||this._flagJoin||this._flagMiter||this._flagScale;this._update();if(c||p)this._renderer.matrix||(this._renderer.matrix=new Two.Array(9)),this._matrix.toArray(!0,e),C(e,n._renderer.matrix,this._renderer.matrix),this._renderer.scale=this._scale*n._renderer.scale;l&&(this._renderer.rect||(this._renderer.rect={}),this._renderer.triangles||(this._renderer.triangles=new Two.Array(12)),
|
||||
S.getBoundingClientRect(this._vertices,this._linewidth,this._renderer.rect),S.getTriangles(this._renderer.rect,this._renderer.triangles),S.updateBuffer(a,this,b),S.updateTexture(a,this));a.bindBuffer(a.ARRAY_BUFFER,this._renderer.textureCoordsBuffer);a.vertexAttribPointer(b.textureCoords,2,a.FLOAT,!1,0,0);a.bindTexture(a.TEXTURE_2D,this._renderer.texture);a.uniformMatrix3fv(b.matrix,!1,this._renderer.matrix);a.bindBuffer(a.ARRAY_BUFFER,this._renderer.buffer);a.vertexAttribPointer(b.position,2,a.FLOAT,
|
||||
!1,0,0);a.drawArrays(a.TRIANGLES,0,6);return this.flagReset()}},getBoundingClientRect:function(c,e,f){D=Infinity;F=-Infinity;s=Infinity;y=-Infinity;_.each(c,function(b,c){d=b.x;z=b.y;q;w;x;B;H=b.controls;s=Math.min(z,s);D=Math.min(d,D);F=Math.max(d,F);y=Math.max(z,y);b.controls&&(G=H.left,a=H.right,G&&a&&(q=b._relative?G.x+d:G.x,w=b._relative?G.y+z:G.y,x=b._relative?a.x+d:a.x,B=b._relative?a.y+z:a.y,q&&(w&&x&&B)&&(s=Math.min(w,B,s),D=Math.min(q,x,D),F=Math.max(q,x,F),y=Math.max(w,B,y))))});_.isNumber(e)&&
|
||||
(s-=e,D-=e,F+=e,y+=e);b=F-D;k=y-s;f.top=s;f.left=D;f.right=F;f.bottom=y;f.width=b;f.height=k;f.centroid||(f.centroid={});f.centroid.x=-D;f.centroid.y=-s},getTriangles:function(a,b){s=a.top;D=a.left;F=a.right;y=a.bottom;b[0]=D;b[1]=s;b[2]=F;b[3]=s;b[4]=D;b[5]=y;b[6]=D;b[7]=y;b[8]=F;b[9]=s;b[10]=F;b[11]=y},updateCanvas:function(a){v=a._vertices;K=this.canvas;u=this.ctx;A=a._renderer.scale;L=a._stroke;J=a._linewidth*A;O=a._fill;M=a._opacity;t=a._cap;I=a._join;T=a._miter;f=a._closed;h=v.length;E=h-1;
|
||||
K.width=Math.max(Math.ceil(a._renderer.rect.width*A),1);K.height=Math.max(Math.ceil(a._renderer.rect.height*A),1);ea=a._renderer.rect.centroid;P=ea.x*A;Q=ea.y*A;u.clearRect(0,0,K.width,K.height);O&&(u.fillStyle=O);L&&(u.strokeStyle=L);J&&(u.lineWidth=J);T&&(u.miterLimit=T);I&&(u.lineJoin=I);t&&(u.lineCap=t);_.isNumber(M)&&(u.globalAlpha=M);u.beginPath();_.each(v,function(a,b){aa;da;q;x;U;V;W;X;Y;ba;ca;G;d=(a.x*A+P).toFixed(3);z=(a.y*A+Q).toFixed(3);switch(a._command){case Two.Commands.close:u.closePath();
|
||||
break;case Two.Commands.curve:da=f?r(b-1,h):Math.max(b-1,0);aa=f?r(b+1,h):Math.min(b+1,E);q=v[da];x=v[aa];Y=q.controls&&q.controls.right||q;ba=a.controls&&a.controls.left||a;q._relative?(W=((Y.x+q.x)*A+P).toFixed(3),X=((Y.y+q.y)*A+Q).toFixed(3)):(W=(Y.x*A+P).toFixed(3),X=(Y.y*A+Q).toFixed(3));a._relative?(U=((ba.x+a.x)*A+P).toFixed(3),V=((ba.y+a.y)*A+Q).toFixed(3)):(U=(ba.x*A+P).toFixed(3),V=(ba.y*A+Q).toFixed(3));u.bezierCurveTo(W,X,U,V,d,z);b>=E&&f&&(x=B,ca=a.controls&&a.controls.right||a,G=x.controls&&
|
||||
x.controls.left||x,a._relative?(W=((ca.x+a.x)*A+P).toFixed(3),X=((ca.y+a.y)*A+Q).toFixed(3)):(W=(ca.x*A+P).toFixed(3),X=(ca.y*A+Q).toFixed(3)),x._relative?(U=((G.x+x.x)*A+P).toFixed(3),V=((G.y+x.y)*A+P).toFixed(3)):(U=(G.x*A+P).toFixed(3),V=(G.y*A+Q).toFixed(3)),d=(x.x*A+P).toFixed(3),z=(x.y*A+Q).toFixed(3),u.bezierCurveTo(W,X,U,V,d,z));break;case Two.Commands.line:u.lineTo(d,z);break;case Two.Commands.move:B=a,u.moveTo(d,z)}});f&&u.closePath();u.fill();u.stroke()},updateTexture:function(a,b){this.updateCanvas(b);
|
||||
b._renderer.texture&&a.deleteTexture(b._renderer.texture);a.bindBuffer(a.ARRAY_BUFFER,b._renderer.textureCoordsBuffer);b._renderer.texture=a.createTexture();a.bindTexture(a.TEXTURE_2D,b._renderer.texture);a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_S,a.CLAMP_TO_EDGE);a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_T,a.CLAMP_TO_EDGE);a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,a.LINEAR);0>=this.canvas.width||0>=this.canvas.height||a.texImage2D(a.TEXTURE_2D,0,a.RGBA,a.RGBA,a.UNSIGNED_BYTE,this.canvas)},
|
||||
updateBuffer:function(a,b,c){_.isObject(b._renderer.buffer)&&a.deleteBuffer(b._renderer.buffer);b._renderer.buffer=a.createBuffer();a.bindBuffer(a.ARRAY_BUFFER,b._renderer.buffer);a.enableVertexAttribArray(c.position);a.bufferData(a.ARRAY_BUFFER,b._renderer.triangles,a.STATIC_DRAW);_.isObject(b._renderer.textureCoordsBuffer)&&a.deleteBuffer(b._renderer.textureCoordsBuffer);b._renderer.textureCoordsBuffer=a.createBuffer();a.bindBuffer(a.ARRAY_BUFFER,b._renderer.textureCoordsBuffer);a.enableVertexAttribArray(c.textureCoords);
|
||||
a.bufferData(a.ARRAY_BUFFER,this.uv,a.STATIC_DRAW)},program:{create:function(a,b){Z=a.createProgram();_.each(b,function(b){a.attachShader(Z,b)});a.linkProgram(Z);R=a.getProgramParameter(Z,a.LINK_STATUS);if(!R)throw ga=a.getProgramInfoLog(Z),a.deleteProgram(Z),new Two.Utils.Error("unable to link program: "+ga);return Z}},shaders:{create:function(a,b,c){$=a.createShader(a[c]);a.shaderSource($,b);a.compileShader($);fa=a.getShaderParameter($,a.COMPILE_STATUS);if(!fa)throw ga=a.getShaderInfoLog($),a.deleteShader($),
|
||||
new Two.Utils.Error("unable to compile shader "+$+": "+ga);return $},types:{vertex:"VERTEX_SHADER",fragment:"FRAGMENT_SHADER"},vertex:"attribute vec2 a_position;\nattribute vec2 a_textureCoords;\n\nuniform mat3 u_matrix;\nuniform vec2 u_resolution;\n\nvarying vec2 v_textureCoords;\n\nvoid main() {\n vec2 projected = (u_matrix * vec3(a_position, 1.0)).xy;\n vec2 normal = projected / u_resolution;\n vec2 clipspace = (normal * 2.0) - 1.0;\n\n gl_Position = vec4(clipspace * vec2(1.0, -1.0), 0.0, 1.0);\n v_textureCoords = a_textureCoords;\n}",
|
||||
fragment:"precision mediump float;\n\nuniform sampler2D u_image;\nvarying vec2 v_textureCoords;\n\nvoid main() {\n gl_FragColor = texture2D(u_image, v_textureCoords);\n}"}};S.ctx=S.canvas.getContext("2d");var la=Two[Two.Types.webgl]=function(a){this.domElement=a.domElement||document.createElement("canvas");this.scene=new Two.Group;this.scene.parent=this;this._renderer={matrix:new Two.Array(g),scale:1};this._flagMatrix=!0;ha=_.defaults(a||{},{antialias:!1,alpha:!0,premultipliedAlpha:!0,stencil:!0,
|
||||
preserveDrawingBuffer:!0,overdraw:!1});this.overdraw=ha.overdraw;N=this.ctx=this.domElement.getContext("webgl",ha)||this.domElement.getContext("experimental-webgl",ha);if(!this.ctx)throw new Two.Utils.Error("unable to create a webgl context. Try using another renderer.");ka=S.shaders.create(N,S.shaders.vertex,S.shaders.types.vertex);ja=S.shaders.create(N,S.shaders.fragment,S.shaders.types.fragment);this.program=S.program.create(N,[ka,ja]);N.useProgram(this.program);this.program.position=N.getAttribLocation(this.program,
|
||||
"a_position");this.program.matrix=N.getUniformLocation(this.program,"u_matrix");this.program.textureCoords=N.getAttribLocation(this.program,"a_textureCoords");N.disable(N.DEPTH_TEST);N.enable(N.BLEND);N.blendEquationSeparate(N.FUNC_ADD,N.FUNC_ADD);N.blendFuncSeparate(N.SRC_ALPHA,N.ONE_MINUS_SRC_ALPHA,N.ONE,N.ONE_MINUS_SRC_ALPHA)};_.extend(la.prototype,Backbone.Events,{setSize:function(a,b,c){this.width=a;this.height=b;this.ratio=_.isUndefined(c)?m(this.ctx):c;this.domElement.width=a*this.ratio;this.domElement.height=
|
||||
b*this.ratio;_.extend(this.domElement.style,{width:a+"px",height:b+"px"});a*=this.ratio;b*=this.ratio;this._renderer.matrix[0]=this._renderer.matrix[4]=this._renderer.scale=this.ratio;this._flagMatrix=!0;this.ctx.viewport(0,0,a,b);ia=this.ctx.getUniformLocation(this.program,"u_resolution");this.ctx.uniform2f(ia,a,b);return this},render:function(){N=this.ctx;this.overdraw||N.clear(N.COLOR_BUFFER_BIT|N.DEPTH_BUFFER_BIT);S.group.render.call(this.scene,N,this.program);this._flagMatrix=!1;return this}})})();(function(){var C,r=Two.Shape=function(g){this._renderer={};this.id=Two.uniqueId();this._matrix=new Two.Matrix;this.translation=new Two.Vector;this.translation.bind(Two.Events.change,_.bind(r.FlagMatrix,this));this.rotation=0;this.scale=1};_.extend(r,Backbone.Events,{FlagMatrix:function(){this._flagMatrix=!0},MakeObservable:function(g){Object.defineProperty(g,"rotation",{get:function(){return this._rotation},set:function(e){this._rotation=e;this._flagMatrix=!0}});Object.defineProperty(g,"scale",{get:function(){return this._scale},
|
||||
set:function(e){this._scale=e;this._flagScale=this._flagMatrix=!0}})}});_.extend(r.prototype,{_flagMatrix:!0,_rotation:0,_scale:1,addTo:function(g){g.add(this);return this},clone:function(){C=new r;C.translation.copy(this.translation);C.rotation=this.rotation;C.scale=this.scale;_.each(r.Properties,function(g){C[g]=this[g]},this);return C._update()},_update:function(){!this._matrix.manual&&this._flagMatrix&&this._matrix.identity().translate(this.translation.x,this.translation.y).scale(this.scale).rotate(this.rotation);
|
||||
this.parent&&_.isFunction(this.parent._update)&&this.parent._update();return this},flagReset:function(){this._flagScale=this._flagMatrix=!1;return this}});r.MakeObservable(r.prototype)})();(function(){var C=Math.min,r=Math.max,g=Math.round,e=Two.Utils.getComputedMatrix,m,n,c,p,l,D,F,s,y,d,z,q,w,x,B,H,G,a,b,k,v,K,u,A,L,J,O,M=Two.Polygon=function(a,b,c,d){Two.Shape.call(this);this._renderer.type="polygon";this._closed=!!b;this._curved=!!c;this.beginning=0;this.ending=1;this.fill="#fff";this.stroke="#000";this.opacity=this.linewidth=1;this.visible=!0;this.cap="butt";this.join="miter";this.miter=4;this._vertices=[];this.vertices=a;this.automatic=!d};_.extend(M,{Properties:"fill stroke linewidth opacity visible cap join miter closed curved automatic beginning ending".split(" "),
|
||||
FlagVertices:function(){this._flagVertices=!0},MakeObservable:function(a){Two.Shape.MakeObservable(a);_.each(M.Properties.slice(0,8),function(b){var c="_"+b,d="_flag"+b.charAt(0).toUpperCase()+b.slice(1);Object.defineProperty(a,b,{get:function(){return this[c]},set:function(a){this[c]=a;this[d]=!0}})});Object.defineProperty(a,"closed",{get:function(){return this._closed},set:function(a){this._closed=!!a;this._flagVertices=!0}});Object.defineProperty(a,"curved",{get:function(){return this._curved},
|
||||
set:function(a){this._curved=!!a;this._flagVertices=!0}});Object.defineProperty(M.prototype,"automatic",{get:function(){return this._automatic},set:function(a){a!==this._automatic&&(method=(this._automatic=!!a)?"ignore":"listen",_.each(this.vertices,function(a){a[method]()}))}});Object.defineProperty(a,"beginning",{get:function(){return this._beginning},set:function(a){this._beginning=C(r(a,0),this._ending);this._flagVertices=!0}});Object.defineProperty(a,"ending",{get:function(){return this._ending},
|
||||
set:function(a){this._ending=C(r(a,this._beginning),1);this._flagVertices=!0}});Object.defineProperty(a,"vertices",{get:function(){return this._collection},set:function(a){var b=_.bind(M.FlagVertices,this),c=_.bind(function(a){_.each(a,function(a){a.bind(Two.Events.change,b)},this);b()},this),d=_.bind(function(a){_.each(a,function(a){a.unbind(Two.Events.change,b)},this);b()},this);this._collection&&this._collection.unbind();this._collection=new Two.Utils.Collection(a.slice(0));this._collection.bind(Two.Events.insert,
|
||||
c);this._collection.bind(Two.Events.remove,d);verticesChanged=!0;c(this._collection)}})}});_.extend(M.prototype,Two.Shape.prototype,{_flagVertices:!0,_flagFill:!0,_flagStroke:!0,_flagLinewidth:!0,_flagOpacity:!0,_flagVisible:!0,_flagCap:!0,_flagJoin:!0,_flagMiter:!0,_fill:"#fff",_stroke:"#000",_linewidth:1,_opacity:1,_visible:!0,_cap:"round",_join:"round",_miter:4,_closed:!0,_curved:!1,_automatic:!0,_beginning:0,_ending:1,clone:function(a){a=a||this.parent;s=_.map(this.vertices,function(a){return a.clone()});
|
||||
y=new M(s,this.closed,this.curved,!this.automatic);_.each(Two.Shape.Properties,function(a){y[a]=this[a]},this);y.translation.copy(this.translation);y.rotation=this.rotation;y.scale=this.scale;a.add(y);return y},toObject:function(){var a={vertices:_.map(this.vertices,function(a){return a.toObject()})};_.each(Two.Shape.Properties,function(b){a[b]=this[b]},this);a.translation=this.translation.toObject;a.rotation=this.rotation;a.scale=this.scale;return a},noFill:function(){this.fill="transparent";return this},
|
||||
noStroke:function(){this.stroke="transparent";return this},corner:function(){d=this.getBoundingClientRect(!0);d.centroid={x:d.left+d.width/2,y:d.top+d.height/2};_.each(this.vertices,function(a){a.addSelf(d.centroid)});return this},center:function(){d=this.getBoundingClientRect(!0);d.centroid={x:d.left+d.width/2,y:d.top+d.height/2};_.each(this.vertices,function(a){a.subSelf(d.centroid)});return this},remove:function(){if(!this.parent)return this;this.parent.remove(this);return this},getBoundingClientRect:function(a){this._update();
|
||||
b=a?this._matrix:e(this);z=this.linewidth/2;void 0;q=Infinity;w=-Infinity;x=Infinity;B=-Infinity;_.each(this._vertices,function(a){H=a.x;G=a.y;a=b.multiply(H,G,1);x=C(a.y-z,x);q=C(a.x-z,q);w=r(a.x+z,w);B=r(a.y+z,B)});return{top:x,left:q,right:w,bottom:B,width:w-q,height:B-x}},plot:function(){if(this.curved)return Two.Utils.getCurveFromPoints(this._vertices,this.closed),this;_.each(this._vertices,function(a,b){a._command=0===b?Two.Commands.move:Two.Commands.line},this);return this},subdivide:function(b){this._update();
|
||||
p=this.vertices.length-1;a=this.vertices[p];l=this._closed||this.vertices[p]._command===Two.Commands.close;s=[];_.each(this.vertices,function(c,d){if(!(0>=d)||l)if(c.command===Two.Commands.move)s.push(new Two.Anchor(a.x,a.y)),0<d&&(s[s.length-1].command=Two.Commands.line);else{w=a.controls&&a.controls.right;q=c.controls&&c.controls.left;k=a.x;v=a.y;K=(w||a).x;u=(w||a).y;A=(q||c).x;L=(q||c).y;J=c.x;O=c.y;w&&a._relative&&(K+=a.x,u+=a.y);q&&c._relative&&(A+=c.x,L+=c.y);var e=Two.Utils.subdivide(k,v,
|
||||
K,u,A,L,J,O,b);s=s.concat(e);_.each(e,function(b,c){b.command=0>=c&&a.command===Two.Commands.move?Two.Commands.move:Two.Commands.line});d>=p&&(s.push(new Two.Anchor(J,O)),s[s.length-1].command=l?Two.Commands.close:Two.Commands.line)}a=c},this);this._curved=this._automatic=!1;this.vertices=s;return this},_update:function(){if(this._flagVertices){m=this.vertices.length;p=m-1;n=g(this._beginning*p);c=g(this._ending*p);this._vertices.length=0;for(F=n;F<c+1;F++)D=this.vertices[F],this._vertices.push(D);
|
||||
this._automatic&&this.plot()}Two.Shape.prototype._update.call(this);return this},flagReset:function(){this._flagVertices=this._flagFill=this._flagStroke=this._flagLinewidth=this._flagOpacity=this._flagVisible=this._flagCap=this._flagJoin=this._flagMiter=!1;Two.Shape.prototype.flagReset.call(this);return this}});M.MakeObservable(M.prototype)})();(function(){var C=Math.min,r=Math.max,g,e,m,n,c,p,l,D,F,s,y,d,z=Two.Group=function(c){Two.Shape.call(this,!0);this._renderer.type="group";this.additions=[];this.subtractions=[];this.children={}};_.extend(z,{MakeObservable:function(c){Two.Shape.MakeObservable(c);z.MakeGetterSetter(c,Two.Polygon.Properties)},MakeGetterSetter:function(c,d){_.isArray(d)||(d=[d]);_.each(d,function(d){g="_"+d;Object.defineProperty(c,d,{get:function(){return this[g]},set:function(c){this[g]=c;_.each(this.children,function(e){e[d]=
|
||||
c})}})})}});_.extend(z.prototype,Two.Shape.prototype,{_flagAdditions:!1,_flagSubtractions:!1,_fill:"#fff",_stroke:"#000",_linewidth:1,_opacity:1,_visible:!0,_cap:"round",_join:"round",_miter:4,_closed:!0,_curved:!1,_automatic:!0,_beginning:0,_ending:1,clone:function(c){c=c||this.parent;n=new z;c.add(n);m=_.map(this.children,function(c){return c.clone(n)});n.translation.copy(this.translation);n.rotation=this.rotation;n.scale=this.scale;return n},toObject:function(){var c={children:{},translation:this.translation.toObject(),
|
||||
rotation:this.rotation,scale:this.scale};_.each(this.children,function(d,e){c.children[e]=d.toObject()},this);return c},corner:function(){c=this.getBoundingClientRect(!0);p={x:c.left,y:c.top};_.each(this.children,function(c){c.translation.subSelf(p)});return this},center:function(){c=this.getBoundingClientRect(!0);c.centroid={x:c.left+c.width/2,y:c.top+c.height/2};_.each(this.children,function(d){d.translation.subSelf(c.centroid)});return this},add:function(c){l=arguments.length;D=c;m=this.children;
|
||||
F=this.parent;s=this.additions;_.isArray(c)||(D=_.toArray(arguments));_.each(D,function(c){c&&(y=c.id,e=c.parent,_.isUndefined(m[y])&&(e&&(delete e.children[y],d=_.indexOf(e.additions,y),0<=d&&e.additions.splice(d,1)),m[y]=c,c.parent=this,s.push(y),this._flagAdditions=!0))},this);return this},remove:function(c){l=arguments.length;D=c;m=this.children;F=this.parent;s=this.subtractions;if(0>=l&&F)return F.remove(this),this;_.isArray(c)||(D=_.toArray(arguments));_.each(D,function(c){y=c.id;grandchildren=
|
||||
c.children;e=c.parent;y in m&&(delete m[y],delete c.parent,d=_.indexOf(e.additions,y),0<=d&&e.additions.splice(d,1),s.push(y),this._flagSubtractions=!0)},this);return this},getBoundingClientRect:function(d){this._update();var e=Infinity,g=-Infinity,l=Infinity,m=-Infinity;_.each(this.children,function(d){c=d.getBoundingClientRect();_.isNumber(c.top)&&(_.isNumber(c.left)&&_.isNumber(c.right)&&_.isNumber(c.bottom))&&(l=C(c.top,l),e=C(c.left,e),g=r(c.right,g),m=r(c.bottom,m))},this);return{top:l,left:e,
|
||||
right:g,bottom:m,width:g-e,height:m-l}},noFill:function(){_.each(this.children,function(c){c.noFill()});return this},noStroke:function(){_.each(this.children,function(c){c.noStroke()});return this},subdivide:function(){var c=arguments;_.each(this.children,function(d){d.subdivide.apply(d,c)});return this},flagReset:function(){this._flagAdditions&&(this.additions.length=0,this._flagAdditions=!1);this._flagSubtractions&&(this.subtractions.length=0,this._flagSubtractions=!1);Two.Shape.prototype.flagReset.call(this);
|
||||
return this}});z.MakeObservable(z.prototype)})();
|
Loading…
Reference in New Issue