2018-08-22 18:16:31 +00:00
|
|
|
import 'dart:html' as html;
|
|
|
|
|
|
|
|
import 'package:angular/angular.dart';
|
2018-10-18 10:51:35 +00:00
|
|
|
import 'package:rules_of_living/service/engine_service.dart';
|
2018-10-18 12:41:57 +00:00
|
|
|
import 'package:rules_of_living/service/simulation_service.dart';
|
2018-08-22 18:16:31 +00:00
|
|
|
|
|
|
|
@Component(
|
|
|
|
selector: 'gol-simulation',
|
|
|
|
templateUrl: "simulation_component.html",
|
|
|
|
directives: [coreDirectives],
|
|
|
|
providers: [],
|
|
|
|
)
|
|
|
|
class SimulationComponent implements OnInit {
|
2018-10-18 10:51:35 +00:00
|
|
|
final EngineService engine;
|
2018-10-18 12:41:57 +00:00
|
|
|
final SimulationService sim;
|
2018-08-22 18:16:31 +00:00
|
|
|
|
2018-10-18 12:41:57 +00:00
|
|
|
SimulationComponent(this.engine, this.sim);
|
2018-08-22 18:16:31 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
void ngOnInit() {
|
|
|
|
html.CanvasElement canvas = html.CanvasElement()..id = "simulation";
|
|
|
|
html.querySelector("#simulation")..append(canvas);
|
|
|
|
canvas.width = 500;
|
2018-08-23 10:38:34 +00:00
|
|
|
canvas.height = 500;
|
2018-08-22 18:16:31 +00:00
|
|
|
|
|
|
|
canvas.context2D.setFillColorRgb(200, 0, 0);
|
|
|
|
canvas.context2D.fillRect(0, 0, canvas.width, canvas.height);
|
|
|
|
canvas.context2D.setFillColorRgb(0, 255, 0);
|
|
|
|
canvas.context2D.fillText('''
|
2018-08-25 12:10:56 +00:00
|
|
|
If you see this
|
|
|
|
|
|
|
|
the canvas did not load correctly :(
|
2018-08-23 10:38:34 +00:00
|
|
|
''', canvas.width / 2 - 50, canvas.height / 2);
|
2018-10-18 12:41:57 +00:00
|
|
|
sim.canvas = canvas;
|
2018-08-22 18:16:31 +00:00
|
|
|
}
|
|
|
|
}
|