Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
oscarfonts committed Jul 16, 2024
1 parent 37443d1 commit ea1be9f
Show file tree
Hide file tree
Showing 7 changed files with 365 additions and 6 deletions.
2 changes: 1 addition & 1 deletion color-ramp.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
map.on('load', () => {
map.addSource('imageSource', {
type: 'raster',
url: 'cog://./data/kriging.tif#color:BrewerSpectral9,1.7084054885838,1.7919403772937',
url: 'cog://./data/kriging.tif#color:BrewerSpectral7,1.7084054885838,1.7919403772937,c',
});

map.addLayer({
Expand Down
54 changes: 54 additions & 0 deletions colors.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Color Ramp cheatsheet</title>
<link rel="stylesheet" href="vanilla.css">
<style>
.colorItem {
display: inline-block;
width: 1px;
height: 20px;
}
</style>
<script src="dist/index.js"></script>
</head>
<body>
<h1>Color Ramp cheatsheet</h1>
<div id="colorSchemes"></div>
<script>
const {colorInterpolator, colorSchemeNames} = MaplibreCOGProtocol;

const rows = colorSchemeNames.map(colorScheme => {
const interpolateDisc = colorInterpolator({colorScheme, min: 0,max: 230});
const discreteRamp = Array.from({length: 231}, (x, i) => {
const [r, g, b] = interpolateDisc(i);
return `<span class="colorItem" style="background: rgb(${r}, ${g}, ${b})"></span>`;
}).join('');

const interpolateCont = colorInterpolator({colorScheme, min: 0, max: 230, isContinuous: true});
const continuousRamp = Array.from({length: 231}, (x, i) => {
const [r, g, b] = interpolateCont(i);
return `<span class="colorItem" style="background: rgb(${r}, ${g}, ${b})"></span>`;
}).join('');

return `<tr>
<td>${colorScheme}</td>
<td>${discreteRamp}</td>
<td>${continuousRamp}</td>
</tr>`;
}).join('');

document.getElementById('colorSchemes').innerHTML = `<table>
<tr>
<th>colorScheme</th>
<th>discrete</th>
<th>continuous</th>
</tr>
${rows}
</table>`;

</script>
</body>
</html>
303 changes: 303 additions & 0 deletions dist/colorInterpolator.d.ts

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion dist/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
import cogProtocol from '@/cogProtocol';
export { cogProtocol };
import { colorInterpolator, colorSchemeNames } from '@/colorInterpolator';
export { cogProtocol, colorInterpolator, colorSchemeNames };
6 changes: 3 additions & 3 deletions dist/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ <h2>Examples</h2>

<h2>Resources</h2>
<ul>
<li><a href="colors.html">Color Ramp cheatsheet</a></li>
<li><a href="http://github.com/geomatico/maplibre-cog-protocol">GitHub repository</a></li>
</ul>

Expand Down

0 comments on commit ea1be9f

Please sign in to comment.