-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.html
233 lines (199 loc) · 11.8 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
<!doctype html>
<!--
Tangram: real-time WebGL rendering for OpenStreetMap
http://github.com/tangrams/tangram
http://mapzen.com
-->
<html lang="en-us">
<head>
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>Tangram Kinkade</title>
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.0.1/dist/leaflet.css" />
<link rel="stylesheet" href="kinkade.css" />
<link rel="stylesheet" href="lib/scarab/scarab.css" />
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
<script src="lib/jscolor.min.js"></script>
</head>
<body>
<!-- BEGIN UI -->
<div id="kinkade" onmouseover="hidePicker();">
<input id="picker" class="jscolor" value="ab5127" onchange="updateColorHex(this.value);"><br>
<div id="canvaswrapper" height="256">
<img id="reticle" src="reticle.png"/>
<canvas id="kcanvas" height="256" width="256"></canvas>
<div id="kvideo"></div>
</div>
<div id="swatches">
<div class="swatch" onclick="swatch(this)"></div>
<div class="swatch" onclick="swatch(this)"></div>
<div class="swatch" onclick="swatch(this)"></div>
<div class="swatch" onclick="swatch(this)"></div>
<div class="swatch" onclick="swatch(this)"></div>
<div class="swatch" onclick="swatch(this)"></div>
</div>
<!-- <button id="loadSwatches" class="kbutton" onclick="loadSwatches()">Reload Color Swatches</button> -->
<div class="brushes">
<div id="brush1" class="hitarea" onclick="updateWidth(10);updateAlpha(.2);switchBrush(this)"><button class="button-small"></button></div>
<div id="brush2" class="hitarea" onclick="updateWidth(40);updateAlpha(.2);switchBrush(this)"><button class="button-big"></button></div>
<div id="brush3" class="hitarea-fuzzy" onclick="updateWidth(60);updateAlpha(.05);switchFuzzyBrush(this)"><button class="button-blurry"></button></div>
</div>
<hr width="256px">
<div id="line_toggles">
<input type="checkbox" id="vector" checked onchange="updateLines(this.checked)">Lines
<input type="checkbox" id="labels" checked onchange="updateLabels(this.checked)">Labels
<input type="checkbox" id="ocean" checked onchange="updateOcean(this.checked)">Water
</div>
<hr>
Terrain Scale:<input id="scale" value="2" size=3 onchange="updateScale(this.value)">
<input id="scale_slider" class="slider50" type="range" min="0.01" max="5" value="2" step=".001" oninput="updateScale(this.value)">
<span class="span25">Blur:<input class="slider75" type="range" id="blur" min="0" max="100" value="0" step=".01" oninput="updateBlur(this.value)"></span>
<span class="span25">Rotate:<input class="slider75" type="range" id="rotate" min="-360" max="360" value="0" step="1" oninput="updateRotate(this.value)" onChange="resetRotate()"></span>
<hr width="256px">
<div id="webcamdiv">
<input type="checkbox" id="webcam" onchange="useWebcam(this.checked)">Webcam
<span id="flipspan"><input type="checkbox" id="flipwebcam" onchange="flipWebcam(this.checked)" disabled="true">Flip <button disabled="true" id="snapshot" onclick="snapshot()">Snapshot</button></span>
</div>
<hr width="256px">
Rewind:<br>
<div id="rewindwrapper" class="rewindwrapper">
<div id="ticks"></div>
<input disabled type="range" id="rewind" class="slider" min="0" max="1" value="1" step="1" oninput="rewind(this.value)">
</div>
<hr>
Presets:
<button class="kbutton" onclick="togglePane('examples')">Images</button>
<button class="kbutton" onclick="togglePane('locations')">Locations</button>
<hr>
<button class="kbutton" onclick="exportCanvas()">Export</button>
<!-- <input type="file" onchange="previewFile()" value="LOAD"> -->
<button class="kbutton" onclick="clearCanvas();updateMap();">Clear</button>
<button class="kbutton" onclick="togglePane('help');">Help</button>
<button class="kbutton" id="recordvideo" onclick="recordVideo();">Record Video</button>
<div id="loginsection" style="display:none">
<hr>
<div id="loginname">Nobody logged in!</div><button id="login" class="kbutton" onclick="mzUserSignin.openSignInWindow()">Sign In</button>
<div id="account-actions">
<button class="kbutton" onclick="togglePane('scenespane')">Load</button>
<button class="kbutton" onclick="togglePane('scenespane', true);saveScene();">Save</button>
<button id="logout" class="kbutton" onclick="logout()">Sign Out</button>
<!-- <button class="kbutton" onclick="get('/api/scenes/'+user.id, 'json', clearScenes);">DELETE ALL</button> -->
</div>
</div>
<!-- Hide blur image -->
<img id="lastCanvas" style="display:none"/>
</div>
<!-- BEGIN UI -->
<!-- Hide default dropzone thumbnail -->
<div id="preview-template" style="display: none;"><div></div></div>
<!-- <div id="save-dialog">SAVE SCENE</div> -->
<div id="panes">
<!-- examples pane -->
<div id="help"><h2>Tangram Kinkade</h2>
<hr>
<h3>To use</h3>
<p>Draw in the pane on the right to paint a spheremap, which will color the interactive map on the left.</p>
<!-- <p>Sign in with your <a href="https://mapzen.com/developers">Mapzen account</a> to save scenes, and then open and edit them in <a href="https://mapzen.com/tangram/play">Tangram Play</a>.</p> -->
<h3>How it works</h3>
This tool uses a technique called <a href="https://en.wikipedia.org/wiki/Sphere_mapping">sphere mapping</a>. An image (the "spheremap") is used to color 3D geometry, by treating the image as though it is wrapped around a sphere. Then, faces of the 3D object are assigned the same color as parallel faces on the imaginary sphere. For instance, the color on the left side of the spheremap will be the color of 3D faces which point left.</p>
<p>Using the <a href="http://github.co/tangrams//tangram">Tangram</a> map library, the <a href="https://www.nextzen.org/">Nextzen terrain tiles</a> are treated as though they are real 3D objects, and the spheremap technique can be applied to them too.
<h3>Learn more</h3>
<p>To read about how we use spheremaps in our <a href="https://mapzen.com/documentation/cartography/styles/#walkabout">Walkabout basemap</a>, read our blog post <a href="https://mapzen.com/blog/sphere-maps/">Sphere Maps.</a></p>
<p>To learn more about using spheremaps in cartography, read our blog post <a href="https://mapzen.com/blog/mapping-mountains/">Mapping Mountains</a>.</p>
<p>The <a href="https://github.com/tangrams/kinkade">code</a> for this <a href="https://mapzen.com">Mapzen</a> project is open-source and freely available.</p>
<h3>Secrets</h3>
<p>You can drag an image directly into the drawing pane!</p>
<p>Press 'H' to hide and show the interface!</p>
</div>
<!-- examples pane -->
<div id="examples">example images
<hr>
<a onclick="swapimg(this)"><img class="example" src="examples/aurora.png"></a>
<a onclick="swapimg(this)"><img class="example" src="examples/fivedots.png"></a>
<a onclick="swapimg(this)"><img class="example" src="examples/imhof5.jpg"></a>
<a onclick="swapimg(this)"><img class="example" src="examples/emerald.png"></a>
<a onclick="swapimg(this)"><img class="example" src="examples/treefrog.png"></a>
<a onclick="swapimg(this)"><img class="example" src="examples/normals.jpg"></a>
<a id="default" onclick="swapimg(this)"><img class="example" src="examples/slope.png"></a>
<a onclick="swapimg(this)"><img class="example" src="examples/dorodango.png"></a>
<a onclick="swapimg(this)"><img class="example" src="examples/doro2.jpg"></a>
<a onclick="swapimg(this)"><img class="example" src="examples/doro3.jpg"></a>
<a onclick="swapimg(this)"><img class="example" src="examples/doro4.jpg"></a>
<a onclick="swapimg(this)"><img class="example" src="examples/doro5.jpg"></a>
<a onclick="swapimg(this)"><img class="example" src="examples/doro6.jpg"></a>
<a onclick="swapimg(this)"><img class="example" src="examples/doro7.jpg"></a>
<a onclick="swapimg(this)"><img class="example" src="examples/doro8.jpg"></a>
</div>
<!-- locations pane -->
<div id="locations">locations
<hr>
<a class="location" onclick="map.flyTo([35.3624,138.7388],12.65879,{duration: 1.5})">Mt. Fuji, Japan</a><br>
<a class="location" onclick="map.flyTo([45.9808,7.6595],12.35492,{duration: 1.5})">Matterhorn</a><br>
<a class="location" onclick="map.flyTo([37.7393,-119.5929],13.17645,{duration: 1.5})">Yosemite Valley, CA, USA</a><br>
<a class="location" onclick="map.flyTo([44.8535,-118.3326],9.90145,{duration: 1.5})">Northeastern Oregon, USA</a><br>
<a class="location" onclick="map.flyTo([53.4419,54.5289],9.06812,{duration: 1.5})">Western Bashkorotostan, Russia</a><br>
<a class="location" onclick="map.flyTo([19.4061,83.8115],11.29881,{duration: 1.5})">Eastern Ghats, India</a><br>
<a class="location" onclick="map.flyTo([26.5667,65.0077],9.51131,{duration: 1.5})">Balochistan, Pakistan</a><br>
<a class="location" onclick="map.flyTo([29.3709,5.2959],9.25714,{duration: 1.5})">Issaouane Erg, Algeria</a><br>
<a class="location" onclick="map.flyTo([36.2434,-112.2843],11.07228,{duration: 1.5})">Grand Canyon, Arizona, USA</a><br>
<a class="location" onclick="map.flyTo([46.2051,-122.1737],13.21471,{duration: 1.5})">Mt. St. Helens, Washington, USA</a><br>
<a class="location" onclick="map.flyTo([33.4393,-91.1579],11.50000,{duration: 1.5})">Mississippi Meanders</a><br>
</div>
<!-- API scenes pane -->
<div class="clearfix">
<div id="scenespane">scenes
<hr>
<div id="scenes"></div>
</div>
</div>
</div>
<!-- END UI -->
<script>
// http://www.paulirish.com/2009/random-hex-color-code-snippets/
var n = Math.floor(Math.random()*16777215).toString(16);
// http://stackoverflow.com/a/10073788/738675
n = n.length >= 6 ? n : new Array(6 - n.length + 1).join('0') + n;
var picker = document.getElementById('picker');
picker.value = n;
function hidePicker() {
if (typeof picker.jscolor != 'undefined') picker.jscolor.hide();
}
picker.onmouseover = function(e) {
picker.jscolor.show();
e.stopPropagation(); // prevent the kinkade.onmouseover from hiding the popup immediately
}
</script>
<div id="map"></div>
<!-- 3rd party libraries -->
<!-- leaflet -->
<script src="https://unpkg.com/leaflet@1.2.0/dist/leaflet.js"></script>
<!-- bog-standard leaflet URL hash -->
<script src="lib/leaflet-hash.js"></script>
<!-- make canvas.toBlob work in Safari -->
<script type="text/javascript" src="lib/Blob.js"></script>
<script type="text/javascript" src="lib/canvas-toBlob.js"></script>
<!-- drag-n-drop upload - http://www.dropzonejs.com/ -->
<script type="text/javascript" src="lib/dropzone.js"></script>
<!-- blur - https://github.com/flozz/StackBlur -->
<script type="text/javascript" src="lib/StackBlur.js"></script>
<!-- webcam - https://github.com/jhuckaby/webcamjs -->
<script type="text/javascript" src="lib/webcam.min.js"></script>
<!-- color-thief https://github.com/lokesh/color-thief -->
<script type="text/javascript" src="lib/color-thief.min.js"></script>
<!-- FileSaver.js https://github.com/eligrey/FileSaver.js -->
<script type="text/javascript" src="lib/FileSaver.min.js"></script>
<!-- End of 3rd party libraries -->
<!-- Main tangram library -->
<script src="https://unpkg.com/tangram/dist/tangram.min.js"></script> <!-- use NPM CDN -->
<!-- <script src="http://192.168.41.246:8000/dist/tangram.debug.js"></script> -->
<!-- Main demo code -->
<script src="lib/thumbnail.js"></script>
<script src="main.js"></script>
<!-- rewind wrapper style placeholder -->
<style>
#rewindwrapper {}
</style>
</body>
</html>