2018-07-07 13:46:40 +00:00
|
|
|
import 'package:angular/angular.dart';
|
|
|
|
|
2018-07-07 14:44:27 +00:00
|
|
|
import 'dart:html' as html;
|
|
|
|
import 'package:rules_of_living/src/App.dart';
|
|
|
|
|
2018-07-07 13:46:40 +00:00
|
|
|
@Component(
|
|
|
|
selector: 'my-app',
|
2018-07-07 17:05:56 +00:00
|
|
|
templateUrl: "app_component.html",
|
|
|
|
directives: [coreDirectives]
|
2018-07-07 13:46:40 +00:00
|
|
|
)
|
2018-07-07 14:44:27 +00:00
|
|
|
class AppComponent implements OnInit {
|
|
|
|
var name = "World";
|
|
|
|
|
|
|
|
App engine;
|
2018-07-07 15:47:37 +00:00
|
|
|
String buttonRunText = "Start";
|
2018-07-07 14:44:27 +00:00
|
|
|
|
|
|
|
@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);
|
|
|
|
}
|
2018-07-07 15:47:37 +00:00
|
|
|
|
|
|
|
void onStartClicked() {
|
|
|
|
bool isRunning = !engine.running;
|
|
|
|
engine.running = isRunning;
|
2018-07-07 17:05:56 +00:00
|
|
|
}
|
2018-07-07 15:47:37 +00:00
|
|
|
|
|
|
|
switch (isRunning) {
|
|
|
|
case true: buttonRunText = "Stop"; break;
|
|
|
|
case false: buttonRunText = "Start"; break;
|
|
|
|
}
|
2018-07-07 17:05:56 +00:00
|
|
|
void onStepClicked() {
|
|
|
|
}
|
|
|
|
|
|
|
|
void onResetClicked() {
|
2018-07-07 15:47:37 +00:00
|
|
|
}
|
2018-07-07 17:05:56 +00:00
|
|
|
|
|
|
|
void onRandomClicked() {}
|
2018-07-07 13:46:40 +00:00
|
|
|
}
|