cellular_automata_web 1.0.1

  • README.md
  • Example
  • Installing
  • Versions
  • new54


Pub Package Version Latest Dartdocs

Library containing various web renderers for the cellular_automata Dart package.

Web demos

Play with the hosted demos here. Source code is in the demos/ folder.


  • CanvasRenderer : HTML Canvas renderer, this is the recommended renderer for web.
  • StageXLRenderer : WebGL renderer although in this context not quite as performant as Canvas.
  • HtmlTableRenderer : A HTML table using table cells & css (just for fun!)

Build config

For best perfomance ensure that you set --omit-implicit-checks and --trust-primitives as dart2js arguments in your build config. See the demo release config for an example of this.



  • New renderer: HtmlTableRenderer (just for fun!)
  • Initial import. This repository contains the various web renderers that previously were included in the main cellular_automata package.


// Copyright (c) 2017, jimmyff. All rights reserved. Use of this source code
// is governed by a BSD-style license that can be found in the LICENSE file.

import 'dart:html';
import 'package:cellular_automata/cellular_automata.dart';
import 'package:cellular_automata/rules.dart';

import 'package:cellular_automata_web/renderer_canvas.dart';

// Simple example of using cellular_automata with a web canvas renderer
// Include a canvas element in your html: <canvas id="canvas"></canvas>
void main() {
  final palette = new Map<GameOfLifeStates, String>.from({
    GameOfLifeStates.dead: '#000',
    GameOfLifeStates.deadUnderPopulated: '#483D8B',
    GameOfLifeStates.deadOverPopulated: '#00008B',
    GameOfLifeStates.alive: '#FF69B4',
    GameOfLifeStates.aliveBorn: '#FFC0CB',
  const width = 64;
  const height = 64;

  final scene = new Scene<String>(width: width, height: height, fpsTarget: 15);

  // create the Cnvas renderer that will paint our scene
  final renderer = new CanvasRenderer(width: width, height: height)
        canvas: querySelector('#canvas'),
        canvasWidth: 512,
        canvasHeight: 512,
        paintFullSize: true);

    ..onPrepare.listen((int count) {
      // setup the scene
            automaton: new Automaton<GameOfLifeStates, String>(
          width: width,
          height: height,
          palette: palette,
          defaultState: GameOfLifeStates.dead,
          wrap: true,
          rules: new GameOfLife(),
        )..applyGenerator(new MathematicalGenerator<GameOfLifeStates>(
                type: MathematicalGenerators.random,
                valueTrue: GameOfLifeStates.alive,
                valueFalse: GameOfLifeStates.dead)));
    ..onComplete.listen((SceneCompleteReason s) {
      // restart the scene when complete

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  cellular_automata_web: ^1.0.1

2. Install it

You can install packages from the command line:

with pub:

$ pub get

Alternatively, your editor might support pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:cellular_automata_web/renderer_canvas.dart';
import 'package:cellular_automata_web/renderer_html_table.dart';
import 'package:cellular_automata_web/renderer_stagexl.dart';
Version Uploaded Documentation Archive
1.0.1 Jul 27, 2018 Go to the documentation of cellular_automata_web 1.0.1 Download cellular_automata_web 1.0.1 archive
1.0.0 Jul 27, 2018 Go to the documentation of cellular_automata_web 1.0.0 Download cellular_automata_web 1.0.0 archive
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Aug 17, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0
  • pana: 0.11.8


Detected platforms: web

Platform components identified in package: html.


The description is too short.

Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.61.0 <3.0.0
cellular_automata ^1.0.0 1.0.2
logging ^0.11.3+1 0.11.3+2
stagexl ^1.2.0+3 1.4.0+1
Transitive dependencies
collection 1.14.11
petitparser 2.0.0
xml 3.2.0
Dev dependencies
test ^1.3.0