cellular_automata_web 1.0.1

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 46

cellular_automata_web

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.

Renderers

  • 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.

Changelog

1.0

  • 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.

example/example.dart

// 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)
    ..initCanvas(
        canvas: querySelector('#canvas'),
        canvasWidth: 512,
        canvasHeight: 512,
        paintFullSize: true);

  scene
    ..onPrepare.listen((int count) {
      // setup the scene
      scene
        ..clearAutomata()
        ..addAutomaton(
            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)));
    })
    ..onPaint.listen(renderer.render)
    ..onComplete.listen((SceneCompleteReason s) {
      // restart the scene when complete
      scene
        ..stop()
        ..start();
    })
    ..start();
}

Use this package as a library

1. Depend on it

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


dependencies:
  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
Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
80
Overall:
Weighted score of the above. [more]
46
Learn more about scoring.

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

  • Dart: 2.0.0
  • pana: 0.12.4

Platforms

Detected platforms: web

Platform components identified in package: html.

Maintenance suggestions

The description is too short. (-20 points)

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

Dependencies

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.2
xml 3.2.3
Dev dependencies
test ^1.3.0