/* * Verrückte Turing-Maschinen — A turing complete game * Copyright (C) 2016-2018 kcf * * 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 . */ namespace mod_vtm { export namespace mod_manifestation { export namespace mod_svg { export namespace 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_extended ( 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 { const node_stone : lib_xml.type_node = ( lib_svg.isogon ( 6, 0.1, { "position": lib_vector.cartesian(0, 0), "tilt": (1/4 + 1/12), "classes": ["stone"], } ) ); children_token.push(node_stone); } // Band { let tape : Array = mod_vtm.mod_model.mod_token.tape_read(token); let children_tape : Array = []; tape.forEach ( (symbol, index) => { const r : float = 0.0800; const x : float = (+0.1+(2*r*1.25)*index); const y : float = (-0.1); const node_entry : lib_xml.type_node = ( lib_svg.group ( { "transform": ( [ lib_svg.translation(x, y), lib_svg.rotation(index * (1/12)), ].join(" ") ) }, [ lib_svg.isogon ( 3, r, { "position": lib_vector.cartesian(0, 0), "tilt": (1/4), "classes": [ "entry", "symbol_" + symbol.toFixed(0), ] , } ) ] ) ); children_tape.push(node_entry); } ) ; 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.from_spot(mod_vtm.mod_model.mod_token.spot_read(token)); let node_token = ( lib_xml.create_normal ( "g", { "class": "token", "transform": lib_svg.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), } ) ; } } } }