mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-01 02:38:43 -05:00
Support Firefox 3.6 still, with surprising little effort.
Why, I don't really know :)
This commit is contained in:
parent
62f7b0d73e
commit
d28bac0734
5 changed files with 42 additions and 10 deletions
|
@ -32,7 +32,7 @@ fi
|
|||
|
||||
./preprocess.sh $MODE ../src/paper.js "-i '../src/constants.js'" ../dist/paper-full.js
|
||||
./preprocess.sh $MODE ../src/paper.js "-o '{ \"paperScript\": false, \"palette\": false }' -i '../src/constants.js'" ../dist/paper-core.js
|
||||
./preprocess.sh $MODE ../src/paper.js "-o '{ \"environment\": \"node\" }' -i '../src/constants.js'" ../dist/paper-node.js
|
||||
./preprocess.sh $MODE ../src/paper.js "-o '{ \"environment\": \"node\", \"legacy\": false }' -i '../src/constants.js'" ../dist/paper-node.js
|
||||
|
||||
# Remove the existing file and copy paper-full.js to paper.js now
|
||||
if [ -f ../dist/paper.js ]
|
||||
|
|
|
@ -232,20 +232,24 @@ var BlendMode = new function() {
|
|||
Base.each(modes, function(func, mode) {
|
||||
// Blend #330000 (51) and #aa0000 (170):
|
||||
// Multiplying should lead to #220000 (34)
|
||||
ctx.save();
|
||||
// For darken we need to reverse color parameters in order to test mode.
|
||||
var darken = mode === 'darken',
|
||||
ok = false;
|
||||
ctx.fillStyle = darken ? '#300' : '#a00';
|
||||
ctx.fillRect(0, 0, 1, 1);
|
||||
ctx.globalCompositeOperation = mode;
|
||||
if (ctx.globalCompositeOperation === mode) {
|
||||
ctx.fillStyle = darken ? '#a00' : '#300';
|
||||
ctx.save();
|
||||
// FF 3.6 throws exception when setting globalCompositeOperation to
|
||||
// unsupported values.
|
||||
try {
|
||||
ctx.fillStyle = darken ? '#300' : '#a00';
|
||||
ctx.fillRect(0, 0, 1, 1);
|
||||
ok = ctx.getImageData(0, 0, 1, 1).data[0] !== (darken ? 170 : 51);
|
||||
}
|
||||
nativeModes[mode] = ok;
|
||||
ctx.globalCompositeOperation = mode;
|
||||
if (ctx.globalCompositeOperation === mode) {
|
||||
ctx.fillStyle = darken ? '#a00' : '#300';
|
||||
ctx.fillRect(0, 0, 1, 1);
|
||||
ok = ctx.getImageData(0, 0, 1, 1).data[0] !== darken ? 170 : 51;
|
||||
}
|
||||
} catch (e) {}
|
||||
ctx.restore();
|
||||
nativeModes[mode] = ok;
|
||||
});
|
||||
CanvasProvider.release(ctx);
|
||||
|
||||
|
|
23
src/legacy.js
Normal file
23
src/legacy.js
Normal file
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* Paper.js - The Swiss Army Knife of Vector Graphics Scripting.
|
||||
* http://paperjs.org/
|
||||
*
|
||||
* Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey
|
||||
* http://scratchdisk.com/ & http://jonathanpuckey.com/
|
||||
*
|
||||
* Distributed under the MIT license. See LICENSE file for details.
|
||||
*
|
||||
* All rights reserved.
|
||||
*/
|
||||
|
||||
// Support for legacy browsers (mainly FF 3.6). Remove 2nd half of 2014?
|
||||
|
||||
if (!Array.isArray) {
|
||||
Array.isArray = function(obj) {
|
||||
return Object.prototype.toString.call(obj) === '[object Array]';
|
||||
};
|
||||
}
|
||||
|
||||
if (!document.head) {
|
||||
document.head = document.getElementsByTagName('head')[0];
|
||||
}
|
|
@ -18,6 +18,7 @@ var __options = {
|
|||
parser: 'acorn',
|
||||
version: 'dev',
|
||||
environment: 'browser',
|
||||
legacy: true,
|
||||
stats: true,
|
||||
svg: true,
|
||||
fatlineClipping: true,
|
||||
|
|
|
@ -40,6 +40,10 @@ var paper = new function(undefined) {
|
|||
/*#*/ include('../bower_components/stats.js/build/stats.min.js');
|
||||
/*#*/ } // __options.stats
|
||||
|
||||
/*#*/ if (__options.legacy) {
|
||||
/*#*/ include('legacy.js');
|
||||
/*#*/ } // __options.legacy
|
||||
|
||||
/*#*/ if (__options.version == 'dev') {
|
||||
/*#*/ include('constants.js');
|
||||
/*#*/ } // __options.version == 'dev'
|
||||
|
|
Loading…
Reference in a new issue