Perlでコッホ曲線を描く(後編)

前回の続きで、一部パラメータを変えて描いてみる。

これは、ハイテク都市っぽくて気に入ってます。

20150417-2

use v5.14;
use strict;
use warnings;

use Imager;

use constant N => 9;
use constant WIDTH => 1200;
use constant HEIGHT => 1200;

my $rect_w = 512;
my $margin = (WIDTH - $rect_w) / 2;
my ( $x0, $y0 ) = ( $margin, HEIGHT - $margin );

my @gen = (
    # [ 0.0, 0.0 ] は不要
    [ 0.0, 0.5 ],
    [ 0.5, 0.5 ],
    [ 0.5, 0.0 ],
    [ 1.0, 0.0 ]
);

my $points = [
    [ 0, 0 ],
    [ $rect_w, 0 ],
    [ $rect_w, $rect_w ],
    [ 0, $rect_w ],
    [ 0, 0 ]
];

# ここ以降は同じ

 

これは、クロワッサンっぽいって言われてました。

20150417-3

use v5.14;
use strict;
use warnings;

use Imager;

use constant N => 19;
use constant WIDTH => 1200;
use constant HEIGHT => 1200;

my $margin = 310;
my ( $x0, $y0 ) = ( $margin, HEIGHT - $margin );

my @gen = (
    # [ 0.0, 0.0 ] は不要
    [ 1/3, 0.5 ],
    [ 1.0, 0 ]
);

my $points = [
    [ 0, 80 ],
    [ 450, 80 ]
];

# ここ以降は同じ

おしまい。

Leave a Comment