Merge remote branch 'origin/master'

This commit is contained in:
Jonathan Puckey 2011-03-07 12:59:08 +01:00
commit 5e99833ebb
6 changed files with 16 additions and 15 deletions

Binary file not shown.

View file

@ -26,7 +26,7 @@
# commented Preprocessed but still formated and commented (default)
# stripped Formated but without comments
# compressed No comments and no whitespaces
# compiled Uses Google Closure Compiler to reduce file size even more
# uglified Uses UglifyJS to further reduce file size
KEYWORD="//#"
@ -44,9 +44,9 @@ case $4 in
/./,/^$/!d
p' > $2
;;
compiled)
uglified)
./filepp.pl -kc $KEYWORD $3 $1 > temp.js
java -jar compiler.jar --js temp.js --js_output_file $2
../../uglifyjs/bin/uglifyjs temp.js --extra --unsafe --reserved-names "$eval,$sign" > $2
rm temp.js
;;
esac

View file

@ -321,7 +321,7 @@ var Curve = this.Curve = Base.extend({
}
var ds = getLengthIntegrand(
p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y);
return Numerical.gauss(ds, a, b, 8);
return Numerical.integrate(ds, a, b, 8);
},
getParameter: function(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y,
@ -339,18 +339,18 @@ var Curve = this.Curve = Base.extend({
p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y);
// Use integrand both to calculate total length and part lengths
// in f(t) below.
var bezierLength = Numerical.gauss(ds, 0, 1, 8);
var bezierLength = Numerical.integrate(ds, 0, 1, 8);
if (length >= bezierLength)
return 1;
// Let's use the Van WijngaardenDekkerBrent Method to find
// solutions more reliably than with False Position Method.
function f(t) {
// The precision of 5 iterations seems enough for this
return length - Numerical.gauss(ds, 0, t, 5);
return length - Numerical.integrate(ds, 0, t, 5);
}
// Use length / bezierLength for an initial guess for b, to
// bring us closer:
return Numerical.brent(f, 0, length / bezierLength,
return Numerical.findRoot(f, 0, length / bezierLength,
Numerical.TOLERANCE);
},

View file

@ -28,7 +28,7 @@
*
* @author lehni
*/
ToolEvent = Base.extend({
var ToolEvent = this.ToolEvent = Base.extend({
beans: true,
initialize: function(tool, type, modifiers) {

View file

@ -42,7 +42,7 @@ var Numerical = new function() {
* Copyright (c) 2006-2007, Jim Armstrong (www.algorithmist.net)
* All Rights Reserved.
*/
gauss: function(f, a, b, n) {
integrate: function(f, a, b, n) {
n = Math.min(Math.max(n, 2), 8);
var l = n == 2 ? 0 : n * (n - 1) / 2 - 1,
@ -59,7 +59,7 @@ var Numerical = new function() {
* Van WijngaardenDekkerBrent method for root finding, implementation
* based on Numerical Recipes in C
*/
brent: function(f, a, b, tol) {
findRoot: function(f, a, b, tol) {
var c = b, d = 0, e = 0,
fa = f(a),
fb = f(b),

View file

@ -15,7 +15,7 @@ var PaperScript = new function() {
//TODO: Make sure there are all the correct copyrights for the inlined parse-js:
//#include "../../lib/parse-js-min.js"
// Handle Math Operators
// Math Operators
var operators = {
'+': 'add',
@ -46,7 +46,7 @@ var PaperScript = new function() {
}
};
// Handle Sign Operators
// Sign Operators
var signOperators = {
'-': 'negate'
@ -150,7 +150,8 @@ var PaperScript = new function() {
//#ifdef BROWSER
// Code borrowed from Coffee Script:
function load(url) {
var xhr = new (window.ActiveXObject || XMLHttpRequest)('Microsoft.XMLHTTP');
var xhr = new (window.ActiveXObject
|| XMLHttpRequest)('Microsoft.XMLHTTP');
xhr.open('GET', url, true);
if ('overrideMimeType' in xhr) {
xhr.overrideMimeType('text/plain');
@ -169,8 +170,8 @@ var PaperScript = new function() {
for (var i = 0, l = scripts.length; i < l; i++) {
var script = scripts[i];
if (script.type === 'text/paperscript') {
// If a canvas id is provided, create a document for it now, so
// the active document is defined.
// If a canvas id is provided, create a document for it now,
// so the active document is defined.
var canvas = script.getAttribute('canvas');
if (canvas && (canvas = document.getElementById(canvas))) {
new Document(canvas);