摘要
Source code
<syntaxhighlight lang="perl">
!/usr/bin/perl
my @elements = (
sym, pe, g, RGB color, mass, natural radionuclide (0=no, "+"=many, undef=controversial or already stated)
["n", 0, 18, 0, 1, 0 ],
["H", 1, 1, "#FFF", 0, 3 ],
["He", 1, 18, "#FFF", 0, 0 ],
["Li", 2, 1, "#FFF", 0, 0 ],
["Be", 2, 2, "#0F0", 9],
["B", 2, 13, "#FFF", 0, 0 ],
["C", 2, 14, "#FFF", 0, 14 ],
["N", 2, 15, "#FFF", 0, 0 ],
["O", 2, 16, "#FFF", 0, 0 ],
["F", 2, 17, "#0F0", 19],
["Ne", 2, 18, "#FFF", 0, 0 ],
["Na", 3, 1, "#0F0", 23],
["Mg", 3, 2, "#FFF", 0, 0 ],
["Al", 3, 13, "#0F0", 27],
["Si", 3, 14, "#FFF", 0, 0 ],
["P", 3, 15, "#0F0", 31],
["S", 3, 16, "#FFF", 0, 0 ],
["Cl", 3, 17, "#FFF", 0],
["Ar", 3, 18, "#FFF", 0, 0 ],
["K", 4, 1, "#FFF", 0, 40 ],
["Ca", 4, 2, "#FFF", 0, 48, "_" ],
["Sc", 4, 3, "#0F0", 45],
["Ti", 4, 4, "#FFF", 0, 0 ],
["V", 4, 5, "#9FF", 51, 50, "_" ],
["Cr", 4, 6, "#FFF", 0, 0 ],
["Mn", 4, 7, "#0F0", 55],
["Fe", 4, 8, "#FFF", 0, 0 ],
["Co", 4, 9, "#0F0", 59],
["Ni", 4, 10, "#FFF", 0, 0 ],
["Cu", 4, 11, "#FFF", 0, 0 ],
["Zn", 4, 12, "#FFF", 0, 0 ],
["Ga", 4, 13, "#FFF", 0, 0 ],
["Ge", 4, 14, "#FFF", 0, 76, "_" ],
["As", 4, 15, "#0F0", 75],
["Se", 4, 16, "#FFF", 0, 82, "_" ],
["Br", 4, 17, "#FFF", 0, 0 ],
["Kr", 4, 18, "#FFF", 0, 78, "_" ],
["Rb", 5, 1, "#0FF", 85, 87 ],
["Sr", 5, 2, "#FFF", 0, 0 ],
["Y", 5, 3, "#0F0", 89],
["Zr", 5, 4, "#FFF", 0, 96, "_" ],
["Nb", 5, 5, "#0F0", 93],
["Mo", 5, 6, "#FFF", 0, 100, "_" ],
["Tc", 5, 7, "#F0F", 0],
["Ru", 5, 8, "#FFF", 0, 0 ],
["Rh", 5, 9, "#0F0", 103],
["Pd", 5, 10, "#FFF", 0, 0 ],
["Ag", 5, 11, "#FFF", 0, 0 ],
["Cd", 5, 12, "#FFF", 0, "_" ],
["In", 5, 13, "#9FF", 113, 115, "_" ],
["Sn", 5, 14, "#FFF", 0, 0 ],
["Sb", 5, 15, "#FFF", 0, 0 ],
["Te", 5, 16, "#FFF", 0, "+" ],
["I", 5, 17, "#0F0", 127],
["Xe", 5, 18, "#FFF", 0, "+" ],
["Cs", 6, 1, "#0F0", 133],
["Ba", 6, 2, "#FFF", 0, 130, "_" ],
["La", 6, 0, "#0FF", 139, 138],
["Ce", 6, 0, "#FFF", 0, 0 ],
["Pr", 6, 0, "#0F0", 141],
["Nd", 6, 0, "#FFF", 0, "_" ],
["Pm", 6, 0, "#F0F", 0],
["Sm", 6, 0, "#FFF", 0, "+" ],
["Eu", 6, 0, "#9FF", 153, 151, "_" ],
["Gd", 6, 0, "#FFF", 0, 152, "_" ],
["Tb", 6, 0, "#0F0", 159],
["Dy", 6, 0, "#FFF", 0, 0 ],
["Ho", 6, 0, "#0F0", 165],
["Er", 6, 0, "#FFF", 0, 0 ],
["Tm", 6, 0, "#0F0", 169],
["Yb", 6, 0, "#FFF", 0, 0 ],
["Lu", 6, 0, "#0FF", 175, 176 ],
["Hf", 6, 4, "#FFF", 0, 174, "_" ],
["Ta", 6, 5, "#FFF", 0, 0 ],
["W", 6, 6, "#FFF", 0, 180, "_" ],
["Re", 6, 7, "#0FF", 185, 187 ],
["Os", 6, 8, "#FFF", 0, 186, "_" ],
["Ir", 6, 9, "#FFF", 0, 0 ],
["Pt", 6, 10, "#FFF", 0, 190 ],
["Au", 6, 11, "#0F0", 197],
["Hg", 6, 12, "#FFF", 0, 0 ],
["Tl", 6, 13, "#FFF", 0, 0 ],
["Pb", 6, 14, "#FFF", 0, 0 ],
["Bi", 6, 15, "#F60", 209],
["Po", 6, 16, "#F0F", 0],
["At", 6, 17, "#F0F", 0],
["Rn", 6, 18, "#F0F", 0],
["Fr", 7, 1, "#F0F", 0],
["Ra", 7, 2, "#F0F", 0],
["Ac", 7, 0, "#F0F", 0],
["Th", 7, 0, "#F00", 0, "+" ],
["Pa", 7, 0, "#F00", 231],
["U", 7, 0, "#F0F", 0, "+" ],
["Np", 7, 0, "#F0F", 0],
["Pu", 7, 0, "#F0F", 0],
["Am", 7, 0, "#F0F", 0, 0 ],
["Cm", 7, 0, "#F0F", 0, 0 ],
["Bk", 7, 0, "#F0F", 0, 0 ],
["Cf", 7, 0, "#F0F", 0, 0 ],
["Es", 7, 0, "#F0F", 0, 0 ],
["Fm", 7, 0, "#F0F", 0, 0 ],
["Md", 7, 0, "#F0F", 0, 0 ],
["No", 7, 0, "#F0F", 0, 0 ],
["Lr", 7, 0, "#F0F", 0, 0 ],
["Rf", 7, 4, "#F0F", 0, 0 ],
["Db", 7, 5, "#F0F", 0, 0 ],
["Sg", 7, 6, "#F0F", 0, 0 ],
["Bh", 7, 7, "#F0F", 0, 0 ],
["Hs", 7, 8, "#F0F", 0, 0 ],
["Mt", 7, 9, "#F0F", 0, 0 ],
["Ds", 7, 10, "#F0F", 0, 0 ],
["Rg", 7, 11, "#F0F", 0, 0 ],
["Cn", 7, 12, "#F0F", 0, 0 ],
["Nh", 7, 13, "#F0F", 0, 0 ],
["Fl", 7, 14, "#F0F", 0, 0 ],
["Mc", 7, 15, "#F0F", 0, 0 ],
["Lv", 7, 16, "#F0F", 0, 0 ],
["Ts", 7, 17, "#F0F", 0, 0 ],
["Og", 7, 18, "#F0F", 0, 0 ],
);
sub start_box {
my $fill="";
$fill=' style="fill:'.$_[2].'"' if ($_[2]);
print "<g> <rect$fill x=\"".(20*$_[1]-19)."\" width=\"18\" y=\"".($_[0]-19)."\" height=\"18\"/> ";
};
sub make_tria {
my $fill="";
$fill=' style="fill:'.$_[2].'"' if ($_[2]);
print "<polyline$fill points=\""
.(20*$_[1]-19).",".($_[0]-19)." "
.(20*$_[1]-12).",".($_[0]-19)." "
.(20*$_[1]-19).",".($_[0]-14)
."\"/> ";
};
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 (45, $base_y-8, "*", "sym"); print "</g>";
$intro = "* lanthanoids";
};
$base_y = 168;
$group = $_[0] - 54;
}
elsif ( $ref->[1] == 7) { # Actinoid
if ($_[0] == 89) { # Actinium
start_box($base_y, 3); make_text (43, $base_y-8, "**", "sym"); print "</g>";
$intro = "** actinoids";
};
$base_y = 190;
$group = $_[0] - 86;
}
else { return; };
};
if ($intro) {
print "\n";
make_text (($intro=~/^\*/)?3:-5, $base_y-10, $intro) if ($intro);
print "\n";
};
start_box ($base_y, $group, $ref->[3] # background (if defined)
);
if (defined($ref->[5])) {
if ($ref->[5] =~ /^[\+_]/) { # several radionuclides
print '<rect class="rnm"'.(($ref->[5]=~/^_/)?' style="fill:#F96"':)
.' x="'.(20*$group-19).'" width="5" y="'.($base_y-19).'" height="4"/> ';
}
elsif ($ref->[5]) {
make_tria ($base_y, $group,
($ref->[6])?"#F60" #several "radionuclides" are practically stable
:"#F00");
}
else { make_tria ($base_y, $group); }; # no radionuclides (the default style)
};
smart_number (20*$group-11, $base_y-5, $_[0]); # Atomic number
smart_symbol (20*$group-13, $base_y-9, $ref->[0]); # Symbol
smart_number (20*$group-12, $base_y-11, $ref->[4]) if ($ref->[4]); # Mass number
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=\"1098\" height=\"588\" viewBox=\"-5 -6 366 196\"\
xmlns:xlink=\"http://www.w3.org/1999/xlink \">\
<defs>\
<style type=\"text/css\">\
<![CDATA[\
rect {stroke:#666; stroke-width:1px; fill:none} /* for cells */\
text {fill:#000; 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 */\
polyline {stroke:none; fill:#000} /* this default for \"no radionuclides\" */\
.rnm {fill:#7F00FF; stroke:none} /* several radionuclides */\
]]>\
</style>\
</defs>\n\n";
my $group;
make_text ( 8, -1, 1);
make_text (28, 18, 2);
for ( $group=3; $group<=12; $group++) { make_text(20*$group-12, 58, $group); };
for ($group=13; $group<=17; $group++) { make_text(20*$group-14, 18, $group); };
make_text (346, -1, 18);
my $Z;
for ($Z=1; $Z<=118; $Z++) { print_Z ($Z); };
print "</svg>\n";
}}
}}
许可协议
我,本作品著作权人,特此采用以下许可协议发表本作品:
您可以自由地:
共享 – 复制、发行并传播本作品
修改 – 改编作品
惟须遵守下列条件:
署名 – 您必须对作品进行署名,提供授权条款的链接,并说明是否对原始内容进行了更改。您可以用任何合理的方式来署名,但不得以任何方式表明许可人认可您或您的使用。
相同方式共享 – 如果您再混合、转换或者基于本作品进行创作,您必须以与原先许可协议相同或相兼容的许可协议 分发您贡献的作品。 https://creativecommons.org/licenses/by-sa/3.0 CC BY-SA 3.0 Creative Commons Attribution-Share Alike 3.0 true true
已授权您依据自由软件基金会 发行的无固定段落及封面封底文字(Invariant Sections, Front-Cover Texts, and Back-Cover Texts)的GNU自由文件许可协议 1.2版或任意后续版本的条款,复制、传播和/或修改本文件。该协议的副本请见“GNU Free Documentation License ”。http://www.gnu.org/copyleft/fdl.html GFDL GNU Free Documentation License true true
中文(马来西亚) 添加一行文字以描述该文件所表现的内容