File:CA rule110s.png

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search

Original file(10,000 × 10,000 pixels, file size: 167 KB, MIME type: image/png)

Captions

Captions

Add a one-line explanation of what this file represents

Summary

[edit]
Description 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

[edit]
Grondilu at English Wikipedia, the copyright holder of this work, hereby publishes it under the following license:
Creative Commons CC-Zero 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 neighboring rights, to the extent allowed by law. You can copy, modify, distribute and perform the work, even for commercial purposes, all without asking permission.

Original upload log

[edit]
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;...

File history

Click on a date/time to view the file as it appeared at that time.

Date/TimeThumbnailDimensionsUserComment
current17:14, 4 August 2023Thumbnail for version as of 17:14, 4 August 202310,000 × 10,000 (167 KB)Obscure2020 (talk | contribs)Optimized with OxiPNG and ZopfliPNG.
21:19, 10 July 2023Thumbnail for version as of 21:19, 10 July 202310,000 × 10,000 (1.75 MB)CJKVR (talk | contribs)Showing more executions
20:41, 27 February 2014Thumbnail for version as of 20:41, 27 February 20141,000 × 1,000 (10 KB)Grondilu (talk | contribs)Bigger version, right aligned.
17:55, 18 March 2006Thumbnail for version as of 17:55, 18 March 2006500 × 250 (2 KB)Maksim (talk | contribs)La bildo estas kopiita de wikipedia:en. La originala priskribo estas: Smaller version of CA_rule110.png {{GFDL}} {| border="1" ! date/time || username || edit summary |---- | 21:57, 1 February 2005 || en:User:Quadell || <nowiki>(tagged)</nowiki> |

There are no pages that use this file.

File usage on other wikis

The following other wikis use this file: