ol-mapbox-style
Advanced tools
Comparing version 6.5.2 to 6.5.3
# Changelog | ||
## 6.5.3 | ||
* Fix handling of `icon-color` | ||
## 6.5.2 | ||
@@ -4,0 +8,0 @@ |
@@ -521,36 +521,19 @@ /* | ||
var spriteImageData = spriteData[icon]; | ||
if (iconColor !== null) { | ||
// cut out the sprite and color it | ||
var canvas = createCanvas(spriteImageData.width, spriteImageData.height); | ||
var ctx = /** @type {CanvasRenderingContext2D} */ (canvas.getContext('2d')); | ||
ctx.drawImage(spriteImage, spriteImageData.x, spriteImageData.y, spriteImageData.width, spriteImageData.height, 0, 0, spriteImageData.width, spriteImageData.height); | ||
var data = ctx.getImageData(0, 0, canvas.width, canvas.height); | ||
for (var c = 0, cc = data.data.length; c < cc; c += 4) { | ||
var a = iconColor.a; | ||
if (a !== 0) { | ||
data.data[c] = (iconColor.r * 255) / a; | ||
data.data[c + 1] = (iconColor.g * 255) / a; | ||
data.data[c + 2] = (iconColor.b * 255) / a; | ||
} | ||
data.data[c + 3] = a; | ||
} | ||
ctx.putImageData(data, 0, 0); | ||
iconImg = new Icon({ | ||
img: canvas, | ||
imgSize: [canvas.width, canvas.height], | ||
scale: iconSize / spriteImageData.pixelRatio, | ||
}); | ||
iconImageCache[icon_cache_key] = iconImg; | ||
} | ||
else { | ||
iconImg = new Icon({ | ||
img: spriteImage, | ||
imgSize: spriteImgSize, | ||
size: [spriteImageData.width, spriteImageData.height], | ||
offset: [spriteImageData.x, spriteImageData.y], | ||
rotateWithView: iconRotationAlignment === 'map', | ||
scale: iconSize / spriteImageData.pixelRatio, | ||
}); | ||
iconImageCache[icon_cache_key] = iconImg; | ||
} | ||
iconImg = new Icon({ | ||
color: iconColor | ||
? [ | ||
iconColor.r * 255, | ||
iconColor.g * 255, | ||
iconColor.b * 255, | ||
iconColor.a, | ||
] | ||
: undefined, | ||
img: spriteImage, | ||
imgSize: spriteImgSize, | ||
size: [spriteImageData.width, spriteImageData.height], | ||
offset: [spriteImageData.x, spriteImageData.y], | ||
rotateWithView: iconRotationAlignment === 'map', | ||
scale: iconSize / spriteImageData.pixelRatio, | ||
}); | ||
iconImageCache[icon_cache_key] = iconImg; | ||
} | ||
@@ -557,0 +540,0 @@ } |
{ | ||
"name": "ol-mapbox-style", | ||
"version": "6.5.2", | ||
"version": "6.5.3", | ||
"description": "Create OpenLayers maps from Mapbox Style objects", | ||
@@ -39,3 +39,4 @@ "main": "dist/index.js", | ||
"@types/geojson": "^7946.0.7", | ||
"@types/node": "^12.12.19", | ||
"@types/node": "^16.11.7", | ||
"@types/offscreencanvas": "^2019.6.4", | ||
"@types/topojson-specification": "^1.0.1", | ||
@@ -45,3 +46,3 @@ "babel-loader": "^8.0.6", | ||
"buble-loader": "^0.5.1", | ||
"copy-webpack-plugin": "^6.0.3", | ||
"copy-webpack-plugin": "^9.1.0", | ||
"coverage-istanbul-loader": "^3.0.5", | ||
@@ -68,3 +69,3 @@ "css-loader": "^6.5.1", | ||
"style-loader": "^3.3.1", | ||
"typescript": "4.3", | ||
"typescript": "4.4", | ||
"webpack": "^5.62.1", | ||
@@ -71,0 +72,0 @@ "webpack-cli": "^4.9.1", |
@@ -8,3 +8,3 @@ To create and publish a release, perform the following steps: | ||
git checkout -b v2.11.0 origin/master | ||
git checkout -b v2.11.0 origin/main | ||
@@ -11,0 +11,0 @@ ### Bump the version in package.json |
@@ -668,55 +668,20 @@ /* | ||
const spriteImageData = spriteData[icon]; | ||
if (iconColor !== null) { | ||
// cut out the sprite and color it | ||
const canvas = createCanvas( | ||
spriteImageData.width, | ||
spriteImageData.height | ||
); | ||
const ctx = /** @type {CanvasRenderingContext2D} */ ( | ||
canvas.getContext('2d') | ||
); | ||
ctx.drawImage( | ||
spriteImage, | ||
spriteImageData.x, | ||
spriteImageData.y, | ||
spriteImageData.width, | ||
spriteImageData.height, | ||
0, | ||
0, | ||
spriteImageData.width, | ||
spriteImageData.height | ||
); | ||
const data = ctx.getImageData( | ||
0, | ||
0, | ||
canvas.width, | ||
canvas.height | ||
); | ||
for (let c = 0, cc = data.data.length; c < cc; c += 4) { | ||
const a = iconColor.a; | ||
if (a !== 0) { | ||
data.data[c] = (iconColor.r * 255) / a; | ||
data.data[c + 1] = (iconColor.g * 255) / a; | ||
data.data[c + 2] = (iconColor.b * 255) / a; | ||
} | ||
data.data[c + 3] = a; | ||
} | ||
ctx.putImageData(data, 0, 0); | ||
iconImg = new Icon({ | ||
img: canvas, | ||
imgSize: [canvas.width, canvas.height], | ||
scale: iconSize / spriteImageData.pixelRatio, | ||
}); | ||
iconImageCache[icon_cache_key] = iconImg; | ||
} else { | ||
iconImg = new Icon({ | ||
img: spriteImage, | ||
imgSize: spriteImgSize, | ||
size: [spriteImageData.width, spriteImageData.height], | ||
offset: [spriteImageData.x, spriteImageData.y], | ||
rotateWithView: iconRotationAlignment === 'map', | ||
scale: iconSize / spriteImageData.pixelRatio, | ||
}); | ||
iconImageCache[icon_cache_key] = iconImg; | ||
} | ||
iconImg = new Icon({ | ||
color: iconColor | ||
? [ | ||
iconColor.r * 255, | ||
iconColor.g * 255, | ||
iconColor.b * 255, | ||
iconColor.a, | ||
] | ||
: undefined, | ||
img: spriteImage, | ||
imgSize: spriteImgSize, | ||
size: [spriteImageData.width, spriteImageData.height], | ||
offset: [spriteImageData.x, spriteImageData.y], | ||
rotateWithView: iconRotationAlignment === 'map', | ||
scale: iconSize / spriteImageData.pixelRatio, | ||
}); | ||
iconImageCache[icon_cache_key] = iconImg; | ||
} | ||
@@ -723,0 +688,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8584629
34
94
13128