Clip tile layers by extent
This commit is contained in:
@@ -85,6 +85,39 @@ class CanvasLayerRenderer extends LayerRenderer {
|
||||
rotateAtOffset(context, rotation, halfWidth, halfHeight);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {CanvasRenderingContext2D} context Context.
|
||||
* @param {import("../../PluggableMap.js").FrameState} frameState Frame state.
|
||||
* @param {import("../../extent.js").Extent} extent Clip extent.
|
||||
* @protected
|
||||
*/
|
||||
clipUnrotated(context, frameState, extent) {
|
||||
const topLeft = getTopLeft(extent);
|
||||
const topRight = getTopRight(extent);
|
||||
const bottomRight = getBottomRight(extent);
|
||||
const bottomLeft = getBottomLeft(extent);
|
||||
|
||||
applyTransform(frameState.coordinateToPixelTransform, topLeft);
|
||||
applyTransform(frameState.coordinateToPixelTransform, topRight);
|
||||
applyTransform(frameState.coordinateToPixelTransform, bottomRight);
|
||||
applyTransform(frameState.coordinateToPixelTransform, bottomLeft);
|
||||
|
||||
const inverted = invertTransform(this.pixelTransform_.slice());
|
||||
|
||||
applyTransform(inverted, topLeft);
|
||||
applyTransform(inverted, topRight);
|
||||
applyTransform(inverted, bottomRight);
|
||||
applyTransform(inverted, bottomLeft);
|
||||
|
||||
context.save();
|
||||
context.beginPath();
|
||||
context.moveTo(Math.round(topLeft[0]), Math.round(topLeft[1]));
|
||||
context.lineTo(Math.round(topRight[0]), Math.round(topRight[1]));
|
||||
context.lineTo(Math.round(bottomRight[0]), Math.round(bottomRight[1]));
|
||||
context.lineTo(Math.round(bottomLeft[0]), Math.round(bottomLeft[1]));
|
||||
context.clip();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {import("../../render/EventType.js").default} type Event type.
|
||||
* @param {CanvasRenderingContext2D} context Context.
|
||||
|
||||
Reference in New Issue
Block a user