File:BlankMap-World-striped.svg
Summary
| Description |
English: Blank world map in Robinson projection from http://commons.wikimedia.org/wiki/File:BlankMap-World.svg adapted to allow countries to be shaded in stripes as per http://en.wikipedia.org/w/index.php?title=Wikipedia:Graphics_Lab/Map_workshop&diff=prev&oldid=1299817938 |
|
| Date | ||
| Source |
Own work, |
|
| Author | cmglee, Canuckguy and many others |
Python source code
#!/usr/bin/env python
import re, os
path_prefix = os.path.splitext(__file__)[0]
path_in = '%s.svg' % (path_prefix[:path_prefix.rindex('-')])
path_out = '%s.svg' % (path_prefix)
with open(path_in) as f_in: ins = f_in.readlines()
format_use = ' <use href="#%s" class="%s%s"/>'
(outs, use1s, use2s) = ([], [], [])
for row in ins:
match = re.search(r'(?<=id=")[^\'"]{2}(?=")', row)
if match:
id = match.group(0)
use1s.append(format_use % (id, id, 1))
use2s.append(format_use % (id, id, 2))
if 'r="6"' in row:
attributes = [ re.search(r'(?<=%s=")[^\'"]+' % (attribute), row).group(0)
for attribute in 'id,class,cx,cy'.split(',') ]
id = attributes[0][:2]
row = '''\
<g id="%s" class="%s" transform="translate(%s,%s)">
<use href="#spot1" class="%s1"/>
<use href="#spot2" class="%s2"/>
</g>
''' % tuple(attributes + [id, id])
if '</svg>' in row:
row = '''
<path id="spot1" d="M 5,-5 A 7,7 0 0 0 -5,5" transform="scale(0.857)"/>
<use id="spot2" href="#spot1" transform="scale(-1)"/>
<pattern id="pattern" patternUnits="userSpaceOnUse" width="20" height="20">
<path id="pattern" d="M -30,0 l 30,30 h 20 l -40,-40 h 20 l 30,30" fill="none" stroke="#fff" stroke-width="7"/>
</pattern>
<mask id="mask">
<rect width="2754" height="1398" fill="url(#pattern)"/>
</mask>
</defs>
%s
<g mask="url(#mask)">
%s
</g>
%s
''' % ('\n'.join(use1s), '\n'.join(use2s), row)
if '#c0c0c0' in row: row = ''
if '</style>' in row: row = '''
svg { fill:#c0c0c0; }
.circlexx { opacity:1; }
/* Solid */
.cl { fill:#0c0; }
.st { fill:#f00; }
/* Striped */
.aq1 { fill:#ff0; } .aq2 { fill:#fc0; }
.bm1 { fill:#00f; } .bm2 { fill:#9cf; }
.cu1 { fill:#c00; } .cu2 { fill:#960; }
.it1 { fill:#09f; } .it2 { fill:#6cf; }
.jp1 { fill:#f0f; } .jp2 { fill:#f6f; }
.nz1 { fill:#000; } .nz2 { fill:#666; }
%s<defs>''' % (row)
outs.append(re.sub(r'^ +', lambda m:'\t' * len(m.group(0)), row, flags=re.M))
with open(path_out, 'wb') as f_out: f_out.writelines(outs)
Licensing
I, the copyright holder of this work, hereby publish it under the following license:
This file is licensed under the Creative Commons Attribution-Share Alike 4.0 International license.
- You are free:
- to share – to copy, distribute and transmit the work
- to remix – to adapt the work
- Under the following conditions:
- attribution – You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
- share alike – If you remix, transform, or build upon the material, you must distribute your contributions under the same or compatible license as the original.
