cellular-automata/lib/app_component.dart
2018-07-07 19:08:49 +02:00

47 lines
899 B
Dart

import 'package:angular/angular.dart';
import 'dart:html' as html;
import 'package:rules_of_living/src/App.dart';
@Component(
selector: 'my-app',
templateUrl: "app_component.html",
directives: [coreDirectives]
)
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);
}
void onStartClicked() {
engine.running = !engine.running;
}
void onStepClicked() {
engine.running = false;
engine.update();
}
void onResetClicked() {
engine.reset();
}
void onRandomClicked() {}
}