box_pattern.pl 524 B

12345678910111213141516171819202122232425262728
  1. #!/usr/bin/perl
  2. # Daniel "Trizen" Șuteu
  3. # License: GPLv3
  4. # Date: 24 May 2017
  5. # https://github.com/trizen
  6. # Generates an interesting pattern.
  7. use 5.010;
  8. use strict;
  9. use warnings;
  10. use Imager;
  11. my $size = 1000;
  12. my $img = Imager->new(xsize => $size, ysize => $size);
  13. foreach my $x (1 .. $size) {
  14. foreach my $y (1 .. $size) {
  15. if (($x * $y) % (int(sqrt($x)) + int(sqrt($y))) == 0) {
  16. $img->setpixel(x => $x - 1, y => $y - 1, color => 'red');
  17. }
  18. }
  19. }
  20. $img->write(file => 'box_pattern.png');