PHP 5.4,549字节
由于需要将箭头定义为图形而有所阻碍,这是我的PHP代码:
<? $i=$argv[1];$p="R0lGODdhBQAFAIAAAP///wAAACwAAAAABQAFAAAC";$a=[$p."BwRiicGsDwoAOw",$p."CEQeoLfmlhQoADs",$p."CARiF8hnmGABADs",$p."CIwDBouYvGIoADs",$p."BwRil8Gs+QoAOw",$p."CIQRYcqrnkABADs",$p."CARihscYn1YBADs",$p."CAx+Bmq6HWIBADs"];$c=[$i&7,$i>>3&7,$i>>6&7,$i>>9];$m=imagecreate(120,120);imagecolorallocate($m,255,255,255);foreach($a as$_)$z[]=imagecreatefromstring(base64_decode($_));for($y=0;$y<8;$y++)for($x=0;$x<8;$x++)imagecopy($m,$z[($c[0]*(7-$x)*(7-$y)+$c[1]*$x*(7-$y)+$c[2]*(7-$x)*$y+$c[3]*$x*$y)/49%8],$x*15+5,$y*15+5,0,0,5,5);imagepng($m);
从命令行获取其参数,例如:
php windmap.php 123
该解决方案将使用输入作为四个角的定义。地图的其余部分将在值之间平滑插值。它定义了从0到4095的所有值的结果,总计〜11.25年的虚假预测,这应该足够时间来修复天气软件!
这是所有结果的GIF:
包含每个地图的ZIP可以在这里下载
(请注意:我的域最近过期,因为我没有引起注意。我已对其进行续订,但是上面的图像和链接在DNS更新之前可能无法工作)
未压缩:
<?php
$input = $argv[1];
$prefix = "R0lGODdhBQAFAIAAAP///wAAACwAAAAABQAFAAAC";
$arrows = [
$prefix."BwRiicGsDwoAOw", // E
$prefix."CEQeoLfmlhQoADs", // NE
$prefix."CARiF8hnmGABADs", // N
$prefix."CIwDBouYvGIoADs", // NW
$prefix."BwRil8Gs+QoAOw", // W
$prefix."CIQRYcqrnkABADs", // SW
$prefix."CARihscYn1YBADs", // S
$prefix."CAx+Bmq6HWIBADs", // SE
];
$points = [
$input & 7,
$input >> 3 & 7,
$input >> 6 & 7,
$input >> 9 // input beyond 0o7777 (4095) will be undefined due to lack of & 7 here
];
$img = imagecreate(120,120);
imagecolorallocate($img,255,255,255);
$arrowimgs = [];
foreach($arrows as $src) {
$arrowimgs[] = imagecreatefromstring(base64_decode($src));
}
for($y=0; $y<8; $y++) {
for($x=0; $x<8; $x++) {
$point = (
$points[0] * (7-$x)/7 * (7-$y)/7
+ $points[1] * $x /7 * (7-$y)/7
+ $points[2] * (7-$x)/7 * $y /7
+ $points[3] * $x /7 * $y /7
) % 8;
imagecopy($img,$arrowimgs[$point],$x*15+5,$y*15+5,0,0,5,5);
}
}
imagepng($img,"out.png");