43 lines
998 B
Dart
43 lines
998 B
Dart
import 'package:angular/angular.dart';
|
|
|
|
import 'dart:html' as html;
|
|
import 'package:rules_of_living/src/App.dart';
|
|
|
|
@Component(
|
|
selector: 'my-app',
|
|
template: '''
|
|
<h1>Cellular Automata - The Rules of Life</h1>
|
|
<div id="output">
|
|
<canvas #caCanvas width="500" height="500"></canvas>
|
|
</div>
|
|
<div id="controls">
|
|
<button id="run">Run</button>
|
|
<button id="step">Step</button>
|
|
<button id="reset">Reset</button>
|
|
<button id="random">Random</button>
|
|
<input id="speed" title="Speed" value="1">
|
|
</div>
|
|
''',
|
|
)
|
|
class AppComponent implements OnInit {
|
|
var name = "World";
|
|
|
|
App engine;
|
|
|
|
@ViewChild("caCanvas")
|
|
html.CanvasElement canvas;
|
|
|
|
@override
|
|
void ngOnInit() {
|
|
canvas.context2D.setFillColorRgb(255, 0, 0);
|
|
canvas.context2D.fillRect(0, 0, 200, 150);
|
|
engine = new App(canvas);
|
|
html.window.animationFrame.then(animFrame);
|
|
}
|
|
|
|
void animFrame(num now) {
|
|
engine.process(now);
|
|
html.window.animationFrame.then(animFrame);
|
|
}
|
|
}
|