/* * Verrückte Turing-Maschinen — A turing complete game * Copyright (C) 2016 Christian Fraß * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ module mod_vtm { export module mod_manifestation { export module mod_svg { export module mod_token { /** * @author kcf */ export type type_token = { model : mod_vtm.mod_model.mod_token.type_token; } ; /** * @author kcf */ function create ( model : mod_vtm.mod_model.mod_token.type_token ) : type_token { return { "model": model, }; } /** * @author kcf */ export function create_manifestation ( model : mod_vtm.mod_model.mod_token.type_token ) : type_manifestation { return { "kind": "svg_token", "data": create(model), }; } /** * @author kcf */ function view ( token_ : type_token ) : lib_xml.type_node { let token : mod_vtm.mod_model.mod_token.type_token = token_.model; let children_token : Array = []; // Stein { let node_stein : lib_xml.type_node = ( lib_xml.create_normal ( "circle", { "cx": (0.0).toFixed(float_precision), "cy": (0.0).toFixed(float_precision), "r": (0.125).toFixed(float_precision), "class": "stein", } ) ); children_token.push(node_stein); } // Band { let tape : Array = mod_vtm.mod_model.mod_token.tape_read(token); let children_tape : Array = []; tape.forEach ( (symbol, index) => { let r : float = 0.06125; let x : float = (+0.1+(2*r*1.25)*index); let y : float = (-0.1); let node_eintrag : lib_xml.type_node = ( lib_xml.create_normal ( "circle", { "cx": x.toFixed(float_precision), "cy": y.toFixed(float_precision), "r": r.toFixed(float_precision), /* "x": (x-r).toFixed(float_precision), "y": (y-r).toFixed(float_precision), "width": (2*r).toFixed(float_precision), "height": (2*r).toFixed(float_precision), */ "class": ( [ "eintrag", "symbol_" + symbol.toFixed(0), ].join(" ") ), } ) ); children_tape.push(node_eintrag); } ) ; let node_tape = ( lib_xml.create_normal ( "g", { "class": "tape", }, children_tape ) ); children_token.push(node_tape); } let position : mod_position.type_position = mod_position.von_spot(mod_vtm.mod_model.mod_token.spot_read(token)); let node_token = ( lib_xml.create_normal ( "g", { "class": "token", "transform": translation(position.x, position.y), }, children_token ) ); return node_token; } /** * @author kcf */ function bind(token : type_token) : void { } /** * @author kcf */ lib_trait.attend> ( trait_manifestation, "svg_token", { "view": (manifestation) => view(manifestation.data), "bind": (manifestation) => bind(manifestation.data), } ) ; } } } }