sub start_box {
my $fill="";
$fill=' style="fill:'.$_2.'"' if ($_2]);
print "<g> <rect$fill x=\"".(16*$_1-15)."\" width=\"14\" y=\"".($_0-19)."\" height=\"18\"/> ";
};
sub make_text {
my $cl="";
$cl=' class="'.$_3.'"' if ($_3]);
print "<text$cl x=\"".$_0."\" y=\"".$_1."\">".$_2."</text> ";
};
sub smart_symbol {
make_text ($_0], $_1], $_2], (length($_2])>2)?"smallsym":"sym");
};
sub smart_number {
my $x = $_0 - 3;
my $cl = "num";
if ( $_2 >=100 ) { $cl = "smallnum"; $x -= 3; }
elsif ( $_2 >=10 ) { $x -= 3; };
make_text ($x, $_1], $_2], $cl);
};
sub print_Z {
my $ref = $elements$_0]];
return unless $ref;
my $intro;
my $base_y = 20 * $ref->1];
my $group = $ref->2];
if ($group == 1) { # First element in a period
$intro = $ref->1];
}
elsif (!$group) {
if ( $ref->1 == 6) { # Lanthanoid
if ($_0 == 57) { # Lanthanum
start_box($base_y, 3); make_text (37, $base_y-10, "*", "sym"); print "</g>";
$intro = "* lanthanoids";
};
$base_y = 174;
$group = $_0 - 54;
}
elsif ( $ref->1 == 7) { # Actinoid
if ($_0 == 89) { # Actinium
start_box($base_y, 3); make_text (35, $base_y-10, "**", "sym"); print "</g>";
$intro = "** actinoids";
};
$base_y = 194;
$group = $_0 - 86;
}
else { return; };
};
if ($intro) {
print "\n";
make_text (-5, $base_y-4, $intro) if ($intro);
print "\n";
};
my $background = $ref->3];
# this version is not focused on nuclides, recycling some stuff
if ( $background =~ /\#FF00/ ) {
# we classify all unstable elements to nanural, marginally natural and unnatural in this version
if ( $ref->5 eq "0" ) {
$background = '#CC00FF'; # I said: no natural isotopes
}
else {
$background = (($_0 == 90)||($_0 == 92))?'#FF3333' # Th, U
:'#FF33FF'; # marginally natural
};
}
else {
$background =~ s/\#..FF../\#FFFFFF/;
};
start_box ($base_y, $group, $background);
# no check for natural radionuclides in this version
smart_number (16*$group-8, $base_y-5, $_0]); # Atomic number
smart_symbol (16*$group-13, $base_y-11, $ref->0]); # Symbol
# no mass numbers in this version
print "</g>\n"; # end box
};
print "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\
<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\
<svg xmlns=\"http://www.w3.org/2000/svg\" xml:space=\"preserve\" width=\"1176\" height=\"800\" viewBox=\"-5 -6 294 200\"\
xmlns:xlink=\"http://www.w3.org/1999/xlink\">\
<!-- see http://commons.wikimedia.org/wiki/File:Periodic_table,_good_SVG.svg for more information about the file -->
<defs>\
<style type=\"text/css\">\
<![CDATA[\
rect {stroke:#666666; stroke-width:1px; fill:none} /* for cells */\
text {fill:#000000; font-family:sans; font-size:5px; stroke:none} /* periods and groups */\
.sym {font-family:serif; font-size:7px}\
.smallsym {font-family:serif; font-size:5.5px} /* Uu? */\
.num {font-size:4px} /* up to 99 */\
.smallnum {font-size:3px} /* 100 and greater */\
]]>\
</style>\
</defs>\n\n";
my $group;
make_text ( 6, -1, 1);
make_text (22, 18, 2);
for ( $group=3; $group<=12; $group++) { make_text(16*$group-10, 58, $group); };
for ($group=13; $group<=17; $group++) { make_text(16*$group-12, 18, $group); };
make_text (276, -1, 18);
my $Z;
for ($Z=1; $Z<=119; $Z++) { print_Z ($Z); };
print "</svg>\n";