vtm/quelldatein/manifestation/svg/figur.ts

176 lines
4.4 KiB
TypeScript
Raw Normal View History

2017-11-09 18:42:09 +01:00
/*
* 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_manifestation
{
/**
* @author kcf <vidofnir@folksprak.org>
*/
2018-03-26 00:41:10 +02:00
export type typ_svg_figur =
2017-11-09 18:42:09 +01:00
{
2018-03-26 00:41:10 +02:00
aufbau : mod_vtm_aufbau.typ_figur;
2017-11-09 18:42:09 +01:00
}
2018-03-26 00:41:10 +02:00
;
/**
* @author kcf <vidofnir@folksprak.org>
*/
function svg_figur_erstellen
(
aufbau : mod_vtm_aufbau.typ_figur
)
: typ_svg_figur
{
return {
"aufbau": aufbau,
};
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function svg_figur_erstellen_manifestation
(
aufbau : mod_vtm_aufbau.typ_figur
)
: typ_manifestation<mod_vtm_aufbau.typ_figur>
{
return {
"art": "svg_figur",
"angaben": svg_figur_erstellen(aufbau),
};
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function svg_figur_darstellen
(
svg_figur : typ_svg_figur
)
: mod_vtm_helfer.typ_xmlknoten
{
let figur : mod_vtm_aufbau.typ_figur = svg_figur.aufbau;
let kinder_figur : Array<mod_vtm_helfer.typ_xmlknoten> = [];
// Stein
{
let knoten_stein : mod_vtm_helfer.typ_xmlknoten = (
mod_vtm_helfer.xmlknoten_normal_erstellen_erweitert
(
"circle",
{
"cx": (0.0).toFixed(svg_float_praezission),
"cy": (0.0).toFixed(svg_float_praezission),
"r": (0.125).toFixed(svg_float_praezission),
"class": "stein",
}
)
);
kinder_figur.push(knoten_stein);
}
// Band
{
let band : Array<mod_vtm_aufbau.typ_symbol> = mod_vtm_aufbau.figur_band_lesen(figur);
let kinder_band : Array<mod_vtm_helfer.typ_xmlknoten> = [];
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 : mod_vtm_helfer.typ_xmlknoten = (
mod_vtm_helfer.xmlknoten_normal_erstellen_erweitert
(
"circle",
{
"cx": x.toFixed(svg_float_praezission),
"cy": y.toFixed(svg_float_praezission),
"r": r.toFixed(svg_float_praezission),
/*
"x": (x-r).toFixed(svg_float_praezission),
"y": (y-r).toFixed(svg_float_praezission),
"width": (2*r).toFixed(svg_float_praezission),
"height": (2*r).toFixed(svg_float_praezission),
*/
"class": (
[
"eintrag",
"symbol_" + symbol.toFixed(0),
].join(" ")
),
}
)
);
kinder_band.push(knoten_eintrag);
}
)
;
let knoten_band = (
mod_vtm_helfer.xmlknoten_normal_erstellen_erweitert
(
"g",
{
"class": "band",
},
kinder_band
)
);
kinder_figur.push(knoten_band);
}
let position : typ_position = position_von_stelle(mod_vtm_aufbau.figur_stelle_lesen(figur));
let knoten_figur = (
mod_vtm_helfer.xmlknoten_normal_erstellen_erweitert
(
"g",
{
"class": "figur",
"transform": ("translate(" + position.x.toFixed(svg_float_praezission) + "," + position.y.toFixed(svg_float_praezission) + ")"),
},
kinder_figur
)
);
return knoten_figur;
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function svg_figur_binden(svg_figur : typ_svg_figur) : void
{
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
implementierung_manifestation["svg_figur"] =
{
"darstellen": (manifestation) => svg_figur_darstellen(manifestation.angaben),
"binden": (manifestation) => svg_figur_binden(manifestation.angaben),
}
;
2017-11-09 18:42:09 +01:00
}