2017-11-09 18:42:09 +01:00
|
|
|
/*
|
|
|
|
|
* Verrückte Turing-Maschinen — A turing complete game
|
2018-03-29 01:13:39 +02:00
|
|
|
* Copyright (C) 2016-2018 Christian Fraß <vidofnir@folksprak.org>
|
2017-11-09 18:42:09 +01:00
|
|
|
*
|
|
|
|
|
* 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 <https://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
|
|
|
|
|
2018-03-26 14:22:20 +02:00
|
|
|
module mod_vtm
|
2017-11-09 18:42:09 +01:00
|
|
|
{
|
|
|
|
|
|
2018-03-26 14:22:20 +02:00
|
|
|
export module mod_manifestation
|
2017-11-09 18:42:09 +01:00
|
|
|
{
|
2018-03-26 14:22:20 +02:00
|
|
|
|
|
|
|
|
export module mod_svg
|
|
|
|
|
{
|
|
|
|
|
|
2018-03-28 13:59:29 +02:00
|
|
|
export module mod_token
|
2018-03-26 00:41:10 +02:00
|
|
|
{
|
2018-03-26 14:22:20 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @author kcf <vidofnir@folksprak.org>
|
|
|
|
|
*/
|
2018-03-28 13:59:29 +02:00
|
|
|
export type type_token =
|
2018-03-26 14:22:20 +02:00
|
|
|
{
|
2018-03-28 13:59:29 +02:00
|
|
|
model : mod_vtm.mod_model.mod_token.type_token;
|
2018-03-26 14:22:20 +02:00
|
|
|
}
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @author kcf <vidofnir@folksprak.org>
|
|
|
|
|
*/
|
2018-03-28 13:59:29 +02:00
|
|
|
function create
|
2018-03-26 14:22:20 +02:00
|
|
|
(
|
2018-03-28 13:59:29 +02:00
|
|
|
model : mod_vtm.mod_model.mod_token.type_token
|
2018-03-26 14:22:20 +02:00
|
|
|
)
|
2018-03-28 13:59:29 +02:00
|
|
|
: type_token
|
2018-03-26 14:22:20 +02:00
|
|
|
{
|
|
|
|
|
return {
|
2018-03-28 13:59:29 +02:00
|
|
|
"model": model,
|
2018-03-26 14:22:20 +02:00
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @author kcf <vidofnir@folksprak.org>
|
|
|
|
|
*/
|
2018-03-29 01:13:39 +02:00
|
|
|
export function create_extended
|
2018-03-26 14:22:20 +02:00
|
|
|
(
|
2018-03-28 13:59:29 +02:00
|
|
|
model : mod_vtm.mod_model.mod_token.type_token
|
2018-03-26 14:22:20 +02:00
|
|
|
)
|
2018-03-28 13:59:29 +02:00
|
|
|
: type_manifestation<mod_vtm.mod_model.mod_token.type_token>
|
2018-03-26 14:22:20 +02:00
|
|
|
{
|
|
|
|
|
return {
|
2018-03-28 13:59:29 +02:00
|
|
|
"kind": "svg_token",
|
|
|
|
|
"data": create(model),
|
2018-03-26 14:22:20 +02:00
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @author kcf <vidofnir@folksprak.org>
|
|
|
|
|
*/
|
2018-03-28 13:59:29 +02:00
|
|
|
function view
|
2018-03-26 14:22:20 +02:00
|
|
|
(
|
2018-03-28 13:59:29 +02:00
|
|
|
token_ : type_token
|
2018-03-26 14:22:20 +02:00
|
|
|
)
|
2018-03-28 13:59:29 +02:00
|
|
|
: lib_xml.type_node
|
2018-03-26 14:22:20 +02:00
|
|
|
{
|
2018-03-28 13:59:29 +02:00
|
|
|
let token : mod_vtm.mod_model.mod_token.type_token = token_.model;
|
|
|
|
|
let children_token : Array<lib_xml.type_node> = [];
|
2018-03-26 14:22:20 +02:00
|
|
|
// Stein
|
|
|
|
|
{
|
2018-03-28 13:59:29 +02:00
|
|
|
let node_stein : lib_xml.type_node = (
|
|
|
|
|
lib_xml.create_normal
|
2018-03-26 14:22:20 +02:00
|
|
|
(
|
|
|
|
|
"circle",
|
|
|
|
|
{
|
2018-03-29 01:13:39 +02:00
|
|
|
"cx": (0.0).toFixed(lib_svg.float_precision),
|
|
|
|
|
"cy": (0.0).toFixed(lib_svg.float_precision),
|
|
|
|
|
"r": (0.125).toFixed(lib_svg.float_precision),
|
2018-03-26 14:22:20 +02:00
|
|
|
"class": "stein",
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
);
|
2018-03-28 13:59:29 +02:00
|
|
|
children_token.push(node_stein);
|
2018-03-26 14:22:20 +02:00
|
|
|
}
|
|
|
|
|
// Band
|
|
|
|
|
{
|
2018-03-28 13:59:29 +02:00
|
|
|
let tape : Array<mod_vtm.mod_model.mod_symbol.type_symbol> = mod_vtm.mod_model.mod_token.tape_read(token);
|
|
|
|
|
let children_tape : Array<lib_xml.type_node> = [];
|
|
|
|
|
tape.forEach
|
2018-03-26 14:22:20 +02:00
|
|
|
(
|
|
|
|
|
(symbol, index) =>
|
|
|
|
|
{
|
|
|
|
|
let r : float = 0.06125;
|
|
|
|
|
let x : float = (+0.1+(2*r*1.25)*index);
|
|
|
|
|
let y : float = (-0.1);
|
2018-03-28 13:59:29 +02:00
|
|
|
let node_eintrag : lib_xml.type_node = (
|
|
|
|
|
lib_xml.create_normal
|
2018-03-26 14:22:20 +02:00
|
|
|
(
|
|
|
|
|
"circle",
|
|
|
|
|
{
|
2018-03-29 01:13:39 +02:00
|
|
|
"cx": x.toFixed(lib_svg.float_precision),
|
|
|
|
|
"cy": y.toFixed(lib_svg.float_precision),
|
|
|
|
|
"r": r.toFixed(lib_svg.float_precision),
|
2018-03-26 14:22:20 +02:00
|
|
|
/*
|
2018-03-29 01:13:39 +02:00
|
|
|
"x": (x-r).toFixed(lib_svg.float_precision),
|
|
|
|
|
"y": (y-r).toFixed(lib_svg.float_precision),
|
|
|
|
|
"width": (2*r).toFixed(lib_svg.float_precision),
|
|
|
|
|
"height": (2*r).toFixed(lib_svg.float_precision),
|
2018-03-26 14:22:20 +02:00
|
|
|
*/
|
|
|
|
|
"class": (
|
|
|
|
|
[
|
|
|
|
|
"eintrag",
|
|
|
|
|
"symbol_" + symbol.toFixed(0),
|
|
|
|
|
].join(" ")
|
|
|
|
|
),
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
);
|
2018-03-28 13:59:29 +02:00
|
|
|
children_tape.push(node_eintrag);
|
2018-03-26 14:22:20 +02:00
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
;
|
2018-03-28 13:59:29 +02:00
|
|
|
let node_tape = (
|
|
|
|
|
lib_xml.create_normal
|
2018-03-26 14:22:20 +02:00
|
|
|
(
|
|
|
|
|
"g",
|
|
|
|
|
{
|
2018-03-28 13:59:29 +02:00
|
|
|
"class": "tape",
|
2018-03-26 14:22:20 +02:00
|
|
|
},
|
2018-03-28 13:59:29 +02:00
|
|
|
children_tape
|
2018-03-26 14:22:20 +02:00
|
|
|
)
|
|
|
|
|
);
|
2018-03-28 13:59:29 +02:00
|
|
|
children_token.push(node_tape);
|
2018-03-26 14:22:20 +02:00
|
|
|
}
|
2018-03-29 01:13:39 +02:00
|
|
|
let position : mod_position.type_position = mod_position.from_spot(mod_vtm.mod_model.mod_token.spot_read(token));
|
2018-03-28 13:59:29 +02:00
|
|
|
let node_token = (
|
|
|
|
|
lib_xml.create_normal
|
2018-03-26 14:22:20 +02:00
|
|
|
(
|
|
|
|
|
"g",
|
|
|
|
|
{
|
2018-03-28 13:59:29 +02:00
|
|
|
"class": "token",
|
2018-03-29 01:13:39 +02:00
|
|
|
"transform": lib_svg.translation(position.x, position.y),
|
2018-03-26 14:22:20 +02:00
|
|
|
},
|
2018-03-28 13:59:29 +02:00
|
|
|
children_token
|
2018-03-26 14:22:20 +02:00
|
|
|
)
|
|
|
|
|
);
|
2018-03-28 13:59:29 +02:00
|
|
|
return node_token;
|
2018-03-26 14:22:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @author kcf <vidofnir@folksprak.org>
|
|
|
|
|
*/
|
2018-03-28 13:59:29 +02:00
|
|
|
function bind(token : type_token) : void
|
2018-03-26 14:22:20 +02:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @author kcf <vidofnir@folksprak.org>
|
|
|
|
|
*/
|
2018-03-28 13:59:29 +02:00
|
|
|
lib_trait.attend<signature_manifestation<mod_vtm.mod_model.mod_token.type_token, lib_xml.type_node>>
|
2018-03-28 12:09:27 +02:00
|
|
|
(
|
2018-03-28 13:59:29 +02:00
|
|
|
trait_manifestation,
|
|
|
|
|
"svg_token",
|
2018-03-28 12:09:27 +02:00
|
|
|
{
|
2018-03-28 13:59:29 +02:00
|
|
|
"view": (manifestation) => view(manifestation.data),
|
|
|
|
|
"bind": (manifestation) => bind(manifestation.data),
|
2018-03-28 12:09:27 +02:00
|
|
|
}
|
|
|
|
|
)
|
2018-03-26 14:22:20 +02:00
|
|
|
;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2018-03-26 00:41:10 +02:00
|
|
|
}
|
2017-11-09 18:42:09 +01:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|