#!/usr/bin/perl

#
#  Draw NIMBI board for icon
#

$width = 39*4;
$height = 39*4;
$dx = $width/4.0;
$dy = $dx*sqrt(3.0)/2.0;
$centerx = $width/2.0;
$centery = $height/2.0;
$rowx = $centerx-$dx*0.5;
$rowy = $centery-$dy*1.5;
$lradius = $dx*0.2;
use GD::Simple;

# row 1
$x=$rowx;
$y=$rowy;
$coord->{28}->{"x"} = $x; $coord->{28}->{"y"} = $y; $x+=$dx;
$coord->{29}->{"x"} = $x; $coord->{29}->{"y"} = $y; $x+=$dx;

# row 2
$x=$rowx-0.5*$dx;
$y=$rowy+$dy;
$coord->{39}->{"x"} = $x; $coord->{39}->{"y"} = $y; $x+=$dx;
$coord->{30}->{"x"} = $x; $coord->{30}->{"y"} = $y; $x+=$dx;
$coord->{35}->{"x"} = $x; $coord->{35}->{"y"} = $y; $x+=$dx;

# row 3
$x=$rowx-$dx;
$y=$rowy+2*$dy;
$coord->{33}->{"x"} = $x; $coord->{33}->{"y"} = $y; $x+=$dx;
$coord->{34}->{"x"} = $x; $coord->{34}->{"y"} = $y; $x+=$dx;
$coord->{38}->{"x"} = $x; $coord->{38}->{"y"} = $y; $x+=$dx;
$coord->{36}->{"x"} = $x; $coord->{36}->{"y"} = $y; $x+=$dx;

# row 4
$x=$rowx-0.5*$dx;
$y=$rowy+3*$dy;
$coord->{32}->{"x"} = $x; $coord->{32}->{"y"} = $y; $x+=$dx;
$coord->{31}->{"x"} = $x; $coord->{31}->{"y"} = $y; $x+=$dx;
$coord->{37}->{"x"} = $x; $coord->{37}->{"y"} = $y; $x+=$dx;

$img = GD::Simple->new($width, $height);

#  white background

$img->bgcolor('white');
$img->fgcolor('white');
$img->rectangle(0,0,$width-1,$height-1);

$img->fgcolor('black');

$img->moveTo($coord->{28}->{"x"}, $coord->{28}->{"y"});
$img->lineTo($coord->{29}->{"x"}, $coord->{29}->{"y"});

$img->moveTo($coord->{39}->{"x"}, $coord->{39}->{"y"});
$img->lineTo($coord->{35}->{"x"}, $coord->{35}->{"y"});

$img->moveTo($coord->{33}->{"x"}, $coord->{33}->{"y"});
$img->lineTo($coord->{36}->{"x"}, $coord->{36}->{"y"});

$img->moveTo($coord->{32}->{"x"}, $coord->{32}->{"y"});
$img->lineTo($coord->{37}->{"x"}, $coord->{37}->{"y"});

$img->moveTo($coord->{32}->{"x"}, $coord->{32}->{"y"});
$img->lineTo($coord->{33}->{"x"}, $coord->{33}->{"y"});

$img->moveTo($coord->{31}->{"x"}, $coord->{31}->{"y"});
$img->lineTo($coord->{39}->{"x"}, $coord->{39}->{"y"});

$img->moveTo($coord->{37}->{"x"}, $coord->{37}->{"y"});
$img->lineTo($coord->{28}->{"x"}, $coord->{28}->{"y"});

$img->moveTo($coord->{36}->{"x"}, $coord->{36}->{"y"});
$img->lineTo($coord->{29}->{"x"}, $coord->{29}->{"y"});

$img->moveTo($coord->{36}->{"x"}, $coord->{36}->{"y"});
$img->lineTo($coord->{37}->{"x"}, $coord->{37}->{"y"});

$img->moveTo($coord->{35}->{"x"}, $coord->{35}->{"y"});
$img->lineTo($coord->{31}->{"x"}, $coord->{31}->{"y"});

$img->moveTo($coord->{29}->{"x"}, $coord->{29}->{"y"});
$img->lineTo($coord->{32}->{"x"}, $coord->{32}->{"y"});

$img->moveTo($coord->{28}->{"x"}, $coord->{28}->{"y"});
$img->lineTo($coord->{33}->{"x"}, $coord->{33}->{"y"});

for($i=28;$i<=39;$i++)
{
  $img->moveTo($coord->{$i}->{"x"}, $coord->{$i}->{"y"});
  $img->bgcolor('black');
  $img->fgcolor('black');
  $img->ellipse($lradius,$lradius);
}

print $img->png;

