UNPKG

372 BJavaScriptView Raw
1"use strict";
2
3module.exports = function paethPredictor(left, above, upLeft) {
4 let paeth = left + above - upLeft;
5 let pLeft = Math.abs(paeth - left);
6 let pAbove = Math.abs(paeth - above);
7 let pUpLeft = Math.abs(paeth - upLeft);
8
9 if (pLeft <= pAbove && pLeft <= pUpLeft) {
10 return left;
11 }
12 if (pAbove <= pUpLeft) {
13 return above;
14 }
15 return upLeft;
16};