mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-03 19:45:44 -05:00
Clean up white-spaces and line lengths.
This commit is contained in:
parent
15a7b7e245
commit
2b6dede883
22 changed files with 232 additions and 213 deletions
|
@ -1,6 +1,8 @@
|
|||
var Gradient = Base.extend({
|
||||
initialize: function() {
|
||||
this.stops = [new GradientStop('white', 0), new GradientStop('black', 1)];
|
||||
this.stops = [
|
||||
new GradientStop('white', 0),
|
||||
new GradientStop('black', 1)];
|
||||
this.type = 'linear';
|
||||
},
|
||||
|
||||
|
@ -10,7 +12,8 @@ var Gradient = Base.extend({
|
|||
|
||||
setStops: function(stops) {
|
||||
if (stops.length < 2)
|
||||
throw new Error('Gradient stop list needs to contain at least two stops.');
|
||||
throw new Error(
|
||||
'Gradient stop list needs to contain at least two stops.');
|
||||
this._stops = stops;
|
||||
}
|
||||
});
|
||||
|
|
|
@ -36,7 +36,8 @@ var GradientColor = Color.extend({
|
|||
var hilite = Point.read(arguments);
|
||||
var vector = hilite.subtract(this.origin);
|
||||
if (vector.length > this._radius) {
|
||||
this._hilite = this.origin.add(vector.normalize(this._radius - 0.1));
|
||||
this._hilite = this.origin.add(vector.normalize(
|
||||
this._radius - 0.1));
|
||||
} else {
|
||||
this._hilite = hilite;
|
||||
}
|
||||
|
|
|
@ -23,7 +23,8 @@ var GrayColor = Color.extend({
|
|||
},
|
||||
|
||||
/**
|
||||
* A value between 0 and 1 that specifies the amount of gray in the gray color.
|
||||
* A value between 0 and 1 that specifies the amount of gray in the gray
|
||||
* color.
|
||||
*/
|
||||
getGray: function() {
|
||||
return this._gray;
|
||||
|
|
|
@ -1,49 +1,52 @@
|
|||
var RGBColor = Color.extend(new function() {
|
||||
// TODO: convert hex codes to [r,g,b]?
|
||||
var namedColors = {
|
||||
lightpink: 'FFB6C1', pink: 'FFC0CB', crimson: 'DC143C',
|
||||
lavenderblush: 'FFF0F5', palevioletred: 'DB7093', hotpink: 'FF69B4',
|
||||
deeppink: 'FF1493', mediumvioletred: 'C71585', orchid: 'DA70D6',
|
||||
thistle: 'D8BFD8', plum: 'DDA0DD', violet: 'EE82EE', fuchsia: 'FF00FF',
|
||||
darkmagenta: '8B008B', purple: '800080', mediumorchid: 'BA55D3',
|
||||
darkviolet: '9400D3', darkorchid: '9932CC', indigo: '4B0082',
|
||||
blueviolet: '8A2BE2', mediumpurple: '9370DB', mediumslateblue: '7B68EE',
|
||||
slateblue: '6A5ACD', darkslateblue: '483D8B', ghostwhite: 'F8F8FF',
|
||||
lavender: 'E6E6FA', blue: '0000FF', mediumblue: '0000CD',
|
||||
darkblue: '00008B', navy: '000080', midnightblue: '191970',
|
||||
royalblue: '4169E1', cornflowerblue: '6495ED', lightsteelblue: 'B0C4DE',
|
||||
lightslategray: '778899', slategray: '708090', dodgerblue: '1E90FF',
|
||||
aliceblue: 'F0F8FF', steelblue: '4682B4', lightskyblue: '87CEFA',
|
||||
skyblue: '87CEEB', deepskyblue: '00BFFF', lightblue: 'ADD8E6',
|
||||
powderblue: 'B0E0E6', cadetblue: '5F9EA0', darkturquoise: '00CED1',
|
||||
azure: 'F0FFFF', lightcyan: 'E0FFFF', paleturquoise: 'AFEEEE',
|
||||
aqua: '00FFFF', darkcyan: '008B8B', teal: '008080', darkslategray: '2F4F4F',
|
||||
mediumturquoise: '48D1CC', lightseagreen: '20B2AA', turquoise: '40E0D0',
|
||||
aquamarine: '7FFFD4', mediumaquamarine: '66CDAA', mediumspringgreen: '00FA9A',
|
||||
mintcream: 'F5FFFA', springgreen: '00FF7F', mediumseagreen: '3CB371',
|
||||
seagreen: '2E8B57', honeydew: 'F0FFF0', darkseagreen: '8FBC8F',
|
||||
palegreen: '98FB98', lightgreen: '90EE90', limegreen: '32CD32',
|
||||
lime: '00FF00', forestgreen: '228B22', green: '008000', darkgreen: '006400',
|
||||
lawngreen: '7CFC00', chartreuse: '7FFF00', greenyellow: 'ADFF2F',
|
||||
darkolivegreen: '556B2F', yellowgreen: '9ACD32', olivedrab: '6B8E23',
|
||||
ivory: 'FFFFF0', beige: 'F5F5DC', lightyellow: 'FFFFE0',
|
||||
lightgoldenrodyellow: 'FAFAD2', yellow: 'FFFF00', olive: '808000',
|
||||
darkkhaki: 'BDB76B', palegoldenrod: 'EEE8AA', lemonchiffon: 'FFFACD',
|
||||
khaki: 'F0E68C', gold: 'FFD700', cornsilk: 'FFF8DC', goldenrod: 'DAA520',
|
||||
darkgoldenrod: 'B8860B', floralwhite: 'FFFAF0', oldlace: 'FDF5E6',
|
||||
wheat: 'F5DEB3', orange: 'FFA500', moccasin: 'FFE4B5', papayawhip: 'FFEFD5',
|
||||
blanchedalmond: 'FFEBCD', navajowhite: 'FFDEAD', antiquewhite: 'FAEBD7',
|
||||
tan: 'D2B48C', burlywood: 'DEB887', darkorange: 'FF8C00', bisque: 'FFE4C4',
|
||||
linen: 'FAF0E6', peru: 'CD853F', peachpuff: 'FFDAB9', sandybrown: 'F4A460',
|
||||
chocolate: 'D2691E', saddlebrown: '8B4513', seashell: 'FFF5EE',
|
||||
sienna: 'A0522D', lightsalmon: 'FFA07A', coral: 'FF7F50',
|
||||
orangered: 'FF4500', darksalmon: 'E9967A', tomato: 'FF6347',
|
||||
salmon: 'FA8072', mistyrose: 'FFE4E1', lightcoral: 'F08080', snow: 'FFFAFA',
|
||||
rosybrown: 'BC8F8F', indianred: 'CD5C5C', red: 'FF0000', brown: 'A52A2A',
|
||||
firebrick: 'B22222', darkred: '8B0000', maroon: '800000', white: 'FFFFFF',
|
||||
whitesmoke: 'F5F5F5', gainsboro: 'DCDCDC', lightgrey: 'D3D3D3',
|
||||
silver: 'C0C0C0', darkgray: 'A9A9A9', gray: '808080', dimgray: '696969',
|
||||
black: '000000'
|
||||
lightpink: 'ffb6c1', pink: 'ffc0cb', crimson: 'dc143c',
|
||||
lavenderblush: 'fff0f5', palevioletred: 'db7093', hotpink: 'ff69b4',
|
||||
deeppink: 'ff1493', mediumvioletred: 'c71585', orchid: 'da70d6',
|
||||
thistle: 'd8bfd8', plum: 'dda0dd', violet: 'ee82ee', fuchsia: 'ff00ff',
|
||||
darkmagenta: '8b008b', purple: '800080', mediumorchid: 'ba55d3',
|
||||
darkviolet: '9400d3', darkorchid: '9932cc', indigo: '4b0082',
|
||||
blueviolet: '8a2be2', mediumpurple: '9370db', mediumslateblue: '7b68ee',
|
||||
slateblue: '6a5acd', darkslateblue: '483d8b', ghostwhite: 'f8f8ff',
|
||||
lavender: 'e6e6fa', blue: '0000ff', mediumblue: '0000cd',
|
||||
darkblue: '00008b', navy: '000080', midnightblue: '191970',
|
||||
royalblue: '4169e1', cornflowerblue: '6495ed', lightsteelblue: 'b0c4de',
|
||||
lightslategray: '778899', slategray: '708090', dodgerblue: '1e90ff',
|
||||
aliceblue: 'f0f8ff', steelblue: '4682b4', lightskyblue: '87cefa',
|
||||
skyblue: '87ceeb', deepskyblue: '00bfff', lightblue: 'add8e6',
|
||||
powderblue: 'b0e0e6', cadetblue: '5f9ea0', darkturquoise: '00ced1',
|
||||
azure: 'f0ffff', lightcyan: 'e0ffff', paleturquoise: 'afeeee',
|
||||
aqua: '00ffff', darkcyan: '008b8b', teal: '008080',
|
||||
darkslategray: '2f4f4f', mediumturquoise: '48d1cc',
|
||||
lightseagreen: '20b2aa', turquoise: '40e0d0', aquamarine: '7fffd4',
|
||||
mediumaquamarine: '66cdaa', mediumspringgreen: '00fa9a',
|
||||
mintcream: 'f5fffa', springgreen: '00ff7f', mediumseagreen: '3cb371',
|
||||
seagreen: '2e8b57', honeydew: 'f0fff0', darkseagreen: '8fbc8f',
|
||||
palegreen: '98fb98', lightgreen: '90ee90', limegreen: '32cd32',
|
||||
lime: '00ff00', forestgreen: '228b22', green: '008000',
|
||||
darkgreen: '006400', lawngreen: '7cfc00', chartreuse: '7fff00',
|
||||
greenyellow: 'adff2f', darkolivegreen: '556b2f', yellowgreen: '9acd32',
|
||||
olivedrab: '6b8e23', ivory: 'fffff0', beige: 'f5f5dc',
|
||||
lightyellow: 'ffffe0', lightgoldenrodyellow: 'fafad2', yellow: 'ffff00',
|
||||
olive: '808000', darkkhaki: 'bdb76b', palegoldenrod: 'eee8aa',
|
||||
lemonchiffon: 'fffacd', khaki: 'f0e68c', gold: 'ffd700',
|
||||
cornsilk: 'fff8dc', goldenrod: 'daa520', darkgoldenrod: 'b8860b',
|
||||
floralwhite: 'fffaf0', oldlace: 'fdf5e6', wheat: 'f5deb3',
|
||||
orange: 'ffa500', moccasin: 'ffe4b5', papayawhip: 'ffefd5',
|
||||
blanchedalmond: 'ffebcd', navajowhite: 'ffdead', antiquewhite: 'faebd7',
|
||||
tan: 'd2b48c', burlywood: 'deb887', darkorange: 'ff8c00',
|
||||
bisque: 'ffe4c4', linen: 'faf0e6', peru: 'cd853f', peachpuff: 'ffdab9',
|
||||
sandybrown: 'f4a460', chocolate: 'd2691e', saddlebrown: '8b4513',
|
||||
seashell: 'fff5ee', sienna: 'a0522d', lightsalmon: 'ffa07a',
|
||||
coral: 'ff7f50', orangered: 'ff4500', darksalmon: 'e9967a',
|
||||
tomato: 'ff6347', salmon: 'fa8072', mistyrose: 'ffe4e1',
|
||||
lightcoral: 'f08080', snow: 'fffafa', rosybrown: 'bc8f8f',
|
||||
indianred: 'cd5c5c', red: 'ff0000', brown: 'a52a2a',
|
||||
firebrick: 'b22222', darkred: '8b0000', maroon: '800000',
|
||||
white: 'ffffff', whitesmoke: 'f5f5f5', gainsboro: 'dcdcdc',
|
||||
lightgrey: 'd3d3d3', silver: 'c0c0c0', darkgray: 'a9a9a9',
|
||||
gray: '808080', dimgray: '696969', black: '000000'
|
||||
};
|
||||
|
||||
function stringToComponents(string) {
|
||||
|
@ -113,7 +116,8 @@ var RGBColor = Color.extend(new function() {
|
|||
},
|
||||
|
||||
/**
|
||||
* A value between 0 and 1 that specifies the amount of red in the RGB color.
|
||||
* A value between 0 and 1 that specifies the amount of red in the RGB
|
||||
* color.
|
||||
*/
|
||||
getRed: function() {
|
||||
return this._red;
|
||||
|
@ -125,7 +129,8 @@ var RGBColor = Color.extend(new function() {
|
|||
},
|
||||
|
||||
/**
|
||||
* A value between 0 and 1 that specifies the amount of green in the RGB color.
|
||||
* A value between 0 and 1 that specifies the amount of green in the RGB
|
||||
* color.
|
||||
*/
|
||||
getGreen: function() {
|
||||
return this._green;
|
||||
|
@ -137,7 +142,8 @@ var RGBColor = Color.extend(new function() {
|
|||
},
|
||||
|
||||
/**
|
||||
* A value between 0 and 1 that specifies the amount of blue in the RGB color.
|
||||
* A value between 0 and 1 that specifies the amount of blue in the RGB
|
||||
* color.
|
||||
*/
|
||||
getBlue: function() {
|
||||
return this._blue;
|
||||
|
|
|
@ -27,7 +27,8 @@ var Tool = ToolHandler.extend(new function() {
|
|||
if (that.onMouseDown)
|
||||
that._document.redraw();
|
||||
if (that.eventInterval != -1)
|
||||
this.intervalId = setInterval(events.drag, that.eventInterval);
|
||||
this.intervalId = setInterval(events.drag,
|
||||
that.eventInterval);
|
||||
dragging = true;
|
||||
},
|
||||
drag: function(e) {
|
||||
|
@ -62,9 +63,9 @@ var Tool = ToolHandler.extend(new function() {
|
|||
|
||||
/**
|
||||
* The fixed time delay between each call to the {@link #onMouseDrag}
|
||||
* event. Setting this to an interval means the {@link #onMouseDrag} event
|
||||
* is called repeatedly after the initial {@link #onMouseDown} until the
|
||||
* user releases the mouse.
|
||||
* event. Setting this to an interval means the {@link #onMouseDrag}
|
||||
* event is called repeatedly after the initial {@link #onMouseDown}
|
||||
* until the user releases the mouse.
|
||||
*
|
||||
* Sample code:
|
||||
* <code>
|
||||
|
|
|
@ -13,7 +13,6 @@ var ToolHandler = Base.extend({
|
|||
}
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* The minimum distance the mouse has to drag before firing the onMouseDrag
|
||||
* event, since the last onMouseDrag event.
|
||||
|
@ -48,7 +47,8 @@ var ToolHandler = Base.extend({
|
|||
},
|
||||
|
||||
getFixedDistance: function() {
|
||||
if (this._minDistance != null && this._minDistance.equals(this._maxDistance))
|
||||
if (this._minDistance != null
|
||||
&& this._minDistance.equals(this._maxDistance))
|
||||
return this._minDistance;
|
||||
return null;
|
||||
},
|
||||
|
@ -121,7 +121,8 @@ var ToolHandler = Base.extend({
|
|||
// would produce weird results. matchMaxDistance controls this.
|
||||
this.matchMaxDistance = false;
|
||||
while (this.updateEvent(type, pt, this.minDistance,
|
||||
this.maxDistance, false, this.needsChange, this.matchMaxDistance)) {
|
||||
this.maxDistance, false, this.needsChange,
|
||||
this.matchMaxDistance)) {
|
||||
if (this.onMouseDrag)
|
||||
this.onMouseDrag(new ToolEvent(this, type, modifiers));
|
||||
this.needsChange = true;
|
||||
|
@ -131,8 +132,9 @@ var ToolHandler = Base.extend({
|
|||
case 'MOUSE_UP':
|
||||
// If the last mouse drag happened in a different place, call
|
||||
// mouse drag first, then mouse up.
|
||||
if ((this.point.x != pt.x || this.point.y != pt.y) && this.updateEvent(
|
||||
'MOUSE_DRAG', pt, this.minDistance, this.maxDistance, false, false, false)) {
|
||||
if ((this.point.x != pt.x || this.point.y != pt.y)
|
||||
&& this.updateEvent('MOUSE_DRAG', pt, this.minDistance,
|
||||
this.maxDistance, false, false, false)) {
|
||||
if (this.onMouseDrag)
|
||||
this.onMouseDrag(new ToolEvent(this, type, modifiers));
|
||||
}
|
||||
|
|
|
@ -4,8 +4,8 @@ var MathUtils = {
|
|||
MANT_DIGITS: 53,
|
||||
EPSILON: Math.pow(2, -52),
|
||||
|
||||
// Compute a numerical approximation to an integral via adaptive Simpson's Rule
|
||||
// This routine ignores underflow.
|
||||
// Compute a numerical approximation to an integral via adaptive Simpson's
|
||||
// Rule This routine ignores underflow.
|
||||
|
||||
// Returns approximate value of the integral if successful.
|
||||
// f: Pointer to function to be integrated.
|
||||
|
@ -53,10 +53,11 @@ var MathUtils = {
|
|||
|
||||
if (index >= table.length)
|
||||
success = false;
|
||||
if (!success || (Math.abs(diff) <= accuracy * Math.abs(area) && da <= dxmax)) {
|
||||
if (!success || (Math.abs(diff) <= accuracy * Math.abs(area)
|
||||
&& da <= dxmax)) {
|
||||
// Accept approximate integral.
|
||||
// If it was a right interval, add results to finish at this level.
|
||||
// If it was a left interval, process right interval.
|
||||
// If it was a right interval, add results to finish at this
|
||||
// level. If it was a left interval, process right interval.
|
||||
for (;;) {
|
||||
if (!p.left) { // process right-half interval
|
||||
alpha += da;
|
||||
|
@ -76,7 +77,8 @@ var MathUtils = {
|
|||
}
|
||||
|
||||
} else {
|
||||
// Raise level and store information for processing right-half interval.
|
||||
// Raise level and store information for processing right-half
|
||||
// interval.
|
||||
p = table[++index] = {
|
||||
left: false,
|
||||
f1t: fv2,
|
||||
|
@ -145,7 +147,8 @@ var MathUtils = {
|
|||
diff = est - sum;
|
||||
area = parea + sum;
|
||||
var b2 = alpha + da;
|
||||
if (Math.abs(Math.abs(integral - area) - Math.abs(pdiff)) + Math.abs(diff) <= fv4 * accuracy * (b2 - a)) {
|
||||
if (Math.abs(Math.abs(integral - area) - Math.abs(pdiff))
|
||||
+ Math.abs(diff) <= fv4 * accuracy * (b2 - a)) {
|
||||
return { b: b2, area: area };
|
||||
}
|
||||
if (Math.abs(integral - area) > Math.abs(pdiff + diff)) {
|
||||
|
@ -155,10 +158,12 @@ var MathUtils = {
|
|||
p.left = true;
|
||||
p.psum = parea;
|
||||
} else {
|
||||
if ((Math.abs(diff) <= fv4 * accuracy * da || dx <= dxmin) && da <= dxmax) {
|
||||
if ((Math.abs(diff) <= fv4 * accuracy * da
|
||||
|| dx <= dxmin) && da <= dxmax) {
|
||||
// Accept approximate integral sum.
|
||||
// If it was a right interval, add results to finish at this level.
|
||||
// If it was a left interval, process right interval.
|
||||
// If it was a right interval, add results to finish
|
||||
// at this level. If it was a left interval, process
|
||||
// right interval.
|
||||
pdiff += diff;
|
||||
for (;;) {
|
||||
if (!p.left) { // process right-half interval
|
||||
|
@ -193,7 +198,8 @@ var MathUtils = {
|
|||
}
|
||||
if (index >= table.length)
|
||||
return null;
|
||||
// Raise level and store information for processing right-half interval.
|
||||
// Raise level and store information for processing right-half
|
||||
// interval.
|
||||
da = dx;
|
||||
est = estl;
|
||||
p = table[++index] = {
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
var PaperScript = new function() {
|
||||
|
||||
// Handle Math Operators
|
||||
|
||||
var operators = {
|
||||
|
|
Loading…
Reference in a new issue