File:CA rule110s.png
From Vigyanwiki
CA rule110s.png
Size of this preview: 600 × 600 pixels. Other resolutions: 240 × 240 pixels | 480 × 480 pixels | 768 × 768 pixels | 1,024 × 1,024 pixels | 2,048 × 2,048 pixels | 10,000 × 10,000 pixels.
Original file (10,000 × 10,000 pixels, file size: 167 KB, MIME type: image/png)
This file is from Wikimedia Commons and may be used by other projects. The description on its file description page there is shown below.
Summary
| DescriptionCA rule110s.png | See below. |
| Date | |
| Source | Own work by the original uploader |
| Author | Grondilu (talk) (Uploads) |
| Other versions |
Made with the following Perl code: use strict;
use warnings;
use GD;
package Automaton {
sub new {
my $class = shift;
my $rule = [ reverse split //, sprintf "%08b", shift ];
return bless { rule => $rule, cells => [ @_ ] }, $class;
}
sub next {
my $this = shift;
my @previous = @{$this->{cells}};
$this->{cells} = [
@{$this->{rule}}[
map {
4 * $previous[($_ - 1) % @previous]
+ 2 * $previous[$_]
+ $previous[($_ + 1) % @previous]
} 0 .. @previous - 1
]
];
return $this;
}
use overload
q{""} => sub {
my $this = shift;
join '', map { $_ ? '#' : ' ' } @{$this->{cells}}
};
sub to_image {
my ($this, $width, $height) = @_;
my $image = GD::Image->new($width, $height);
my $black = $image->colorAllocate(0, 0, 0);
my $white = $image->colorAllocate(255, 255, 255);
my $x = 0;
my $y = 0;
foreach my $cell (@{$this->{cells}}) {
if ($cell) {
$image->setPixel($x, $y, $black);
} else {
$image->setPixel($x, $y, $white);
}
$x++;
if ($x >= $width) {
$x = 0;
$y++;
last if $y >= $height;
}
}
return $image;
}
}
my ($width, $height) = (10**4, 10**4);
my @a = map 0, 1 .. $width;
$a[$width - 1] = 1;
my $a = Automaton->new(110, @a);
# Save to file
open(my $out, '>', 'output.png') or die "Cannot open file: $!";
binmode $out;
print $out "P1\n$width $height\n";
for (1 .. $height) {
print $out join(' ', @{$a->{cells}}) . "\n";
$a->next;
}
close $out; |
Licensing
Grondilu at English Wikipedia, the copyright holder of this work, hereby publishes it under the following licence:
| This file is made available under the Creative Commons CC0 1.0 Universal Public Domain Dedication. | |
| The person who associated a work with this deed has dedicated the work to the public domain by waiving all of their rights to the work worldwide under copyright law, including all related and neighbouring rights, to the extent allowed by law. You can copy, modify, distribute and perform the work, even for commercial purposes, all without asking permission.
http://creativecommons.org/publicdomain/zero/1.0/deed.enCC0Creative Commons Zero, Public Domain Dedicationfalsefalse |
Original upload log
The original description page was here. All following user names refer to en.wikipedia.
- 2014-02-28 08:32 Grondilu 1000×1000× (10463 bytes) Made it myself with the following Perl code: <code>use strict; use warnings; package Automaton { sub new { my $class = shift; my $rule = [ reverse split //, sprintf "%08b", shift ]; return bless { rule => $rule, cells => [ @_ ] }, $class;...
Captions
Add a one-line explanation of what this file represents
Эволюция одного «живого» пикселя (в верхней строке) за 10000 итераций (в нижней строке) по Правилу 110
Items portrayed in this file
depicts
28 February 2014
image/png
9b1b62f5bf9ee9a880d31358b7337a51c56c12d9
170,613 byte
10,000 pixel
10,000 pixel
File history
Click on a date/time to view the file as it appeared at that time.
| Date/Time | Thumbnail | Dimensions | User | Comment | |
|---|---|---|---|---|---|
| current | 22:44, 4 August 2023 | 10,000 × 10,000 (167 KB) | wikimediacommons>Obscure2020 | Optimized with OxiPNG and ZopfliPNG. |
File usage
The following 2 pages use this file:
Retrieved from ‘https://www.vigyanwiki.in/wiki/File:CA_rule110s.png’