11<!DOCTYPE html>
22< html >
3+
34< head >
4- < meta charset ="utf-8 "/>
5- < meta name ="viewport " content ="initial-scale=1,maximum-scale=1,user-scalable=no "/>
6- < style >
7- body {
8- margin : 10px ;
9- padding : 0 ;
10- font-family : sans-serif;
11- }
12-
13- # colorramp-contain > * {
14- margin-bottom : 6px ;
15- display : flex;
16- }
17-
18- # colorramp-contain > div > span {
19- width : 185px ;
20- height : 20px ;
21- line-height : 20px ;
22- background : # eeeeee ;
23- text-align : center;
24- margin-right : 5px ;
25- border-radius : 3px ;
26- color : # 04040496 ;
27- font-size : 12px ;
28- }
29-
30- # colorramp-contain > div > canvas {
31- width : calc (100% - 190px );
32- border-radius : 3px ;
33- }
34-
35-
36- # colorramp-contain > div : nth-of-type (1 ) > canvas
37- {
38- border : 1px dashed # 00000059 ;
39- }
40-
41-
42- </ style >
5+ < meta charset ="utf-8 " />
6+ < meta name ="viewport " content ="initial-scale=1,maximum-scale=1,user-scalable=no " />
7+ < style >
8+ body {
9+ margin : 10px ;
10+ padding : 0 ;
11+ font-family : sans-serif;
12+ }
13+
14+ # colorramp-contain > * {
15+ margin-bottom : 6px ;
16+ display : flex;
17+ }
18+
19+ # colorramp-contain > div > span {
20+ width : 185px ;
21+ height : 20px ;
22+ line-height : 20px ;
23+ background : # eeeeee ;
24+ text-align : center;
25+ margin-right : 5px ;
26+ border-radius : 3px ;
27+ color : # 04040496 ;
28+ font-size : 12px ;
29+ }
30+
31+ # colorramp-contain > div > canvas {
32+ width : calc (100% - 190px );
33+ border-radius : 3px ;
34+ }
35+
36+
37+ # colorramp-contain > div : nth-of-type (1 )> canvas {
38+ border : 1px dashed # 00000059 ;
39+ }
40+ </ style >
4341</ head >
4442
4543< body >
44+ < div id ="colorramp-contain "> </ div >
4645
47- < div id ="colorramp-contain "> </ div >
46+ < script src ="../build/maptiler-sdk.umd.min.js "> </ script >
47+ < script >
48+ const colorrampContainer = document . getElementById ( "colorramp-contain" ) ;
4849
49- < script src =" ../build/maptiler-sdk.umd.js " > </ script >
50- < script >
51- const colorrampContainer = document . getElementById ( "colorramp-contain" ) ;
50+ function displayColorRamp ( name , colorramp , extraInfo = "" ) {
51+ const canvas = colorramp . getCanvasStrip ( ) ;
52+ canvas . style . height = "20px" ;
5253
53- function displayColorRamp ( name , colorramp , extraInfo = "" ) {
54- const canvas = colorramp . getCanvasStrip ( ) ;
55- canvas . style . height = "20px" ;
56- // canvas.style.width = "100%";
57- // canvas.style.border = "1px dashed #00000059";
54+ const bounds = colorramp . getBounds ( )
5855
59- const bounds = colorramp . getBounds ( )
56+ const div = document . createElement ( "div" ) ;
57+ const descSpan = document . createElement ( "span" ) ;
58+ descSpan . innerHTML = `${ name } ${ extraInfo } ` ;
6059
61- const div = document . createElement ( "div" ) ;
62- const descSpan = document . createElement ( "span" ) ;
63- // descSpan.innerHTML = `${name}${extraInfo} [${bounds.min}, ${bounds.max}]`;
64- descSpan . innerHTML = `${ name } ${ extraInfo } ` ;
65-
60+ div . appendChild ( descSpan ) ;
61+ div . appendChild ( canvas ) ;
62+ colorrampContainer . appendChild ( div ) ;
63+ } ;
6664
67- div . appendChild ( descSpan ) ;
68- div . appendChild ( canvas ) ;
69- colorrampContainer . appendChild ( div ) ;
70- }
71-
7265 Object . keys ( maptilersdk . ColorRampCollection ) . forEach ( ( k , i ) => {
73- const colorramp = maptilersdk . ColorRampCollection [ k ] ;
74- displayColorRamp ( k , colorramp ) ;
75-
76- // if (i === 0) return;
66+ const colorramp = maptilersdk . ColorRampCollection [ k ] ;
67+ displayColorRamp ( k , colorramp ) ;
7768
78- // displayColorRamp(k, colorramp.resample("ease-in-square"), ', resampling method: "ease-in-square"')
79- // displayColorRamp(k, colorramp.resample("ease-in-sqrt"), ', resampling method: "ease-in-sqrt"')
80- // displayColorRamp(k, colorramp.resample("ease-in-exp"), ', resampling method: "ease-in-exp"')
69+ // if (i === 0) return;
8170
82- // displayColorRamp(k, colorramp.resample("ease-out -square"), ', resampling method: "ease-out -square"')
83- // displayColorRamp(k, colorramp.resample("ease-out -sqrt"), ', resampling method: "ease-out -sqrt"')
84- // displayColorRamp(k, colorramp.resample("ease-out -exp"), ', resampling method: "ease-out -exp"')
71+ // displayColorRamp(k, colorramp.resample("ease-in -square"), ', resampling method: "ease-in -square"')
72+ // displayColorRamp(k, colorramp.resample("ease-in -sqrt"), ', resampling method: "ease-in -sqrt"')
73+ // displayColorRamp(k, colorramp.resample("ease-in -exp"), ', resampling method: "ease-in -exp"')
8574
86-
75+ // displayColorRamp(k, colorramp.resample("ease-out-square"), ', resampling method: "ease-out-square"')
76+ // displayColorRamp(k, colorramp.resample("ease-out-sqrt"), ', resampling method: "ease-out-sqrt"')
77+ // displayColorRamp(k, colorramp.resample("ease-out-exp"), ', resampling method: "ease-out-exp"')
8778
88- // colorrampContainer.appendChild( document.createElement("p") );
89- } )
90-
91-
92-
93-
94- </ script >
79+ // colorrampContainer.appendChild( document.createElement("p") );
80+ } ) ;
81+ </ script >
9582</ body >
96- </ html >
83+
84+ </ html >
0 commit comments