Merge pull request #5449 from CodingFabian/preferParamsOverArguments

Use 3 param method for converting r,g,b into css string.
This commit is contained in:
Yury Delendik 2014-12-08 15:23:12 -06:00
commit 35474628e3
6 changed files with 23 additions and 23 deletions

View File

@ -155,14 +155,14 @@ Shadings.RadialAxial = (function RadialAxialClosure() {
ratio[0] = i; ratio[0] = i;
fn(ratio, 0, color, 0); fn(ratio, 0, color, 0);
rgbColor = cs.getRgb(color, 0); rgbColor = cs.getRgb(color, 0);
var cssColor = Util.makeCssRgb(rgbColor); var cssColor = Util.makeCssRgb(rgbColor[0], rgbColor[1], rgbColor[2]);
colorStops.push([(i - t0) / diff, cssColor]); colorStops.push([(i - t0) / diff, cssColor]);
} }
var background = 'transparent'; var background = 'transparent';
if (dict.has('Background')) { if (dict.has('Background')) {
rgbColor = cs.getRgb(dict.get('Background'), 0); rgbColor = cs.getRgb(dict.get('Background'), 0);
background = Util.makeCssRgb(rgbColor); background = Util.makeCssRgb(rgbColor[0], rgbColor[1], rgbColor[2]);
} }
if (!extendStart) { if (!extendStart) {

View File

@ -62,11 +62,9 @@ var AnnotationUtils = (function AnnotationUtilsClosure() {
container.style.backgroundColor = item.color; container.style.backgroundColor = item.color;
var color = item.color; var color = item.color;
var rgb = []; item.colorCssRgb = Util.makeCssRgb(Math.round(color[0] * 255),
for (var i = 0; i < 3; ++i) { Math.round(color[1] * 255),
rgb[i] = Math.round(color[i] * 255); Math.round(color[2] * 255));
}
item.colorCssRgb = Util.makeCssRgb(rgb);
var highlight = document.createElement('div'); var highlight = document.createElement('div');
highlight.className = 'annotationHighlight'; highlight.className = 'annotationHighlight';
@ -136,13 +134,15 @@ var AnnotationUtils = (function AnnotationUtilsClosure() {
var i, ii; var i, ii;
if (item.hasBgColor) { if (item.hasBgColor) {
var color = item.color; var color = item.color;
var rgb = [];
for (i = 0; i < 3; ++i) { // Enlighten the color (70%)
// Enlighten the color (70%) var BACKGROUND_ENLIGHT = 0.7;
var c = Math.round(color[i] * 255); var r = BACKGROUND_ENLIGHT * (1.0 - color[0]) + color[0];
rgb[i] = Math.round((255 - c) * 0.7) + c; var g = BACKGROUND_ENLIGHT * (1.0 - color[1]) + color[1];
} var b = BACKGROUND_ENLIGHT * (1.0 - color[2]) + color[2];
content.style.backgroundColor = Util.makeCssRgb(rgb); content.style.backgroundColor = Util.makeCssRgb((r * 255) | 0,
(g * 255) | 0,
(b * 255) | 0);
} }
var title = document.createElement('h1'); var title = document.createElement('h1');

View File

@ -1553,12 +1553,12 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
this.current.fillColor = this.getColorN_Pattern(arguments); this.current.fillColor = this.getColorN_Pattern(arguments);
}, },
setStrokeRGBColor: function CanvasGraphics_setStrokeRGBColor(r, g, b) { setStrokeRGBColor: function CanvasGraphics_setStrokeRGBColor(r, g, b) {
var color = Util.makeCssRgb(arguments); var color = Util.makeCssRgb(r, g, b);
this.ctx.strokeStyle = color; this.ctx.strokeStyle = color;
this.current.strokeColor = color; this.current.strokeColor = color;
}, },
setFillRGBColor: function CanvasGraphics_setFillRGBColor(r, g, b) { setFillRGBColor: function CanvasGraphics_setFillRGBColor(r, g, b) {
var color = Util.makeCssRgb(arguments); var color = Util.makeCssRgb(r, g, b);
this.ctx.fillStyle = color; this.ctx.fillStyle = color;
this.current.fillColor = color; this.current.fillColor = color;
}, },

View File

@ -400,7 +400,7 @@ var TilingPattern = (function TilingPatternClosure() {
context.strokeStyle = ctx.strokeStyle; context.strokeStyle = ctx.strokeStyle;
break; break;
case PaintType.UNCOLORED: case PaintType.UNCOLORED:
var cssColor = Util.makeCssRgb(color); var cssColor = Util.makeCssRgb(color[0], color[1], color[2]);
context.fillStyle = cssColor; context.fillStyle = cssColor;
context.strokeStyle = cssColor; context.strokeStyle = cssColor;
break; break;

View File

@ -822,11 +822,11 @@ var SVGGraphics = (function SVGGraphicsClosure() {
this.current.miterLimit = limit; this.current.miterLimit = limit;
}, },
setStrokeRGBColor: function SVGGraphics_setStrokeRGBColor(r, g, b) { setStrokeRGBColor: function SVGGraphics_setStrokeRGBColor(r, g, b) {
var color = Util.makeCssRgb(arguments); var color = Util.makeCssRgb(r, g, b);
this.current.strokeColor = color; this.current.strokeColor = color;
}, },
setFillRGBColor: function SVGGraphics_setFillRGBColor(r, g, b) { setFillRGBColor: function SVGGraphics_setFillRGBColor(r, g, b) {
var color = Util.makeCssRgb(arguments); var color = Util.makeCssRgb(r, g, b);
this.current.fillColor = color; this.current.fillColor = color;
this.current.tspan = document.createElementNS(NS, 'svg:tspan'); this.current.tspan = document.createElementNS(NS, 'svg:tspan');
this.current.xcoords = []; this.current.xcoords = [];

View File

@ -574,10 +574,10 @@ var Util = PDFJS.Util = (function UtilClosure() {
// makeCssRgb() can be called thousands of times. Using |rgbBuf| avoids // makeCssRgb() can be called thousands of times. Using |rgbBuf| avoids
// creating many intermediate strings. // creating many intermediate strings.
Util.makeCssRgb = function Util_makeCssRgb(rgb) { Util.makeCssRgb = function Util_makeCssRgb(r, g, b) {
rgbBuf[1] = rgb[0]; rgbBuf[1] = r;
rgbBuf[3] = rgb[1]; rgbBuf[3] = g;
rgbBuf[5] = rgb[2]; rgbBuf[5] = b;
return rgbBuf.join(''); return rgbBuf.join('');
}; };