#!/ASPerl/bin/perl use strict; use Math::Complex; use Math::Polynomial::Solve qw(poly_roots); use Data::Dumper; $Data::Dumper::Terse = 1; $Data::Dumper::Indent = 0; my $roots = compute (3, 3); #print Dumper ($roots), "\n"; saveimage ({'width' => 640, 'height' => 480, 'fname' => 'foo.png', 'pdata' => $roots, 'color' => [255, 255, 255] }); sub enumer { my $args = shift; my $nbound = shift; sub compute { my $nbound = shift; my $rbound = shift; my $polys = []; my $indl = []; for my $a (-3..3) { for my $b (-3..3) { for my $c (-3..3) { push (@{$polys}, [$a, $b, $c]); } } } my $roots = []; foreach my $poly (@{$polys}) { #print Dumper ($poly), "\n"; foreach my $iroot (poly_roots (@{$poly})) { push (@{$roots}, [(0 + Re($iroot)) / 3, (0 + Im($iroot)) / 3]); } # print Dumper ($poly), "\t", Dumper ($roots), "\n"; } return $roots; } # package App; # use Wx qw (:everything); # use base 'Wx::App'; # use Data::Dumper; # sub OnInit { # my $self = shift; # return 1; # } sub saveimage { my $args = shift; use Wx qw(:everything); Wx::InitAllImageHandlers(); my $bmp = new Wx::Bitmap ($args->{"width"}, $args->{"height"}, 24); my $dc = new Wx::MemoryDC (); $dc->SelectObject ($bmp); $dc->BeginDrawing (); my $pen = $dc->GetPen (); foreach my $pdata (@{$args->{"pdata"}}) { $pen->SetColour ($args->{"color"}->[0], $args->{"color"}->[1], $args->{"color"}->[2]); $dc->SetPen ($pen); my $rx = (($pdata->[0] + 1) / 2) * $args->{"width"}; my $ry = (($pdata->[1] + 1) / 2) * $args->{"height"}; next if ($rx > $args->{"width"}); next if ($ry > $args->{"height"}); next if ($rx < 0); next if ($ry < 0); $dc->DrawPoint ($rx, $ry); print "$rx $ry \n"; } $dc->EndDrawing (); $bmp->SaveFile ($args->{"fname"}, wxBITMAP_TYPE_PNG); }