195 lines
5.3 KiB
TypeScript
195 lines
5.3 KiB
TypeScript
/*
|
|
* Verrückte Turing-Maschinen — A turing complete game
|
|
* Copyright (C) 2016 Christian Fraß <vidofnir@folksprak.org>
|
|
*
|
|
* 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/>.
|
|
*/
|
|
|
|
module mod_vtm
|
|
{
|
|
|
|
export module mod_manifestation
|
|
{
|
|
|
|
export module mod_svg
|
|
{
|
|
|
|
export module mod_figur
|
|
{
|
|
|
|
/**
|
|
* @author kcf <vidofnir@folksprak.org>
|
|
*/
|
|
export type typ_figur =
|
|
{
|
|
aufbau : mod_vtm.mod_aufbau.mod_figur.typ_figur;
|
|
}
|
|
;
|
|
|
|
|
|
/**
|
|
* @author kcf <vidofnir@folksprak.org>
|
|
*/
|
|
function erstellen
|
|
(
|
|
aufbau : mod_vtm.mod_aufbau.mod_figur.typ_figur
|
|
)
|
|
: typ_figur
|
|
{
|
|
return {
|
|
"aufbau": aufbau,
|
|
};
|
|
}
|
|
|
|
|
|
/**
|
|
* @author kcf <vidofnir@folksprak.org>
|
|
*/
|
|
export function erstellen_manifestation
|
|
(
|
|
aufbau : mod_vtm.mod_aufbau.mod_figur.typ_figur
|
|
)
|
|
: typ_manifestation<mod_vtm.mod_aufbau.mod_figur.typ_figur>
|
|
{
|
|
return {
|
|
"art": "svg_figur",
|
|
"angaben": erstellen(aufbau),
|
|
};
|
|
}
|
|
|
|
|
|
/**
|
|
* @author kcf <vidofnir@folksprak.org>
|
|
*/
|
|
function darstellen
|
|
(
|
|
figur_ : typ_figur
|
|
)
|
|
: lib_xml.typ_knoten
|
|
{
|
|
let figur : mod_vtm.mod_aufbau.mod_figur.typ_figur = figur_.aufbau;
|
|
let kinder_figur : Array<lib_xml.typ_knoten> = [];
|
|
// Stein
|
|
{
|
|
let knoten_stein : lib_xml.typ_knoten = (
|
|
lib_xml.erstellen_normal
|
|
(
|
|
"circle",
|
|
{
|
|
"cx": (0.0).toFixed(float_praezission),
|
|
"cy": (0.0).toFixed(float_praezission),
|
|
"r": (0.125).toFixed(float_praezission),
|
|
"class": "stein",
|
|
}
|
|
)
|
|
);
|
|
kinder_figur.push(knoten_stein);
|
|
}
|
|
// Band
|
|
{
|
|
let band : Array<mod_vtm.mod_aufbau.mod_symbol.typ_symbol> = mod_vtm.mod_aufbau.mod_figur.band_lesen(figur);
|
|
let kinder_band : Array<lib_xml.typ_knoten> = [];
|
|
band.forEach
|
|
(
|
|
(symbol, index) =>
|
|
{
|
|
let r : float = 0.06125;
|
|
let x : float = (+0.1+(2*r*1.25)*index);
|
|
let y : float = (-0.1);
|
|
let knoten_eintrag : lib_xml.typ_knoten = (
|
|
lib_xml.erstellen_normal
|
|
(
|
|
"circle",
|
|
{
|
|
"cx": x.toFixed(float_praezission),
|
|
"cy": y.toFixed(float_praezission),
|
|
"r": r.toFixed(float_praezission),
|
|
/*
|
|
"x": (x-r).toFixed(float_praezission),
|
|
"y": (y-r).toFixed(float_praezission),
|
|
"width": (2*r).toFixed(float_praezission),
|
|
"height": (2*r).toFixed(float_praezission),
|
|
*/
|
|
"class": (
|
|
[
|
|
"eintrag",
|
|
"symbol_" + symbol.toFixed(0),
|
|
].join(" ")
|
|
),
|
|
}
|
|
)
|
|
);
|
|
kinder_band.push(knoten_eintrag);
|
|
}
|
|
)
|
|
;
|
|
let knoten_band = (
|
|
lib_xml.erstellen_normal
|
|
(
|
|
"g",
|
|
{
|
|
"class": "band",
|
|
},
|
|
kinder_band
|
|
)
|
|
);
|
|
kinder_figur.push(knoten_band);
|
|
}
|
|
let position : mod_position.typ_position = mod_position.von_stelle(mod_vtm.mod_aufbau.mod_figur.stelle_lesen(figur));
|
|
let knoten_figur = (
|
|
lib_xml.erstellen_normal
|
|
(
|
|
"g",
|
|
{
|
|
"class": "figur",
|
|
"transform": translation(position.x, position.y),
|
|
},
|
|
kinder_figur
|
|
)
|
|
);
|
|
return knoten_figur;
|
|
}
|
|
|
|
|
|
/**
|
|
* @author kcf <vidofnir@folksprak.org>
|
|
*/
|
|
function binden(figur : typ_figur) : void
|
|
{
|
|
}
|
|
|
|
|
|
/**
|
|
* @author kcf <vidofnir@folksprak.org>
|
|
*/
|
|
lib_brauch.umsetzen<signatur_manifestation<mod_vtm.mod_aufbau.mod_figur.typ_figur, lib_xml.typ_knoten>>
|
|
(
|
|
brauch_manifestation,
|
|
"svg_figur",
|
|
{
|
|
"darstellen": (manifestation) => darstellen(manifestation.angaben),
|
|
"binden": (manifestation) => binden(manifestation.angaben),
|
|
}
|
|
)
|
|
;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|