Align patterns and gradients to a grid
This commit is contained in:
+3
-2
@@ -8,8 +8,9 @@ import {toString} from './color.js';
|
||||
* A type accepted by CanvasRenderingContext2D.fillStyle
|
||||
* or CanvasRenderingContext2D.strokeStyle.
|
||||
* Represents a color, pattern, or gradient. The origin for patterns and
|
||||
* gradients as fill style is the top-left corner of the extent of the geometry
|
||||
* being filled.
|
||||
* gradients as fill style is an increment of 512 css pixels from map coordinate
|
||||
* `[0, 0]`. For seamless repeat patterns, width and height of the pattern image
|
||||
* must be a factor of two (2, 4, 8, ..., 512).
|
||||
*
|
||||
* @typedef {string|CanvasPattern|CanvasGradient} ColorLike
|
||||
* @api
|
||||
|
||||
@@ -456,8 +456,9 @@ CanvasReplay.prototype.beginGeometry = function(geometry, feature) {
|
||||
*/
|
||||
CanvasReplay.prototype.fill_ = function(context) {
|
||||
if (this.fillOrigin_) {
|
||||
const origin = applyTransform(this.renderedTransform_, this.fillOrigin_.slice());
|
||||
context.translate(origin[0], origin[1]);
|
||||
const origin = applyTransform(this.renderedTransform_, [0, 0]);
|
||||
const repeatSize = 512 * this.pixelRatio;
|
||||
context.translate(origin[0] % repeatSize, origin[1] % repeatSize);
|
||||
context.rotate(this.viewRotation_);
|
||||
}
|
||||
context.fill();
|
||||
|
||||
Reference in New Issue
Block a user