vtm/quelldatein/manifestation/svg/figur.ts

143 lines
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>
*/
export class klasse_svg_figur
extends klasse_manifestation<mod_vtm_aufbau.klasse_figur, mod_vtm_helfer.schnittstelle_xmlknoten>
{
/**
* @author kcf <vidofnir@folksprak.org>
*/
public constructor(aufbau : mod_vtm_aufbau.klasse_figur)
{
super(aufbau);
}
/**
* @author kcf <vidofnir@folksprak.org>
* @implementation
*/
public darstellen() : mod_vtm_helfer.schnittstelle_xmlknoten
{
let figur : mod_vtm_aufbau.klasse_figur = this.aufbau;
let kinder_figur : Array<mod_vtm_helfer.schnittstelle_xmlknoten> = [];
// Stein
{
let knoten_stein : mod_vtm_helfer.schnittstelle_xmlknoten = (
new mod_vtm_helfer.klasse_xmlknoten_normal
(
"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> = figur.band_lesen();
let kinder_band : Array<mod_vtm_helfer.schnittstelle_xmlknoten> = [];
band.reduceRight
(
(dummy, 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.schnittstelle_xmlknoten = (
new mod_vtm_helfer.klasse_xmlknoten_normal
(
"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);
return null;
}
,
null
)
;
let knoten_band = (
new mod_vtm_helfer.klasse_xmlknoten_normal
(
"g",
{
"class": "band",
},
kinder_band
)
);
kinder_figur.push(knoten_band);
}
let position : typ_position = position_von_stelle(figur.stelle_lesen());
let knoten_figur = (
new mod_vtm_helfer.klasse_xmlknoten_normal
(
"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>
* @implementation
*/
public binden() : void
{
}
}
}