Merge pull request #871 from kkujala/constants

Use constants for radial and axial types.
This commit is contained in:
Julian Viereck 2011-12-05 09:24:06 -08:00
commit d5f4fd05c6

View File

@ -3,6 +3,11 @@
'use strict';
var PatternType = {
AXIAL: 2,
RADIAL: 3
};
var Pattern = (function patternPattern() {
// Constructor should define this.getPattern
function constructor() {
@ -28,9 +33,9 @@ var Pattern = (function patternPattern() {
var type = dict.get('ShadingType');
switch (type) {
case 2:
case 3:
// both radial and axial shadings are handled by RadialAxial shading
case PatternType.AXIAL:
case PatternType.RADIAL:
// Both radial and axial shadings are handled by RadialAxial shading.
return new Shadings.RadialAxial(dict, matrix, xref, res, ctx);
default:
return new Shadings.Dummy();
@ -117,9 +122,9 @@ Shadings.RadialAxial = (function radialAxialShading() {
}
var grad;
if (type == 2)
if (type == PatternType.AXIAL)
grad = ctx.createLinearGradient(p0[0], p0[1], p1[0], p1[1]);
else if (type == 3)
else if (type == PatternType.RADIAL)
grad = ctx.createRadialGradient(p0[0], p0[1], r0, p1[0], p1[1], r1);
for (var i = 0, ii = colorStops.length; i < ii; ++i) {
@ -133,12 +138,12 @@ Shadings.RadialAxial = (function radialAxialShading() {
getIR: function radialAxialShadingGetIR() {
var coordsArr = this.coordsArr;
var type = this.shadingType;
if (type == 2) {
if (type == PatternType.AXIAL) {
var p0 = [coordsArr[0], coordsArr[1]];
var p1 = [coordsArr[2], coordsArr[3]];
var r0 = null;
var r1 = null;
} else if (type == 3) {
} else if (type == PatternType.RADIAL) {
var p0 = [coordsArr[0], coordsArr[1]];
var p1 = [coordsArr[3], coordsArr[4]];
var r0 = coordsArr[2];