mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-05 20:32:00 -05:00
Optimise code for normal and multiply blend modes by precalculating values.
This commit is contained in:
parent
8bbb3744fe
commit
3850e4a53b
1 changed files with 8 additions and 6 deletions
|
@ -53,15 +53,17 @@ var BlendMode = {
|
|||
// TODO: Some blend modes seem broken at the moment, e.g. dodge, burn
|
||||
var modes = {
|
||||
normal: function(i) {
|
||||
dst[i] = (sRA + dRA - dRA * sA) * rM;
|
||||
dst[i + 1] = (sGA + dGA - dGA * sA) * rM;
|
||||
dst[i + 2] = (sBA + dBA - dBA * sA) * rM;
|
||||
var sA1 = 1 - sA;
|
||||
dst[i] = (sRA + dRA * sA1) * rM;
|
||||
dst[i + 1] = (sGA + dGA * sA1) * rM;
|
||||
dst[i + 2] = (sBA + dRA * sA1) * rM;
|
||||
},
|
||||
|
||||
multiply: function(i) {
|
||||
dst[i] = (sRA * dRA + sRA * (1 - dA) + dRA * (1 - sA)) * rM;
|
||||
dst[i + 1] = (sGA * dGA + sGA * (1 - dA) + dGA * (1 - sA)) * rM;
|
||||
dst[i + 2] = (sBA * dBA + sBA * (1 - dA) + dBA * (1 - sA)) * rM;
|
||||
var sA1 = 1 - sA, dA1 = 1 - dA;
|
||||
dst[i] = (sRA * dRA + sRA * dA1 + dRA * sA1) * rM;
|
||||
dst[i + 1] = (sGA * dGA + sGA * dA1 + dGA * sA1) * rM;
|
||||
dst[i + 2] = (sBA * dBA + sBA * dA1 + dBA * sA1) * rM;
|
||||
},
|
||||
|
||||
screen: function(i) {
|
||||
|
|
Loading…
Reference in a new issue