Indicate required fill alignment with boolean
This commit is contained in:
@@ -87,9 +87,9 @@ const CanvasReplay = function(tolerance, maxExtent, resolution, pixelRatio, over
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @type {module:ol/coordinate~Coordinate}
|
* @type {boolean}
|
||||||
*/
|
*/
|
||||||
this.fillOrigin_;
|
this.alignFill_;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
@@ -191,7 +191,7 @@ CanvasReplay.prototype.replayTextBackground_ = function(context, p1, p2, p3, p4,
|
|||||||
context.lineTo.apply(context, p4);
|
context.lineTo.apply(context, p4);
|
||||||
context.lineTo.apply(context, p1);
|
context.lineTo.apply(context, p1);
|
||||||
if (fillInstruction) {
|
if (fillInstruction) {
|
||||||
this.fillOrigin_ = /** @type {Array.<number>} */ (fillInstruction[2]);
|
this.alignFill_ = /** @type {boolean} */ (fillInstruction[2]);
|
||||||
this.fill_(context);
|
this.fill_(context);
|
||||||
}
|
}
|
||||||
if (strokeInstruction) {
|
if (strokeInstruction) {
|
||||||
@@ -455,14 +455,14 @@ CanvasReplay.prototype.beginGeometry = function(geometry, feature) {
|
|||||||
* @param {CanvasRenderingContext2D} context Context.
|
* @param {CanvasRenderingContext2D} context Context.
|
||||||
*/
|
*/
|
||||||
CanvasReplay.prototype.fill_ = function(context) {
|
CanvasReplay.prototype.fill_ = function(context) {
|
||||||
if (this.fillOrigin_) {
|
if (this.alignFill_) {
|
||||||
const origin = applyTransform(this.renderedTransform_, [0, 0]);
|
const origin = applyTransform(this.renderedTransform_, [0, 0]);
|
||||||
const repeatSize = 512 * this.pixelRatio;
|
const repeatSize = 512 * this.pixelRatio;
|
||||||
context.translate(origin[0] % repeatSize, origin[1] % repeatSize);
|
context.translate(origin[0] % repeatSize, origin[1] % repeatSize);
|
||||||
context.rotate(this.viewRotation_);
|
context.rotate(this.viewRotation_);
|
||||||
}
|
}
|
||||||
context.fill();
|
context.fill();
|
||||||
if (this.fillOrigin_) {
|
if (this.alignFill_) {
|
||||||
context.setTransform.apply(context, resetTransform);
|
context.setTransform.apply(context, resetTransform);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -795,7 +795,7 @@ CanvasReplay.prototype.replay_ = function(
|
|||||||
break;
|
break;
|
||||||
case CanvasInstruction.SET_FILL_STYLE:
|
case CanvasInstruction.SET_FILL_STYLE:
|
||||||
lastFillInstruction = instruction;
|
lastFillInstruction = instruction;
|
||||||
this.fillOrigin_ = instruction[2];
|
this.alignFill_ = instruction[2];
|
||||||
|
|
||||||
if (pendingFill) {
|
if (pendingFill) {
|
||||||
this.fill_(context);
|
this.fill_(context);
|
||||||
@@ -966,8 +966,8 @@ CanvasReplay.prototype.createFill = function(state, geometry) {
|
|||||||
const fillStyle = state.fillStyle;
|
const fillStyle = state.fillStyle;
|
||||||
const fillInstruction = [CanvasInstruction.SET_FILL_STYLE, fillStyle];
|
const fillInstruction = [CanvasInstruction.SET_FILL_STYLE, fillStyle];
|
||||||
if (typeof fillStyle !== 'string') {
|
if (typeof fillStyle !== 'string') {
|
||||||
const fillExtent = geometry.getExtent();
|
// Fill is a pattern or gradient - align it!
|
||||||
fillInstruction.push([fillExtent[0], fillExtent[3]]);
|
fillInstruction.push(true);
|
||||||
}
|
}
|
||||||
return fillInstruction;
|
return fillInstruction;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user