-
Notifications
You must be signed in to change notification settings - Fork 12
/
refill-style.yaml
4927 lines (4766 loc) · 207 KB
/
refill-style.yaml
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
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# Refill provides a high contrast, black & white basemap useful for data visualization.
# Give OpenStreetMap data a professional basemap skin using the Tangram graphics library
# and Mapzen's versatile Vector Tiles.
#
# Refill is a modern GL take on Geraldine's work on Toner for Stamen as part of their
# great CityTracking project. Please use and adapt the open source scene file in
# your own projects!
#
# Authors: Geraldine Sarmiento, Nathaniel V. Kelso
# Read more: https://github.com/tangrams/refill-style
#
import:
- themes/refill-icons.yaml
- themes/color-black.yaml
- themes/label-5.yaml
global:
# Sign up for a Mapzen API key to enjoy higher rate limits
# https://mapzen.com/documentation/overview/#developer-accounts-and-api-keys
sdk_api_key: '' # set this value to your Mapzen API key
#ux/ui
ux_language: false # l10n language code, trusting OSM in v0.10 tiles, fixed in v1.0 tiles
ux_language_fallback: false # l10n language code, trusting OSM in v0.10 tiles, fixed in v1.0 tiles
ux_language_text_source: |
function() {
// if a ux_langauge has been defined use that, else if there is feature name in the fallback_ux_language then use that, else use the feature's default name in the local language
return (global.ux_language && feature['name:'+global.ux_language]) || (global.ux_language_fallback && feature['name:'+global.ux_language_fallback]) || feature.name;
}
ux_language_text_source_left: |
function() {
// if a ux_langauge has been defined use that, else if there is feature name in the fallback_ux_language then use that, else use the feature's default name in the local language
return (global.ux_language && feature['name:left:'+global.ux_language]) || (global.ux_language_fallback && feature['name:left:'+global.ux_language_fallback]) || feature['name:left'];
}
ux_language_text_source_right: |
function() {
// if a ux_langauge has been defined use that, else if there is feature name in the fallback_ux_language then use that, else use the feature's default name in the local language
return (global.ux_language && feature['name:right:'+global.ux_language]) || (global.ux_language_fallback && feature['name:right:'+global.ux_language_fallback]) || feature['name:right'];
}
ux_language_text_source_boundary_lines_left_right:
left: global.ux_language_text_source_left
right: global.ux_language_text_source_right
ux_language_text_source_boundary_lines: |
function() {
var right = (global.ux_language && feature['name:right:'+global.ux_language]) || (global.ux_language_fallback && feature['name:right:'+global.ux_language_fallback]) || feature['name:right'];
var left = (global.ux_language && feature['name:left:'+global.ux_language]) || (global.ux_language_fallback && feature['name:left:'+global.ux_language_fallback]) || feature['name:left'];
if( right && left ) {
//if( right.includes(' ') || left.includes(' ') ) {
return left + " - " + right;
//} else {
// return right + '\n' + left;
//}
} else {
return (global.ux_language && feature['name:'+global.ux_language]) || (global.ux_language_fallback && feature['name:'+global.ux_language_fallback]) || feature.name;
}
}
ux_language_text_source_short: |
function() {
return (global.ux_language && feature['name:short:'+global.ux_language]) || (global.ux_language_fallback && feature['name:short:'+global.ux_language_fallback]) || feature['name:short'];
}
ux_language_text_source_short_proxy_name: |
function() {
var name = (global.ux_language && feature['name:'+global.ux_language]) || (global.ux_language_fallback && feature['name:'+global.ux_language_fallback]) || feature['name'] || '';
var short = (global.ux_language && feature['name:short:'+global.ux_language]) || (global.ux_language_fallback && feature['name:short:'+global.ux_language_fallback]) || feature['name:short'];
return short ? name : '';
}
ux_language_text_source_abbreviation: |
function() {
var name = (global.ux_language && feature['name:'+global.ux_language]) || (global.ux_language_fallback && feature['name:'+global.ux_language_fallback]) || feature['name'] || '';
var abbrev = (global.ux_language && feature['name:abbreviation:'+global.ux_language]) || (global.ux_language_fallback && feature['name:abbreviation:'+global.ux_language_fallback]) || feature['name:abbreviation'];
return abbrev || name;
}
ux_language_text_source_iata: |
function() {
var name = (global.ux_language && feature['name:'+global.ux_language]) || (global.ux_language_fallback && feature['name:'+global.ux_language_fallback]) || feature['name'];
if(feature.iata) {
if (name) {
return name + ' (' + feature.iata + ')';
}
else {
return feature.iata;
}
} else {
return name;
}
}
ux_language_text_source_ocean: |
function() {
var name = (global.ux_language && feature['name:'+global.ux_language]) || (global.ux_language_fallback && feature['name:'+global.ux_language_fallback]) || feature['name'] || '';
name = name.split(' ').join('\n');
return name.split('').join(' ');
}
ux_language_text_source_sea: |
function() {
var name = (global.ux_language && feature['name:'+global.ux_language]) || (global.ux_language_fallback && feature['name:'+global.ux_language_fallback]) || feature['name'] || '';
name = name.split(' ').join('\n');
return name.split('').join(' ');
}
ux_language_text_source_continent_stacked_only: |
function() {
var name = (global.ux_language && feature['name:'+global.ux_language]) || (global.ux_language_fallback && feature['name:'+global.ux_language_fallback]) || feature['name'] || '';
return name.split(' ').join('\n');
}
ux_language_text_source_continent: |
function() {
var name = (global.ux_language && feature['name:'+global.ux_language]) || (global.ux_language_fallback && feature['name:'+global.ux_language_fallback]) || feature['name'] || '';
name = name.split(' ').join('\n');
return name.split('').join(' ');
}
ux_language_text_source_road_ref_and_name: |
function() {
// if a ux_langauge has been defined use that, else if there is feature name in the fallback_ux_language then use that, else use the feature's default name in the local language
return (global.ux_language && feature['name:'+global.ux_language]) || (global.ux_language_fallback && feature['name:'+global.ux_language_fallback]) || feature.name;
/*
var name = (global.ux_language && feature['name:'+global.ux_language]) || (global.ux_language_fallback && feature['name:'+global.ux_language_fallback]) || feature['name'];
if(feature.ref && name) {
return (feature.ref + ' ' + name);
} else {
return name;
}
*/
}
ux_language_text_source_road_ref_and_name_short: |
function() {
// if a ux_langauge has been defined use that, else if there is feature name in the fallback_ux_language then use that, else use the feature's default name in the local language
return (global.ux_language && feature['name:'+global.ux_language]) || (global.ux_language_fallback && feature['name:'+global.ux_language_fallback]) || feature.name;
/*
var name = (global.ux_language && feature['name:'+global.ux_language]) || (global.ux_language_fallback && feature['name:'+global.ux_language_fallback]) || feature['name'];
if (feature.ref && (feature.ref.length < 6) && name) {
return feature.ref + ' ' + name;
} else {
return name;
}
*/
}
ux_language_text_source_piste_advanced: |
function() {
var name = (global.ux_language && feature['name:'+global.ux_language]) || (global.ux_language_fallback && feature['name:'+global.ux_language_fallback]) || feature['name'];
return name ? ('◆ ' + name) : '◆';
}
ux_language_text_source_piste_expert: |
function() {
var name = (global.ux_language && feature['name:'+global.ux_language]) || (global.ux_language_fallback && feature['name:'+global.ux_language_fallback]) || feature['name'];
return name ? ('◆◆ ' + name) : '◆◆';
}
ux_language_text_source_building_and_address: |
function() {
var name = (global.ux_language && feature['name:'+global.ux_language]) || (global.ux_language_fallback && feature['name:'+global.ux_language_fallback]) || feature['name'];
if (name && feature.addr_housenumber) {
return name + '\n' + feature.addr_housenumber;
} else {
return name;
}
}
# To facilitate data visualizations several recommended sort orders are provided
#
# Your classic raster map overlay.
# Over all line and polygon features.
# Under map labels (icons and text), under UI elements
# (like routeline and search result pins).
sdk_order_over_everything_but_text_0: 490
sdk_order_over_everything_but_text_1: 491
sdk_order_over_everything_but_text_2: 492
sdk_order_over_everything_but_text_3: 493
sdk_order_over_everything_but_text_4: 494
sdk_order_over_everything_but_text_5: 495
sdk_order_over_everything_but_text_6: 496
sdk_order_over_everything_but_text_7: 497
sdk_order_over_everything_but_text_8: 498
sdk_order_over_everything_but_text_9: 499
#
# Your classic "underlay"
# Under roads. Above borders, water, landuse, and earth.
sdk_order_under_roads_0: 290
sdk_order_under_roads_1: 291
sdk_order_under_roads_2: 292
sdk_order_under_roads_3: 293
sdk_order_under_roads_4: 294
sdk_order_under_roads_5: 295
sdk_order_under_roads_6: 296
sdk_order_under_roads_7: 297
sdk_order_under_roads_8: 298
sdk_order_under_roads_9: 299
#
# Under water.
# Above earth and most landuse.
sdk_order_under_water_0: 190
sdk_order_under_water_1: 191
sdk_order_under_water_2: 192
sdk_order_under_water_3: 193
sdk_order_under_water_4: 194
sdk_order_under_water_5: 195
sdk_order_under_water_6: 196
sdk_order_under_water_7: 197
sdk_order_under_water_8: 198
sdk_order_under_water_9: 199
#
# Under everything.
# Tip: disable earth layer.
sdk_order_under_everything_0: 0
sdk_order_under_everything_1: 1
sdk_order_under_everything_2: 2
sdk_order_under_everything_3: 3
sdk_order_under_everything_4: 4
sdk_order_under_everything_5: 5
sdk_order_under_everything_6: 6
sdk_order_under_everything_7: 7
sdk_order_under_everything_8: 8
sdk_order_under_everything_9: 9
#
# TRANSIT OVERLAY
# should default to "auto", with SDK overriding it to true or false,
# or app logic sets other booleans that triggers auto behavior later
sdk_transit_overlay: false
#
# BATHYMETRY
# Show relief shading under water
# should default to "false", with SDK overriding it to true or false,
sdk_bathymetry: false
#
# COASTLINE
# Show coastline shader
# should default to "true", with SDK overriding it to true or false,
sdk_coastline: true
#
# SHIELDS
sdk_shield_color: black
sdk_shield_text_color: white
#
# enable interactivity for key features
sdk_interactive: true
#
# default order for basemap features
feature_order: function() { return feature.sort_rank; }
feature_order_down_1: function() { return feature.sort_rank - 1; }
#
# areas:
sdk_building_extrude: true # building extrusion toggle
building_extrude_height: | # building extrude height logic
function() { return feature.height || 20; }
# labels:
text_font_family: 'Open Sans' # branding in asperational Unicode, yo (or Helvetica)
textures:
building-grid:
url: images/building-grid.gif
filtering: mipmap
sources:
mapzen:
type: MVT #GeoJSON, MVT, TopoJSON
# prod
url: https://tile.nextzen.org/tilezen/vector/v1/512/all/{z}/{x}/{y}.mvt
# dev
#url: https://dev-tile.nextzen.org/tilezen/vector/v1/512/all/{z}/{x}/{y}.mvt
url_params:
api_key: global.sdk_api_key
tile_size: 512
max_zoom: 15
normals: # normals
type: Raster
# prod
url: https://tile.nextzen.org/tilezen/terrain/v1/512/normal/{z}/{x}/{y}.png
url_params:
api_key: global.sdk_api_key
tile_size: 512
max_zoom: 14
# # Only enable this for local debug, should not be enabled for prod (app inserts these at runtime)
# # These are all in San Francisco, California
# #
# # Current location gem
# mz_current_location:
# type: GeoJSON
# url: https://gist.githubusercontent.com/anonymous/9e9588228b0a604264a2/raw/b28be49bea0b7feb859eb65b588c28e9fee5ae2c/map.geojson
# # Route line
# mz_route_line:
# type: GeoJSON
# # sf to ny
# #url: https://gist.githubusercontent.com/anonymous/30c6c1a75c168d91d90c/raw/92bfe55e622766d250b1f2f5d17bdc7c26acb956/map.geojson
# # local sf trip
# url: https://gist.githubusercontent.com/anonymous/9a610ebda6fe4be7bccc/raw/8d217e43f2412d48d01534ba115f1e42dac72e68/map.geojson
# # Transit route line
# mz_route_line_transit:
# type: GeoJSON
# url: https://gist.githubusercontent.com/anonymous/71ae88cbc6d62c4d141ecd6a61060050/raw/2254bbc18243f5dc609e663a580c9412a7447936/map.geojson
# # Pin at start of route
# mz_route_start:
# type: GeoJSON
# url: https://gist.githubusercontent.com/anonymous/5262969cb7549ea69221/raw/be03f233fa323d9b5cf50ef1d8e89a1faa3750f1/map.geojson
# # Pin at end of route
# mz_route_destination:
# type: GeoJSON
# url: https://gist.githubusercontent.com/anonymous/dbae9635dfe46796490e/raw/df55c318635a7d91b309ed40754d4738a292fd38/map.geojson
# # Arrow for current route location
# mz_route_location:
# type: GeoJSON
# url: https://gist.githubusercontent.com/anonymous/36613092be6e2aa004fd/raw/f753d13069425199e1dea1b449ef67d723f6510e/map.geojson
# # Dots for transit stops in route preview
# mz_route_transit_stop:
# type: GeoJSON
# url: https://gist.githubusercontent.com/anonymous/b9f16bca4a804f50faf71277d52ee4ab/raw/db13e4e765fa1ac8844b8ba02f4a0f66fe772907/map.geojson
# # Pins showing search result locations
# mz_search_result:
# type: GeoJSON
# url: https://gist.githubusercontent.com/anonymous/57dc09eeb120919f76de/raw/43426217da3c2bae0522dc4257aaa61e4df3981e/map.geojson
# # Default point styling (SDK)
# mz_default_point:
# type: GeoJSON
# url: https://gist.githubusercontent.com/anonymous/16324c771edfce45be0721390389b878/raw/7dbaebf17da7da8562e6c6f8768bc8cff83efa88/map.geojson
# # Default shield styling (SDK)
# mz_default_shield:
# type: GeoJSON
# url: https://gist.githubusercontent.com/anonymous/5a789f6bd8b51b5693ba9cd57a767aa1/raw/d4523a6c9deebca125298c31085958262caa1ecd/map.geojson
# # Default line styling (SDK)
# mz_default_line:
# type: GeoJSON
# url: https://gist.githubusercontent.com/anonymous/26f4e8b6b34b2617b5d5533d89decb39/raw/df8e180ab4f7f19448014dccc4a755f7cfa20003/map.geojson
# # Default polygon styling (SDK)
# mz_default_polygon:
# type: GeoJSON
# url: https://gist.githubusercontent.com/anonymous/88235c795bb44b8c45150bdd5561f947/raw/71d4fab97b6513833bf1a589167119e6169ef86d/map.geojson
cameras:
isometric:
type: isometric
styles:
##### LIBRARY OF FUNCTIONS
# SPACE functions
space-tile:
shaders:
blocks:
global: |
// Variant to be add to both vertex and fragments shaders
varying vec3 v_pos;
//
// Get the coordinates in tile space
// ================================
vec2 getTileCoords() {
return fract(v_pos.xy);
}
position: |
// Normalize the attribute position of a vertex
v_pos = modelPosition().xyz;
space-constant:
shaders:
blocks:
global: |
// Get the constant coordinates (glitches on zooms)
// ================================
vec2 getConstantCoords () {
#ifdef TANGRAM_FRAGMENT_SHADER
const float pixel_scale = 695.;
float meter_pixels = u_meters_per_pixel / u_device_pixel_ratio;
vec2 st = gl_FragCoord.xy/pixel_scale;
const float dot_wrap = 1000.;
st += mod(u_map_position.xy / meter_pixels, dot_wrap)/pixel_scale;
return st;
#else
return vec2(0.0,0.0);
#endif
}
# TILING functions
tiling-tile:
shaders:
blocks:
global: |
// Repeats a coordinate space (st) in diferent tiles
// ================================
vec2 tile(vec2 st, float zoom){
st *= zoom;
return fract(st);
}
tiling-brick:
shaders:
blocks:
global: |
// Repeats a coordinate space (st) in diferent brick-like tiles
// ================================
vec2 brick(vec2 st, float zoom){
st *= zoom;
// Here is where the offset is happening
st.x += step(1., mod(st.y, 2.0)) * 0.5;
return fract(st);
}
tiling-mirror:
shaders:
blocks:
global: |
// Mirror the coordinate space
// ================================
vec2 mirror(vec2 _st, vec2 _zoom){
_st *= _zoom;
if (fract(_st.y * 0.5) > 0.5){
_st.x = _st.x + 0.5;
_st.y = 1.0 - _st.y;
}
return fract(_st);
}
# Usefull functions
functions-aastep:
shaders:
extensions: OES_standard_derivatives
blocks:
global: |
// AntiAliased Step function
//=============================
float aastep(float threshold, float value) {
#ifdef TANGRAM_FRAGMENT_SHADER
#ifdef TANGRAM_EXTENSION_OES_standard_derivatives
float afwidth = length(vec2(dFdx(value), dFdy(value))) * 0.70710678118654757;
return smoothstep(threshold-afwidth, threshold+afwidth, value);
#else
return step(threshold, value);
#endif
#else
return step(threshold, value);
#endif
}
# Generative functions
generative-random:
shaders:
blocks:
global: |
// 1D Random for 1 and 2 dimentions
// ================================
float random(float x) { return fract(sin(x)*43758.5453);}
float random(vec2 p) { return fract(1e4 * sin(17.0 * p.x + p.y * 0.1) * (0.1 + abs(sin(p.y * 13.0 + p.x)))); }
float random(vec3 p) { return fract(sin(dot(p.xyz, vec3(70.9898,78.233,32.4355)))* 43758.5453123); }
//
// 2D Random for 2 dimentions
// ================================
vec2 random2 (vec2 xy) { return fract(sin(vec2(dot(xy,vec2(127.1,311.7)),dot(xy,vec2(269.5,183.3))))*43758.5453); }
//
// 3D Random for 2 dimentions
// ================================
vec3 random3 (vec2 xy) { return fract(sin(vec3( dot(xy,vec2(127.1,311.7)), dot(xy,vec2(269.5,183.3)), dot(xy,vec2(419.2,371.9)) ))*43758.5453); }
vec3 random3 (vec3 c) {
float j = 4096.0*sin(dot(c,vec3(17.0, 59.4, 15.0)));
vec3 r;
r.z = fract(512.0*j);
j *= .125;
r.x = fract(512.0*j);
j *= .125;
r.y = fract(512.0*j);
return r-0.5;
}
# Drawing Shapes functions
shapes-circle:
mix: functions-aastep
shaders:
defines:
PI: 3.14159265358979323846
blocks:
global: |
// get distance field of a Circle
// ================================
float circleDF (vec2 st) {
return dot(st,st);
}
//
// Draw a circle in the middle of the ST space
// ================================
float circle (vec2 st, float radius) {
return 1.-aastep(radius, circleDF(st-vec2(0.5))*PI);
}
shapes-rect:
shaders:
blocks:
global: |
// get distance field of a rectangle in the center
// ================================
float rectDF(vec2 st, vec2 size) {
//float aspect = u_resolution.x/u_resolution.y;
st = st*2.-1.;
//st.x *= aspect;
return length(max(abs(st)-size,.0));
}
float rectDF(vec2 st, float size) {
//float aspect = u_resolution.x/u_resolution.y;
st = st*2.-1.;
//st.x *= aspect;
return length(max(abs(st)-size,.0));
}
// Draw a round corners rectangle in the center
// ================================
float rect(vec2 st, vec2 size, float radio) {
radio = max(.000001, radio);
return 1.0-step(radio, rectDF(st, size-radio));
}
float rect(vec2 st, float size, float radio) {
return rect(st,vec2(size),radio);
}
// Draw a rectangle in the center
// ================================
float rect(vec2 st, vec2 size){
size = .25-size*.125;
vec2 uv = step(size,st*(1.0-st));
return (uv.x*uv.y);
}
float rect(vec2 st, float size){
return rect(st,vec2(size));
}
# Patterns compositions functions
patterns-stripes:
mix: functions-aastep
shaders:
defines:
PI: 3.14159265358979323846
blocks:
global: |
// Return a distance function of stripes
float stripesDF (vec2 st) {
return abs(sin(st.y*PI));
}
// Adjustable width stripes
float stripes (vec2 st, float width) {
return aastep(width,stripesDF(st));
}
// Faster optimisation of diagonal stripes
float diagonalStripes (vec2 st) {
vec2 i_st = floor(st);
vec2 f_st = fract(st);
if (mod(i_st.y,2.) - mod(i_st.x,2.) == 0.) {
return 1.0 - aastep(f_st.x,f_st.y);
} else {
return aastep(f_st.x,f_st.y);
}
}
dots-honeycomb:
mix: [space-tile, tiling-brick, shapes-circle]
shaders:
blocks:
global: |
// Interpolated dot patern between zooms attached to tile coords
float TileDots(float scale, float size) {
// Beginning of the transition
vec2 IN = brick(getTileCoords()*scale,2.);
float A = circleDF(vec2(0.5)-IN)*1.8;
//
// If over 18. add an end B to transition with
float d = 0.0;
if (u_map_position.z < 18.) {
vec2 OUT = fract(getTileCoords()*scale*2.);
float B = circleDF(vec2(0.25)-OUT)*5.;
B = min(B, circleDF(vec2(0.75,0.25)-OUT)*5.);
B = min(B, circleDF(vec2(0.5,0.75)-OUT)*5.);
B = min(B, circleDF(vec2(0.,0.75)-OUT)*5.);
B = min(B, circleDF(vec2(1.,0.75)-OUT)*5.);
d = mix(A, B, pow(fract(u_map_position.z),10.));
} else {
d = A;
}
//
// Use the antialias step to make a shape from the DF
return aastep(size,d);;
}
##### ACTUAL STYLES
pixel-pattern-light:
mix: [space-tile, generative-random]
base: polygons
shaders:
uniforms:
u_tint: global.ultralight_color
blocks:
filter: |
vec3 pos = vec3(getTileCoords()*130.0,1.0);
color.rgb = u_tint * vec3(random(abs(floor(pos)))+0.925);
pixel-pattern-bright:
mix: [space-tile, generative-random]
base: polygons
shaders:
uniforms:
u_tint: global.lightest_color
blocks:
filter: |
vec3 pos = vec3(getTileCoords()*180.0,1.0);
color.rgb = vec3(random(abs(floor(pos)))+0.950);
color.rgb *= u_tint;
waves:
base: polygons
mix: [space-constant, patterns-stripes]
shaders:
uniforms:
u_lighter: global.lighter_color
u_lightest: global.lightest_color
blocks:
global: |
float stripes2(vec2 st){
return step(.3,1.0-smoothstep(.5,1.,abs(sin(st.y*3.14159265358))));
}
filter: |
vec2 st = getConstantCoords();
const float wave_width = 30.0;
const float wave_height = .01;
st.y += sin(st.x*wave_width)*wave_height;
// gradient
color.rgb = mix(u_lighter, color.rgb, gl_FragCoord.x / u_resolution.x);
color = mix(color,vec4(u_lightest,1.0),stripes(st*92.,.5))*1.0;
coast:
base: lines
mix: [space-constant]
blend: overlay
shaders:
defines:
OPACITY: 0.8
blocks:
global: |
mat2 rotate2d(float angle){
return mat2(cos(angle),-sin(angle),
sin(angle),cos(angle));
}
float stripes(vec2 st){
st = rotate2d(3.14159265358*-0.25 )*st;
//return step(.9,1.0-smoothstep(.5,1.,abs(sin(st.x*3.14159265358))));
return step(.75,1.0-smoothstep(.75,1.,abs(sin(st.x*3.14159265358)))); // more spaced out stripes?
}
color: |
vec2 st = getConstantCoords();
color = mix(vec4(color.rgb, 0.4), vec4(0.0), stripes(st*130.))*OPACITY; // transparent stripes
riverlines:
base: lines
mix: [space-constant]
blend: opaque
shaders:
uniforms:
u_tint: global.light_color
u_fill: global.white_color
blocks:
global: |
mat2 rotate2d(float angle){
return mat2(cos(angle),-sin(angle),
sin(angle),cos(angle));
}
float stripes(vec2 st){
st = rotate2d(3.14159265358*-0.25 )*st;
return step(.75,1.0-smoothstep(.75,1.,abs(sin(st.x*3.14159265358)))); // more spaced out stripes?
}
color: |
vec2 st = getConstantCoords();
color = mix(vec4(u_tint.rgb, 0.9), vec4(u_fill.rgb, 1.0), stripes(st*130.));
dots:
mix: [space-tile, tiling-tile, shapes-circle]
base: polygons
shaders:
defines:
PATTERN_SCALE: 50.0
DOT_SIZE: .1
COLOR1: vec3(1.00,1.00,1.00)
COLOR2: color.rgb
blocks:
color: |
color.rgb = mix(COLOR1, COLOR2, circle(tile(getTileCoords(),PATTERN_SCALE), DOT_SIZE));
dots-rev-grid:
mix: [space-tile, tiling-tile, shapes-circle]
base: polygons
shaders:
defines:
PATTERN_SCALE: 60.0
DOT_SIZE: .4
COLOR1: vec3(1.00,1.00,1.00)
COLOR2: color.rgb
blocks:
color: |
color.rgb = mix(COLOR2, COLOR1, circle(tile(getTileCoords(),PATTERN_SCALE), DOT_SIZE));
medium-dots:
mix: dots
base: polygons
shaders:
defines:
PATTERN_SCALE: 60.0
DOT_SIZE: .25
COLOR1: vec3(1.00,1.00,1.00)
COLOR2: color.rgb
tiny-dots:
mix: dots
shaders:
defines:
PATTERN_SCALE: 70.0
DOT_SIZE: .125
COLOR1: vec3(1.00,1.00,1.00)
COLOR2: color.rgb
dots-rev:
base: polygons
mix: dots-honeycomb
shaders:
defines:
COLOR1: vec3(1.00,1.00,1.00)
PATTERN_SCALE: 35.0
blocks:
color: |
color.rgb = mix(COLOR1, color.rgb, TileDots(PATTERN_SCALE, 0.31));
horizontal-bars:
base: polygons
mix: [space-constant, shapes-rect]
texcoords: false
shaders:
defines:
COLOR1: vec3(1.0,1.0,1.0)
blocks:
global: |
float bar(in vec2 st, float size){
return rect(st, vec2(size*0.90,size*0.2));
}
filter: |
vec2 pos = getConstantCoords()*50.0;
float pct = clamp(bar(fract(pos),0.5),0.0,1.0);
color.rgb = mix(COLOR1,color.rgb,pct);
horizontal-bars-rev:
base: polygons
mix: [space-constant, shapes-rect]
texcoords: false
shaders:
defines:
COLOR1: vec3(1.0,1.0,1.0)
PATTERN_SCALE: 50.0
blocks:
global: |
float bar(in vec2 st, float size){
return rect(st, vec2(size*1.05,size*0.5));
}
filter: |
vec2 pos = getConstantCoords()*PATTERN_SCALE;
float pct = clamp(bar(fract(pos),0.5),0.0,1.0);
color.rgb = mix(color.rgb,COLOR1,pct);
scale-buildings:
shaders:
blocks:
position: |
// scale buildings based on zoom
float zoom = u_map_position.z;
float min = .1; // minimum building scale
float midpoint = 16.; // middle of zoom range
float inspeed = .1; // number of zooms to scale buildings up
float outspeed = 2.; // number of zooms to scale buildings back down
float e = 0.;
if (zoom >= midpoint) {
e = (zoom - midpoint) / (outspeed * .2);
} else {
e = abs(zoom - midpoint) / inspeed;
}
position.z *= ((1. - min) / (1. + (exp(e)))) + min;
building-grid:
base: polygons
lighting: false
mix: [scale-buildings]
texcoords: true
shaders:
uniforms:
u_tex_grid: building-grid
u_grid_color: global.black_color
defines:
WALL_TINT: vec3(1., 3., .993)
blocks:
color: |
// If it's a wall
color.rgb = mix(mix(color.rgb, u_grid_color.rgb, texture2D(u_tex_grid, v_texcoord).a),
color.rgb,
step(.5,dot(vec3(0., 0., 1.), worldNormal())));
building-lines:
base: lines
mix: scale-buildings
texcoords: true
lines_transparent:
base: lines
blend: overlay
outline_transparent:
base: lines
blend: overlay
polygons_transparent:
base: polygons
blend: overlay
text-blend-order:
base: text
blend_order: 1
ux-lines-overlay:
base: lines
blend: overlay
blend_order: 0
ux-transit-line-overlay:
base: lines
blend: overlay
blend_order: 0
ux-location-gem-overlay:
base: points
texture: mapzen_icon_library
blend: overlay
blend_order: 2
ux-icons-overlay:
base: points
texture: mapzen_icon_library
blend: overlay
blend_order: 3
sdk-point-overlay:
base: points
texture: mapzen_icon_library
blend: overlay
blend_order: 3
sdk-shield-overlay:
base: points
texture: mapzen_icon_library
blend: overlay
blend_order: 3
sdk-line-overlay:
base: lines
blend: overlay
blend_order: 0
sdk-polygon-overlay:
base: polygons
blend: overlay
blend_order: 0
scene:
background:
color: global.white_color
fonts:
Open Sans:
- weight: 300 # Light
url: fonts/OpenSans-Light.woff
- weight: normal # Regular
url: fonts/OpenSans-Regular.woff
- weight: normal # Regular
style: italic
url: fonts/OpenSans-Italic.woff
- weight: 600 # Semi Bold
url: fonts/OpenSans-Semibold.woff
- weight: 600 # Semi Bold
style: italic
url: fonts/OpenSans-SemiboldItalic.woff
- weight: bold
url: fonts/OpenSans-Bold.woff
Montserrat:
- weight: normal
#url: https://fonts.gstatic.com/s/montserrat/v7/zhcz-_WihjSQC0oHJ9TCYL3hpw3pgy2gAi-Ip7WPMi0.woff
url: fonts/Montserrat-Regular.woff
- weight: 500
#url: https://fonts.gstatic.com/s/montserrat/v10/BYPM-GE291ZjIXBWrtCweqLy3K7m9xj_O5xwN3SdQNs.woff
url: fonts/Montserrat-Medium.woff
- weight: 700
#url: https://fonts.gstatic.com/s/montserrat/v10/IQHow_FEYlDC4Gzy_m8fcnbFhgvWbfSbdVg11QabG8w.woff
url: fonts/Montserrat-Bold.woff
layers:
# Map overlays for styling the server response (using special source layer names) for route line, current location, and search result pins
mz_route_line:
data: { source: mz_route_line }
draw:
ux-lines-overlay:
interactive: global.sdk_interactive
color: global.route_line
order: 500
width: [[0,3.5px],[5,5px],[9,7px],[10,6px],[11,6px],[13,8px],[14,9px],[15,10px],[16,11px],[17,12px],[18,10px]]
mz_route_line_transit:
data: { source: mz_route_line_transit }
draw:
ux-transit-line-overlay:
# each transit route segment could be a different "line" each with it's own color
# but some transit lines don't define a color, in those cases default to blue
# and since the color is coming from Transit.land they call it "color" instead of "colour"
interactive: global.sdk_interactive
color: function() { return feature.color || '#06a6d4'; }
order: 500
width: [[0,3.5px],[5,5px],[9,7px],[10,6px],[11,6px],[13,8px],[14,9px],[15,10px],[16,11px],[17,12px],[18,10px]]
mz_current_location_gem:
data: { source: mz_current_location }
draw:
ux-location-gem-overlay:
interactive: global.sdk_interactive
sprite: ux-current-location
size: 36px
collide: false
transition: { show: { time: 0s }, hide: { time: 0s } }
mz_route_location:
data: { source: mz_route_location }
draw:
ux-location-gem-overlay:
interactive: global.sdk_interactive
sprite: ux-route-arrow
size: [60px,60px]
collide: false
transition: { show: { time: 0s }, hide: { time: 0s } }
mz_route_start:
data: { source: mz_route_start }
draw:
ux-icons-overlay:
interactive: global.sdk_interactive
priority: 1
sprite: ux-route-start
size: [36px,46px]
collide: false
anchor: top
transition: { show: { time: 0s }, hide: { time: 0s } }
mz_route_destination:
data: { source: mz_route_destination }
draw:
ux-icons-overlay:
interactive: global.sdk_interactive
priority: 1
sprite: ux-route-stop
size: [36px,46px]
collide: false
anchor: top
transition: { show: { time: 0s }, hide: { time: 0s } }
mz_route_transit_stop:
data: { source: mz_route_transit_stop }
draw:
ux-icons-overlay:
interactive: global.sdk_interactive
sprite: ux-transit-stop
size: [15px,15px]
collide: false
transition: { show: { time: 0s }, hide: { time: 0s } }
mz_search_result:
data: { source: mz_search_result }
draw:
ux-icons-overlay:
interactive: global.sdk_interactive
sprite: ux-search-active
size: [36px,54px]
collide: false
anchor: top
transition: { show: { time: 0s }, hide: { time: 0s } }
inactive:
filter: { state: inactive }
draw:
ux-icons-overlay:
sprite: ux-search-inactive
mz_dropped_pin:
data: { source: mz_dropped_pin }
draw:
ux-icons-overlay:
interactive: global.sdk_interactive
sprite: ux-search-active
size: [36px,54px]
collide: false
anchor: top
transition: { show: { time: 0s }, hide: { time: 0s } }
# Used by the SDK to place point, line, and polygon overlays on the map
mz_default_point:
data: { source: mz_default_point }
draw:
sdk-point-overlay:
interactive: global.sdk_interactive
sprite: ux-search-active
size: [36px,54px]
collide: false
anchor: top
transition: { show: { time: 0s }, hide: { time: 0s } }
mz_default_shield:
data: { source: mz_default_shield }
draw:
sdk-shield-overlay:
interactive: global.sdk_interactive
sprite: |
function() {
if( feature.ref ) {
return ('sdk_shield-' + feature.ref.length + 'char');
} else {
return ('sdk_shield-' + feature.name.length + 'char');
}
}
sprite_default: sdk_shield-1char
color: global.sdk_shield_color