cellular-automata/lib/service/simulation_service.dart

36 lines
776 B
Dart

import 'dart:html' as html;
import 'dart:math';
import 'package:rules_of_living/service/engine_service.dart';
class SimulationService {
final EngineService _engine;
SimulationService(this._engine);
void reset() {
_engine.reset();
}
void addRandomPattern() {
_engine.addRandomPattern();
}
void clear() {
_engine.clear();
}
void set gridSize(Point<int> size) {
_engine.engine.gridSize = size;
}
Point<int> get gridSize => _engine.engine.gridSize;
//TODO split into RenderService when rendering is decoupled from engine.
html.CanvasElement get canvas => _engine.engine.canvas;
void set canvas(html.CanvasElement canvas) => _engine.engine.canvas = canvas;
void toggleGrid() {
_engine.engine.toggleEdgeRendering();
}
}