Best JavaScript code snippet using wpt
colorspace.js
Source:colorspace.js
...181 whitePoint = IR[1];182 blackPoint = IR[2];183 gamma = IR[3];184 var matrix = IR[4];185 return new CalRGBCS(whitePoint, blackPoint, gamma, matrix);186 case 'PatternCS':187 var basePatternCS = IR[1];188 if (basePatternCS) {189 basePatternCS = this.fromIR(basePatternCS);190 }191 return new PatternCS(basePatternCS);192 case 'IndexedCS':193 var baseIndexedCS = IR[1];194 var hiVal = IR[2];195 var lookup = IR[3];196 return new IndexedCS(this.fromIR(baseIndexedCS), hiVal, lookup);197 case 'AlternateCS':198 var numComps = IR[1];199 var alt = IR[2];200 var tintFn = IR[3];201 return new AlternateCS(numComps, this.fromIR(alt), tintFn);202 case 'LabCS':203 whitePoint = IR[1];204 blackPoint = IR[2];205 var range = IR[3];206 return new LabCS(whitePoint, blackPoint, range);207 default:208 throw new _util.FormatError('Unknown colorspace name: ' + name);209 }210 }211 }, {212 key: 'parseToIR',213 value: function parseToIR(cs, xref) {214 var res = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;215 var pdfFunctionFactory = arguments[3];216 cs = xref.fetchIfRef(cs);217 if ((0, _primitives.isName)(cs)) {218 switch (cs.name) {219 case 'DeviceGray':220 case 'G':221 return 'DeviceGrayCS';222 case 'DeviceRGB':223 case 'RGB':224 return 'DeviceRgbCS';225 case 'DeviceCMYK':226 case 'CMYK':227 return 'DeviceCmykCS';228 case 'Pattern':229 return ['PatternCS', null];230 default:231 if ((0, _primitives.isDict)(res)) {232 var colorSpaces = res.get('ColorSpace');233 if ((0, _primitives.isDict)(colorSpaces)) {234 var resCS = colorSpaces.get(cs.name);235 if (resCS) {236 if ((0, _primitives.isName)(resCS)) {237 return this.parseToIR(resCS, xref, res, pdfFunctionFactory);238 }239 cs = resCS;240 break;241 }242 }243 }244 throw new _util.FormatError('unrecognized colorspace ' + cs.name);245 }246 }247 if (Array.isArray(cs)) {248 var mode = xref.fetchIfRef(cs[0]).name;249 var numComps = void 0,250 params = void 0,251 alt = void 0,252 whitePoint = void 0,253 blackPoint = void 0,254 gamma = void 0;255 switch (mode) {256 case 'DeviceGray':257 case 'G':258 return 'DeviceGrayCS';259 case 'DeviceRGB':260 case 'RGB':261 return 'DeviceRgbCS';262 case 'DeviceCMYK':263 case 'CMYK':264 return 'DeviceCmykCS';265 case 'CalGray':266 params = xref.fetchIfRef(cs[1]);267 whitePoint = params.getArray('WhitePoint');268 blackPoint = params.getArray('BlackPoint');269 gamma = params.get('Gamma');270 return ['CalGrayCS', whitePoint, blackPoint, gamma];271 case 'CalRGB':272 params = xref.fetchIfRef(cs[1]);273 whitePoint = params.getArray('WhitePoint');274 blackPoint = params.getArray('BlackPoint');275 gamma = params.getArray('Gamma');276 var matrix = params.getArray('Matrix');277 return ['CalRGBCS', whitePoint, blackPoint, gamma, matrix];278 case 'ICCBased':279 var stream = xref.fetchIfRef(cs[1]);280 var dict = stream.dict;281 numComps = dict.get('N');282 alt = dict.get('Alternate');283 if (alt) {284 var altIR = this.parseToIR(alt, xref, res, pdfFunctionFactory);285 var altCS = this.fromIR(altIR, pdfFunctionFactory);286 if (altCS.numComps === numComps) {287 return altIR;288 }289 (0, _util.warn)('ICCBased color space: Ignoring incorrect /Alternate entry.');290 }291 if (numComps === 1) {292 return 'DeviceGrayCS';293 } else if (numComps === 3) {294 return 'DeviceRgbCS';295 } else if (numComps === 4) {296 return 'DeviceCmykCS';297 }298 break;299 case 'Pattern':300 var basePatternCS = cs[1] || null;301 if (basePatternCS) {302 basePatternCS = this.parseToIR(basePatternCS, xref, res, pdfFunctionFactory);303 }304 return ['PatternCS', basePatternCS];305 case 'Indexed':306 case 'I':307 var baseIndexedCS = this.parseToIR(cs[1], xref, res, pdfFunctionFactory);308 var hiVal = xref.fetchIfRef(cs[2]) + 1;309 var lookup = xref.fetchIfRef(cs[3]);310 if ((0, _primitives.isStream)(lookup)) {311 lookup = lookup.getBytes();312 }313 return ['IndexedCS', baseIndexedCS, hiVal, lookup];314 case 'Separation':315 case 'DeviceN':316 var name = xref.fetchIfRef(cs[1]);317 numComps = Array.isArray(name) ? name.length : 1;318 alt = this.parseToIR(cs[2], xref, res, pdfFunctionFactory);319 var tintFn = pdfFunctionFactory.create(xref.fetchIfRef(cs[3]));320 return ['AlternateCS', numComps, alt, tintFn];321 case 'Lab':322 params = xref.fetchIfRef(cs[1]);323 whitePoint = params.getArray('WhitePoint');324 blackPoint = params.getArray('BlackPoint');325 var range = params.getArray('Range');326 return ['LabCS', whitePoint, blackPoint, range];327 default:328 throw new _util.FormatError('unimplemented color space object "' + mode + '"');329 }330 }331 throw new _util.FormatError('unrecognized color space object: "' + cs + '"');332 }333 }, {334 key: 'isDefaultDecode',335 value: function isDefaultDecode(decode, n) {336 if (!Array.isArray(decode)) {337 return true;338 }339 if (n * 2 !== decode.length) {340 (0, _util.warn)('The decode map is not the correct length');341 return true;342 }343 for (var i = 0, ii = decode.length; i < ii; i += 2) {344 if (decode[i] !== 0 || decode[i + 1] !== 1) {345 return false;346 }347 }348 return true;349 }350 }, {351 key: 'singletons',352 get: function get() {353 return (0, _util.shadow)(this, 'singletons', {354 get gray() {355 return (0, _util.shadow)(this, 'gray', new DeviceGrayCS());356 },357 get rgb() {358 return (0, _util.shadow)(this, 'rgb', new DeviceRgbCS());359 },360 get cmyk() {361 return (0, _util.shadow)(this, 'cmyk', new DeviceCmykCS());362 }363 });364 }365 }]);366 return ColorSpace;367}();368var AlternateCS = function (_ColorSpace) {369 _inherits(AlternateCS, _ColorSpace);370 function AlternateCS(numComps, base, tintFn) {371 _classCallCheck(this, AlternateCS);372 var _this = _possibleConstructorReturn(this, (AlternateCS.__proto__ || Object.getPrototypeOf(AlternateCS)).call(this, 'Alternate', numComps));373 _this.base = base;374 _this.tintFn = tintFn;375 _this.tmpBuf = new Float32Array(base.numComps);376 return _this;377 }378 _createClass(AlternateCS, [{379 key: 'getRgbItem',380 value: function getRgbItem(src, srcOffset, dest, destOffset) {381 var tmpBuf = this.tmpBuf;382 this.tintFn(src, srcOffset, tmpBuf, 0);383 this.base.getRgbItem(tmpBuf, 0, dest, destOffset);384 }385 }, {386 key: 'getRgbBuffer',387 value: function getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {388 var tintFn = this.tintFn;389 var base = this.base;390 var scale = 1 / ((1 << bits) - 1);391 var baseNumComps = base.numComps;392 var usesZeroToOneRange = base.usesZeroToOneRange;393 var isPassthrough = (base.isPassthrough(8) || !usesZeroToOneRange) && alpha01 === 0;394 var pos = isPassthrough ? destOffset : 0;395 var baseBuf = isPassthrough ? dest : new Uint8ClampedArray(baseNumComps * count);396 var numComps = this.numComps;397 var scaled = new Float32Array(numComps);398 var tinted = new Float32Array(baseNumComps);399 var i = void 0,400 j = void 0;401 for (i = 0; i < count; i++) {402 for (j = 0; j < numComps; j++) {403 scaled[j] = src[srcOffset++] * scale;404 }405 tintFn(scaled, 0, tinted, 0);406 if (usesZeroToOneRange) {407 for (j = 0; j < baseNumComps; j++) {408 baseBuf[pos++] = tinted[j] * 255;409 }410 } else {411 base.getRgbItem(tinted, 0, baseBuf, pos);412 pos += baseNumComps;413 }414 }415 if (!isPassthrough) {416 base.getRgbBuffer(baseBuf, 0, count, dest, destOffset, 8, alpha01);417 }418 }419 }, {420 key: 'getOutputLength',421 value: function getOutputLength(inputLength, alpha01) {422 return this.base.getOutputLength(inputLength * this.base.numComps / this.numComps, alpha01);423 }424 }, {425 key: 'isDefaultDecode',426 value: function isDefaultDecode(decodeMap) {427 return ColorSpace.isDefaultDecode(decodeMap, this.numComps);428 }429 }]);430 return AlternateCS;431}(ColorSpace);432var PatternCS = function (_ColorSpace2) {433 _inherits(PatternCS, _ColorSpace2);434 function PatternCS(baseCS) {435 _classCallCheck(this, PatternCS);436 var _this2 = _possibleConstructorReturn(this, (PatternCS.__proto__ || Object.getPrototypeOf(PatternCS)).call(this, 'Pattern', null));437 _this2.base = baseCS;438 return _this2;439 }440 return PatternCS;441}(ColorSpace);442var IndexedCS = function (_ColorSpace3) {443 _inherits(IndexedCS, _ColorSpace3);444 function IndexedCS(base, highVal, lookup) {445 _classCallCheck(this, IndexedCS);446 var _this3 = _possibleConstructorReturn(this, (IndexedCS.__proto__ || Object.getPrototypeOf(IndexedCS)).call(this, 'Indexed', 1));447 _this3.base = base;448 _this3.highVal = highVal;449 var baseNumComps = base.numComps;450 var length = baseNumComps * highVal;451 if ((0, _primitives.isStream)(lookup)) {452 _this3.lookup = new Uint8Array(length);453 var bytes = lookup.getBytes(length);454 _this3.lookup.set(bytes);455 } else if ((0, _util.isString)(lookup)) {456 _this3.lookup = new Uint8Array(length);457 for (var i = 0; i < length; ++i) {458 _this3.lookup[i] = lookup.charCodeAt(i);459 }460 } else if (lookup instanceof Uint8Array) {461 _this3.lookup = lookup;462 } else {463 throw new _util.FormatError('Unrecognized lookup table: ' + lookup);464 }465 return _this3;466 }467 _createClass(IndexedCS, [{468 key: 'getRgbItem',469 value: function getRgbItem(src, srcOffset, dest, destOffset) {470 var numComps = this.base.numComps;471 var start = src[srcOffset] * numComps;472 this.base.getRgbBuffer(this.lookup, start, 1, dest, destOffset, 8, 0);473 }474 }, {475 key: 'getRgbBuffer',476 value: function getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {477 var base = this.base;478 var numComps = base.numComps;479 var outputDelta = base.getOutputLength(numComps, alpha01);480 var lookup = this.lookup;481 for (var i = 0; i < count; ++i) {482 var lookupPos = src[srcOffset++] * numComps;483 base.getRgbBuffer(lookup, lookupPos, 1, dest, destOffset, 8, alpha01);484 destOffset += outputDelta;485 }486 }487 }, {488 key: 'getOutputLength',489 value: function getOutputLength(inputLength, alpha01) {490 return this.base.getOutputLength(inputLength * this.base.numComps, alpha01);491 }492 }, {493 key: 'isDefaultDecode',494 value: function isDefaultDecode(decodeMap) {495 return true;496 }497 }]);498 return IndexedCS;499}(ColorSpace);500var DeviceGrayCS = function (_ColorSpace4) {501 _inherits(DeviceGrayCS, _ColorSpace4);502 function DeviceGrayCS() {503 _classCallCheck(this, DeviceGrayCS);504 return _possibleConstructorReturn(this, (DeviceGrayCS.__proto__ || Object.getPrototypeOf(DeviceGrayCS)).call(this, 'DeviceGray', 1));505 }506 _createClass(DeviceGrayCS, [{507 key: 'getRgbItem',508 value: function getRgbItem(src, srcOffset, dest, destOffset) {509 var c = src[srcOffset] * 255;510 dest[destOffset] = dest[destOffset + 1] = dest[destOffset + 2] = c;511 }512 }, {513 key: 'getRgbBuffer',514 value: function getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {515 var scale = 255 / ((1 << bits) - 1);516 var j = srcOffset,517 q = destOffset;518 for (var i = 0; i < count; ++i) {519 var c = scale * src[j++];520 dest[q++] = c;521 dest[q++] = c;522 dest[q++] = c;523 q += alpha01;524 }525 }526 }, {527 key: 'getOutputLength',528 value: function getOutputLength(inputLength, alpha01) {529 return inputLength * (3 + alpha01);530 }531 }, {532 key: 'isDefaultDecode',533 value: function isDefaultDecode(decodeMap) {534 return ColorSpace.isDefaultDecode(decodeMap, this.numComps);535 }536 }]);537 return DeviceGrayCS;538}(ColorSpace);539var DeviceRgbCS = function (_ColorSpace5) {540 _inherits(DeviceRgbCS, _ColorSpace5);541 function DeviceRgbCS() {542 _classCallCheck(this, DeviceRgbCS);543 return _possibleConstructorReturn(this, (DeviceRgbCS.__proto__ || Object.getPrototypeOf(DeviceRgbCS)).call(this, 'DeviceRGB', 3));544 }545 _createClass(DeviceRgbCS, [{546 key: 'getRgbItem',547 value: function getRgbItem(src, srcOffset, dest, destOffset) {548 dest[destOffset] = src[srcOffset] * 255;549 dest[destOffset + 1] = src[srcOffset + 1] * 255;550 dest[destOffset + 2] = src[srcOffset + 2] * 255;551 }552 }, {553 key: 'getRgbBuffer',554 value: function getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {555 if (bits === 8 && alpha01 === 0) {556 dest.set(src.subarray(srcOffset, srcOffset + count * 3), destOffset);557 return;558 }559 var scale = 255 / ((1 << bits) - 1);560 var j = srcOffset,561 q = destOffset;562 for (var i = 0; i < count; ++i) {563 dest[q++] = scale * src[j++];564 dest[q++] = scale * src[j++];565 dest[q++] = scale * src[j++];566 q += alpha01;567 }568 }569 }, {570 key: 'getOutputLength',571 value: function getOutputLength(inputLength, alpha01) {572 return inputLength * (3 + alpha01) / 3 | 0;573 }574 }, {575 key: 'isPassthrough',576 value: function isPassthrough(bits) {577 return bits === 8;578 }579 }, {580 key: 'isDefaultDecode',581 value: function isDefaultDecode(decodeMap) {582 return ColorSpace.isDefaultDecode(decodeMap, this.numComps);583 }584 }]);585 return DeviceRgbCS;586}(ColorSpace);587var DeviceCmykCS = function DeviceCmykCSClosure() {588 function convertToRgb(src, srcOffset, srcScale, dest, destOffset) {589 var c = src[srcOffset] * srcScale;590 var m = src[srcOffset + 1] * srcScale;591 var y = src[srcOffset + 2] * srcScale;592 var k = src[srcOffset + 3] * srcScale;593 dest[destOffset] = 255 + c * (-4.387332384609988 * c + 54.48615194189176 * m + 18.82290502165302 * y + 212.25662451639585 * k + -285.2331026137004) + m * (1.7149763477362134 * m - 5.6096736904047315 * y + -17.873870861415444 * k - 5.497006427196366) + y * (-2.5217340131683033 * y - 21.248923337353073 * k + 17.5119270841813) + k * (-21.86122147463605 * k - 189.48180835922747);594 dest[destOffset + 1] = 255 + c * (8.841041422036149 * c + 60.118027045597366 * m + 6.871425592049007 * y + 31.159100130055922 * k + -79.2970844816548) + m * (-15.310361306967817 * m + 17.575251261109482 * y + 131.35250912493976 * k - 190.9453302588951) + y * (4.444339102852739 * y + 9.8632861493405 * k - 24.86741582555878) + k * (-20.737325471181034 * k - 187.80453709719578);595 dest[destOffset + 2] = 255 + c * (0.8842522430003296 * c + 8.078677503112928 * m + 30.89978309703729 * y - 0.23883238689178934 * k + -14.183576799673286) + m * (10.49593273432072 * m + 63.02378494754052 * y + 50.606957656360734 * k - 112.23884253719248) + y * (0.03296041114873217 * y + 115.60384449646641 * k + -193.58209356861505) + k * (-22.33816807309886 * k - 180.12613974708367);596 }597 var DeviceCmykCS = function (_ColorSpace6) {598 _inherits(DeviceCmykCS, _ColorSpace6);599 function DeviceCmykCS() {600 _classCallCheck(this, DeviceCmykCS);601 return _possibleConstructorReturn(this, (DeviceCmykCS.__proto__ || Object.getPrototypeOf(DeviceCmykCS)).call(this, 'DeviceCMYK', 4));602 }603 _createClass(DeviceCmykCS, [{604 key: 'getRgbItem',605 value: function getRgbItem(src, srcOffset, dest, destOffset) {606 convertToRgb(src, srcOffset, 1, dest, destOffset);607 }608 }, {609 key: 'getRgbBuffer',610 value: function getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {611 var scale = 1 / ((1 << bits) - 1);612 for (var i = 0; i < count; i++) {613 convertToRgb(src, srcOffset, scale, dest, destOffset);614 srcOffset += 4;615 destOffset += 3 + alpha01;616 }617 }618 }, {619 key: 'getOutputLength',620 value: function getOutputLength(inputLength, alpha01) {621 return inputLength / 4 * (3 + alpha01) | 0;622 }623 }, {624 key: 'isDefaultDecode',625 value: function isDefaultDecode(decodeMap) {626 return ColorSpace.isDefaultDecode(decodeMap, this.numComps);627 }628 }]);629 return DeviceCmykCS;630 }(ColorSpace);631 return DeviceCmykCS;632}();633var CalGrayCS = function CalGrayCSClosure() {634 function convertToRgb(cs, src, srcOffset, dest, destOffset, scale) {635 var A = src[srcOffset] * scale;636 var AG = Math.pow(A, cs.G);637 var L = cs.YW * AG;638 var val = Math.max(295.8 * Math.pow(L, 0.333333333333333333) - 40.8, 0);639 dest[destOffset] = val;640 dest[destOffset + 1] = val;641 dest[destOffset + 2] = val;642 }643 var CalGrayCS = function (_ColorSpace7) {644 _inherits(CalGrayCS, _ColorSpace7);645 function CalGrayCS(whitePoint, blackPoint, gamma) {646 _classCallCheck(this, CalGrayCS);647 var _this7 = _possibleConstructorReturn(this, (CalGrayCS.__proto__ || Object.getPrototypeOf(CalGrayCS)).call(this, 'CalGray', 1));648 if (!whitePoint) {649 throw new _util.FormatError('WhitePoint missing - required for color space CalGray');650 }651 blackPoint = blackPoint || [0, 0, 0];652 gamma = gamma || 1;653 _this7.XW = whitePoint[0];654 _this7.YW = whitePoint[1];655 _this7.ZW = whitePoint[2];656 _this7.XB = blackPoint[0];657 _this7.YB = blackPoint[1];658 _this7.ZB = blackPoint[2];659 _this7.G = gamma;660 if (_this7.XW < 0 || _this7.ZW < 0 || _this7.YW !== 1) {661 throw new _util.FormatError('Invalid WhitePoint components for ' + _this7.name + ', no fallback available');662 }663 if (_this7.XB < 0 || _this7.YB < 0 || _this7.ZB < 0) {664 (0, _util.info)('Invalid BlackPoint for ' + _this7.name + ', falling back to default.');665 _this7.XB = _this7.YB = _this7.ZB = 0;666 }667 if (_this7.XB !== 0 || _this7.YB !== 0 || _this7.ZB !== 0) {668 (0, _util.warn)(_this7.name + ', BlackPoint: XB: ' + _this7.XB + ', YB: ' + _this7.YB + ', ' + ('ZB: ' + _this7.ZB + ', only default values are supported.'));669 }670 if (_this7.G < 1) {671 (0, _util.info)('Invalid Gamma: ' + _this7.G + ' for ' + _this7.name + ', ' + 'falling back to default.');672 _this7.G = 1;673 }674 return _this7;675 }676 _createClass(CalGrayCS, [{677 key: 'getRgbItem',678 value: function getRgbItem(src, srcOffset, dest, destOffset) {679 convertToRgb(this, src, srcOffset, dest, destOffset, 1);680 }681 }, {682 key: 'getRgbBuffer',683 value: function getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {684 var scale = 1 / ((1 << bits) - 1);685 for (var i = 0; i < count; ++i) {686 convertToRgb(this, src, srcOffset, dest, destOffset, scale);687 srcOffset += 1;688 destOffset += 3 + alpha01;689 }690 }691 }, {692 key: 'getOutputLength',693 value: function getOutputLength(inputLength, alpha01) {694 return inputLength * (3 + alpha01);695 }696 }, {697 key: 'isDefaultDecode',698 value: function isDefaultDecode(decodeMap) {699 return ColorSpace.isDefaultDecode(decodeMap, this.numComps);700 }701 }]);702 return CalGrayCS;703 }(ColorSpace);704 return CalGrayCS;705}();706var CalRGBCS = function CalRGBCSClosure() {707 var BRADFORD_SCALE_MATRIX = new Float32Array([0.8951, 0.2664, -0.1614, -0.7502, 1.7135, 0.0367, 0.0389, -0.0685, 1.0296]);708 var BRADFORD_SCALE_INVERSE_MATRIX = new Float32Array([0.9869929, -0.1470543, 0.1599627, 0.4323053, 0.5183603, 0.0492912, -0.0085287, 0.0400428, 0.9684867]);709 var SRGB_D65_XYZ_TO_RGB_MATRIX = new Float32Array([3.2404542, -1.5371385, -0.4985314, -0.9692660, 1.8760108, 0.0415560, 0.0556434, -0.2040259, 1.0572252]);710 var FLAT_WHITEPOINT_MATRIX = new Float32Array([1, 1, 1]);711 var tempNormalizeMatrix = new Float32Array(3);712 var tempConvertMatrix1 = new Float32Array(3);713 var tempConvertMatrix2 = new Float32Array(3);714 var DECODE_L_CONSTANT = Math.pow((8 + 16) / 116, 3) / 8.0;715 function matrixProduct(a, b, result) {716 result[0] = a[0] * b[0] + a[1] * b[1] + a[2] * b[2];717 result[1] = a[3] * b[0] + a[4] * b[1] + a[5] * b[2];718 result[2] = a[6] * b[0] + a[7] * b[1] + a[8] * b[2];719 }720 function convertToFlat(sourceWhitePoint, LMS, result) {721 result[0] = LMS[0] * 1 / sourceWhitePoint[0];722 result[1] = LMS[1] * 1 / sourceWhitePoint[1];723 result[2] = LMS[2] * 1 / sourceWhitePoint[2];724 }725 function convertToD65(sourceWhitePoint, LMS, result) {726 var D65X = 0.95047;727 var D65Y = 1;728 var D65Z = 1.08883;729 result[0] = LMS[0] * D65X / sourceWhitePoint[0];730 result[1] = LMS[1] * D65Y / sourceWhitePoint[1];731 result[2] = LMS[2] * D65Z / sourceWhitePoint[2];732 }733 function sRGBTransferFunction(color) {734 if (color <= 0.0031308) {735 return adjustToRange(0, 1, 12.92 * color);736 }737 return adjustToRange(0, 1, (1 + 0.055) * Math.pow(color, 1 / 2.4) - 0.055);738 }739 function adjustToRange(min, max, value) {740 return Math.max(min, Math.min(max, value));741 }742 function decodeL(L) {743 if (L < 0) {744 return -decodeL(-L);745 }746 if (L > 8.0) {747 return Math.pow((L + 16) / 116, 3);748 }749 return L * DECODE_L_CONSTANT;750 }751 function compensateBlackPoint(sourceBlackPoint, XYZ_Flat, result) {752 if (sourceBlackPoint[0] === 0 && sourceBlackPoint[1] === 0 && sourceBlackPoint[2] === 0) {753 result[0] = XYZ_Flat[0];754 result[1] = XYZ_Flat[1];755 result[2] = XYZ_Flat[2];756 return;757 }758 var zeroDecodeL = decodeL(0);759 var X_DST = zeroDecodeL;760 var X_SRC = decodeL(sourceBlackPoint[0]);761 var Y_DST = zeroDecodeL;762 var Y_SRC = decodeL(sourceBlackPoint[1]);763 var Z_DST = zeroDecodeL;764 var Z_SRC = decodeL(sourceBlackPoint[2]);765 var X_Scale = (1 - X_DST) / (1 - X_SRC);766 var X_Offset = 1 - X_Scale;767 var Y_Scale = (1 - Y_DST) / (1 - Y_SRC);768 var Y_Offset = 1 - Y_Scale;769 var Z_Scale = (1 - Z_DST) / (1 - Z_SRC);770 var Z_Offset = 1 - Z_Scale;771 result[0] = XYZ_Flat[0] * X_Scale + X_Offset;772 result[1] = XYZ_Flat[1] * Y_Scale + Y_Offset;773 result[2] = XYZ_Flat[2] * Z_Scale + Z_Offset;774 }775 function normalizeWhitePointToFlat(sourceWhitePoint, XYZ_In, result) {776 if (sourceWhitePoint[0] === 1 && sourceWhitePoint[2] === 1) {777 result[0] = XYZ_In[0];778 result[1] = XYZ_In[1];779 result[2] = XYZ_In[2];780 return;781 }782 var LMS = result;783 matrixProduct(BRADFORD_SCALE_MATRIX, XYZ_In, LMS);784 var LMS_Flat = tempNormalizeMatrix;785 convertToFlat(sourceWhitePoint, LMS, LMS_Flat);786 matrixProduct(BRADFORD_SCALE_INVERSE_MATRIX, LMS_Flat, result);787 }788 function normalizeWhitePointToD65(sourceWhitePoint, XYZ_In, result) {789 var LMS = result;790 matrixProduct(BRADFORD_SCALE_MATRIX, XYZ_In, LMS);791 var LMS_D65 = tempNormalizeMatrix;792 convertToD65(sourceWhitePoint, LMS, LMS_D65);793 matrixProduct(BRADFORD_SCALE_INVERSE_MATRIX, LMS_D65, result);794 }795 function convertToRgb(cs, src, srcOffset, dest, destOffset, scale) {796 var A = adjustToRange(0, 1, src[srcOffset] * scale);797 var B = adjustToRange(0, 1, src[srcOffset + 1] * scale);798 var C = adjustToRange(0, 1, src[srcOffset + 2] * scale);799 var AGR = Math.pow(A, cs.GR);800 var BGG = Math.pow(B, cs.GG);801 var CGB = Math.pow(C, cs.GB);802 var X = cs.MXA * AGR + cs.MXB * BGG + cs.MXC * CGB;803 var Y = cs.MYA * AGR + cs.MYB * BGG + cs.MYC * CGB;804 var Z = cs.MZA * AGR + cs.MZB * BGG + cs.MZC * CGB;805 var XYZ = tempConvertMatrix1;806 XYZ[0] = X;807 XYZ[1] = Y;808 XYZ[2] = Z;809 var XYZ_Flat = tempConvertMatrix2;810 normalizeWhitePointToFlat(cs.whitePoint, XYZ, XYZ_Flat);811 var XYZ_Black = tempConvertMatrix1;812 compensateBlackPoint(cs.blackPoint, XYZ_Flat, XYZ_Black);813 var XYZ_D65 = tempConvertMatrix2;814 normalizeWhitePointToD65(FLAT_WHITEPOINT_MATRIX, XYZ_Black, XYZ_D65);815 var SRGB = tempConvertMatrix1;816 matrixProduct(SRGB_D65_XYZ_TO_RGB_MATRIX, XYZ_D65, SRGB);817 dest[destOffset] = sRGBTransferFunction(SRGB[0]) * 255;818 dest[destOffset + 1] = sRGBTransferFunction(SRGB[1]) * 255;819 dest[destOffset + 2] = sRGBTransferFunction(SRGB[2]) * 255;820 }821 var CalRGBCS = function (_ColorSpace8) {822 _inherits(CalRGBCS, _ColorSpace8);823 function CalRGBCS(whitePoint, blackPoint, gamma, matrix) {824 _classCallCheck(this, CalRGBCS);825 var _this8 = _possibleConstructorReturn(this, (CalRGBCS.__proto__ || Object.getPrototypeOf(CalRGBCS)).call(this, 'CalRGB', 3));826 if (!whitePoint) {827 throw new _util.FormatError('WhitePoint missing - required for color space CalRGB');828 }829 blackPoint = blackPoint || new Float32Array(3);830 gamma = gamma || new Float32Array([1, 1, 1]);831 matrix = matrix || new Float32Array([1, 0, 0, 0, 1, 0, 0, 0, 1]);832 var XW = whitePoint[0];833 var YW = whitePoint[1];834 var ZW = whitePoint[2];835 _this8.whitePoint = whitePoint;836 var XB = blackPoint[0];837 var YB = blackPoint[1];...
Using AI Code Generation
1var wptools = require('wptools');2var wp = new wptools('CalRGBCS');3wp.get(function(err, resp, infobox) {4 if (err) {5 console.log(err);6 } else {7 console.log(infobox);8 }9});10{ title: 'CalRGBCS',
Using AI Code Generation
1var wptools = require('wptools');2var wp = wptools.page('CalRGBCS');3wp.get(function(err, resp) {4 console.log(resp);5});6var wptools = require('wptools');7var wp = wptools.page('CalRGBCS');8wp.get(function(err, resp) {9 console.log(resp);10});11var wptools = require('wptools');12var wp = wptools.page('CalRGBCS');13wp.get(function(err, resp) {14 console.log(resp);15});16var wptools = require('wptools');17var wp = wptools.page('CalRGBCS');18wp.get(function(err, resp) {19 console.log(resp);20});21var wptools = require('wptools');22var wp = wptools.page('CalRGBCS');23wp.get(function(err, resp) {24 console.log(resp);25});26var wptools = require('wptools');27var wp = wptools.page('CalRGBCS');28wp.get(function(err, resp) {29 console.log(resp);30});31var wptools = require('wptools');32var wp = wptools.page('CalRGBCS');33wp.get(function(err, resp) {34 console.log(resp);35});36var wptools = require('wptools');37var wp = wptools.page('CalRGBCS');38wp.get(function(err, resp) {39 console.log(resp);40});41var wptools = require('wptools');42var wp = wptools.page('CalRGBCS');43wp.get(function(err, resp) {
Using AI Code Generation
1var wptools = require('wptools');2var wp = new wptools('CalRGBCS');3wp.get(function(err, resp) {4 console.log(resp);5});6var wptools = require('wptools');7var wp = new wptools('CalRGBCS');8wp.get(function(err, resp) {9 console.log(resp);10});11var wptools = require('wptools');12var wp = new wptools('CalRGBCS');13wp.get(function(err, resp) {14 console.log(resp);15});16var wptools = require('wptools');17var wp = new wptools('CalRGBCS');18wp.get(function(err, resp) {19 console.log(resp);20});21var wptools = require('wptools');22var wp = new wptools('CalRGBCS');23wp.get(function(err, resp) {24 console.log(resp);25});26var wptools = require('wptools');27var wp = new wptools('CalRGBCS');28wp.get(function(err, resp) {29 console.log(resp);30});31var wptools = require('wptools');32var wp = new wptools('CalRGBCS');33wp.get(function(err, resp) {34 console.log(resp);35});36var wptools = require('wptools');37var wp = new wptools('CalRGBCS');38wp.get(function(err, resp) {39 console.log(resp);40});41var wptools = require('wptools');42var wp = new wptools('CalRGBCS');43wp.get(function(err, resp) {44 console.log(resp);45});
Using AI Code Generation
1var wpt = require('wpt');2var wptClient = new wpt('your api key');3 if (err) {4 console.log(err);5 } else {6 console.log(data);7 }8});9var wpt = require('wpt');10var wptClient = new wpt('your api key');11 if (err) {12 console.log(err);13 } else {14 console.log(data);15 }16});17var wpt = require('wpt');18var wptClient = new wpt('your api key');19 if (err) {20 console.log(err);21 } else {22 console.log(data);23 }24});25var wpt = require('wpt');26var wptClient = new wpt('your api key');27 if (err) {28 console.log(err);29 } else {30 console.log(data);31 }32});33var wpt = require('wpt');34var wptClient = new wpt('your api key');35 if (err) {36 console.log(err);37 } else {38 console.log(data);39 }40});41var wpt = require('wpt');42var wptClient = new wpt('your api key');43 if (err) {44 console.log(err);45 } else {
Using AI Code Generation
1var wptools = require('wptools');2var wp = new wptools('CalRGBCS');3wp.getCalRGBCS(function(err, data) {4 console.log(data);5});6var wptools = require('wptools');7var wp = new wptools('CalRGBCS');8wp.getCalRGBCS(function(err, data) {9 console.log(data);10});11var wptools = require('wptools');12var wp = new wptools('CalRGBCS');13wp.getCalRGBCS(function(err, data) {14 console.log(data);15});16var wptools = require('wptools');17var wp = new wptools('CalRGBCS');18wp.getCalRGBCS(function(err, data) {19 console.log(data);20});21var wptools = require('wptools');22var wp = new wptools('CalRGBCS');23wp.getCalRGBCS(function(err, data) {24 console.log(data);25});26var wptools = require('wptools');27var wp = new wptools('CalRGBCS');28wp.getCalRGBCS(function(err, data) {29 console.log(data);30});31var wptools = require('wptools');32var wp = new wptools('CalRGBCS');33wp.getCalRGBCS(function(err, data) {34 console.log(data);35});36var wptools = require('wptools');37var wp = new wptools('CalRGBCS');38wp.getCalRGBCS(function(err, data) {39 console.log(data);40});
Using AI Code Generation
1var wptools = require('wptools');2var wp = new wptools('CalRGBCS');3wp.get(function(err, resp, infobox) {4 console.log(resp);5});6 at exports._errnoException (util.js:746:11)7 at Process.ChildProcess._handle.onexit (child_process.js:1053:32)8 at process._tickCallback (node.js:355:11)
Using AI Code Generation
1var wpt = require('wptoolkit');2var rgb = wpt.CalRGBCS(0, 0, 0);3console.log(rgb);4var wpt = require('wptoolkit');5var rgb = wpt.CalRGBCS(255, 255, 255);6console.log(rgb);7var wpt = require('wptoolkit');8var rgb = wpt.CalRGBCS(255, 0, 0);9console.log(rgb);10var wpt = require('wptoolkit');11var rgb = wpt.CalRGBCS(0, 255, 0);12console.log(rgb);13var wpt = require('wptoolkit');14var rgb = wpt.CalRGBCS(0, 0, 255);15console.log(rgb);16var wpt = require('wptoolkit');17var rgb = wpt.CalRGBCS(0, 255, 255);18console.log(rgb);19var wpt = require('wptoolkit');20var rgb = wpt.CalRGBCS(255, 0, 255);21console.log(rgb);
Using AI Code Generation
1var wptools = require('wptools');2var wp = wptools.page('Wikipedia:WikiProject Color/Color articles by color');3wp.getCalRGBCS(function(err, response) {4 console.log(response);5});6var wptools = require('wptools');7var wp = wptools.page('Wikipedia:WikiProject Color/Color articles by color');8wp.getCalRGBCS(function(err, response) {9 console.log(response);10});11var wptools = require('wptools');12var wp = wptools.page('Wikipedia:WikiProject Color/Color articles by color');13wp.getCalRGBCS(function(err, response) {14 console.log(response);15});16var wptools = require('wptools');17var wp = wptools.page('Wikipedia:WikiProject Color/Color articles by color');18wp.getCalRGBCS(function(err, response) {19 console.log(response);20});21var wptools = require('wptools');22var wp = wptools.page('Wikipedia:WikiProject Color/Color articles by color');23wp.getCalRGBCS(function(err, response) {24 console.log(response);25});26var wptools = require('wptools');27var wp = wptools.page('Wikipedia:WikiProject Color/Color articles by color');28wp.getCalRGBCS(function(err, response) {29 console.log(response);30});31var wptools = require('wptools');32var wp = wptools.page('Wikipedia:WikiProject Color/Color articles by color');33wp.getCalRGBCS(function(err, response) {34 console.log(response);35});36var wptools = require('wptools');37var wp = wptools.page('Wikipedia:WikiProject Color/Color articles by color');38wp.getCalRGBCS(function(err, response) {39 console.log(response);40});
Using AI Code Generation
1var wpt = require('wpt');2var myWpt = new wpt();3myWpt.calRGBCS();4var wpt = require('wpt');5var myWpt = new wpt();6myWpt.calRGBCS();
Using AI Code Generation
1var wpt = require('wptoolkit');2var wptObj = new wpt();3var result = wptObj.CalRGBCS(0.64, 0.33, 0.3, 0.6, 0.15, 0.06, 0.3127, 0.329, 0.1800, 0.2640, 0.8400, 0.0400, 0.64, 0.33);4console.log(result);5var wpt = require('wptoolkit');6var wptObj = new wpt();7var result = wptObj.CalRGBCS(0.64, 0.33, 0.3, 0.6, 0.15, 0.06, 0.3127, 0.329, 0.1800, 0.2640, 0.8400, 0.0400, 0.64, 0.33, 0.418, 0.161);8console.log(result);
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!