Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the unused defaultColor property on ColorSpace instances #10000

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 30 additions & 23 deletions src/core/colorspace.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ var ColorSpace = (function ColorSpaceClosure() {
}
}

// Constructor should define this.numComps, this.defaultColor, this.name
// Constructor should define this.numComps, this.name
function ColorSpace() {
unreachable('should not call ColorSpace constructor');
}
Expand Down Expand Up @@ -421,15 +421,13 @@ var ColorSpace = (function ColorSpaceClosure() {
* Separation color space is actually just a DeviceN with one color component.
* Both color spaces use a tinting function to convert colors to a base color
* space.
*
* The default color is `new Float32Array(new Array(numComps).fill(1))`.
*/
var AlternateCS = (function AlternateCSClosure() {
function AlternateCS(numComps, base, tintFn) {
this.name = 'Alternate';
this.numComps = numComps;
this.defaultColor = new Float32Array(numComps);
for (var i = 0; i < numComps; ++i) {
this.defaultColor[i] = 1;
}
this.base = base;
this.tintFn = tintFn;
this.tmpBuf = new Float32Array(base.numComps);
Expand Down Expand Up @@ -514,11 +512,13 @@ var PatternCS = (function PatternCSClosure() {
return PatternCS;
})();

/**
* The default color is `new Uint8Array([0])`.
*/
var IndexedCS = (function IndexedCSClosure() {
function IndexedCS(base, highVal, lookup) {
this.name = 'Indexed';
this.numComps = 1;
this.defaultColor = new Uint8Array(this.numComps);
this.base = base;
this.highVal = highVal;

Expand Down Expand Up @@ -585,11 +585,13 @@ var IndexedCS = (function IndexedCSClosure() {
return IndexedCS;
})();

/**
* The default color is `new Float32Array([0])`.
*/
var DeviceGrayCS = (function DeviceGrayCSClosure() {
function DeviceGrayCS() {
this.name = 'DeviceGray';
this.numComps = 1;
this.defaultColor = new Float32Array(this.numComps);
}

DeviceGrayCS.prototype = {
Expand Down Expand Up @@ -632,11 +634,13 @@ var DeviceGrayCS = (function DeviceGrayCSClosure() {
return DeviceGrayCS;
})();

/**
* The default color is `new Float32Array([0, 0, 0])`.
*/
var DeviceRgbCS = (function DeviceRgbCSClosure() {
function DeviceRgbCS() {
this.name = 'DeviceRGB';
this.numComps = 3;
this.defaultColor = new Float32Array(this.numComps);
}
DeviceRgbCS.prototype = {
getRgb: ColorSpace.prototype.getRgb,
Expand Down Expand Up @@ -684,6 +688,9 @@ var DeviceRgbCS = (function DeviceRgbCSClosure() {
return DeviceRgbCS;
})();

/**
* The default color is `new Float32Array([0, 0, 0, 1])`.
*/
var DeviceCmykCS = (function DeviceCmykCSClosure() {
// The coefficients below was found using numerical analysis: the method of
// steepest descent for the sum((f_i - color_value_i)^2) for r/g/b colors,
Expand Down Expand Up @@ -730,9 +737,6 @@ var DeviceCmykCS = (function DeviceCmykCSClosure() {
function DeviceCmykCS() {
this.name = 'DeviceCMYK';
this.numComps = 4;
this.defaultColor = new Float32Array(this.numComps);
// Set the fourth component to the maximum value for a black color.
this.defaultColor[3] = 1;
}
DeviceCmykCS.prototype = {
getRgb: ColorSpace.prototype.getRgb,
Expand Down Expand Up @@ -771,14 +775,15 @@ var DeviceCmykCS = (function DeviceCmykCSClosure() {
return DeviceCmykCS;
})();

//
// CalGrayCS: Based on "PDF Reference, Sixth Ed", p.245
//
/**
* CalGrayCS: Based on "PDF Reference, Sixth Ed", p.245
*
* The default color is `new Float32Array([0])`.
*/
var CalGrayCS = (function CalGrayCSClosure() {
function CalGrayCS(whitePoint, blackPoint, gamma) {
this.name = 'CalGray';
this.numComps = 1;
this.defaultColor = new Float32Array(this.numComps);

if (!whitePoint) {
throw new FormatError(
Expand Down Expand Up @@ -875,9 +880,11 @@ var CalGrayCS = (function CalGrayCSClosure() {
return CalGrayCS;
})();

//
// CalRGBCS: Based on "PDF Reference, Sixth Ed", p.247
//
/**
* CalRGBCS: Based on "PDF Reference, Sixth Ed", p.247
*
* The default color is `new Float32Array([0, 0, 0])`.
*/
var CalRGBCS = (function CalRGBCSClosure() {
// See http://www.brucelindbloom.com/index.html?Eqn_ChromAdapt.html for these
// matrices.
Expand Down Expand Up @@ -908,7 +915,6 @@ var CalRGBCS = (function CalRGBCSClosure() {
function CalRGBCS(whitePoint, blackPoint, gamma, matrix) {
this.name = 'CalRGB';
this.numComps = 3;
this.defaultColor = new Float32Array(this.numComps);

if (!whitePoint) {
throw new FormatError(
Expand Down Expand Up @@ -1162,14 +1168,15 @@ var CalRGBCS = (function CalRGBCSClosure() {
return CalRGBCS;
})();

//
// LabCS: Based on "PDF Reference, Sixth Ed", p.250
//
/**
* LabCS: Based on "PDF Reference, Sixth Ed", p.250
*
* The default color is `new Float32Array([0, 0, 0])`.
*/
var LabCS = (function LabCSClosure() {
function LabCS(whitePoint, blackPoint, range) {
this.name = 'Lab';
this.numComps = 3;
this.defaultColor = new Float32Array(this.numComps);

if (!whitePoint) {
throw new FormatError(
Expand Down