vtm/quelldatein/manifestation/svg/aktor/_aktor.ts

162 lines
4.4 KiB
TypeScript
Raw Normal View History

2018-03-28 12:09:27 +02: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
{
export module mod_manifestation
{
export module mod_svg
{
export module mod_aktor
{
/**
* @author kcf <vidofnir@folksprak.org>
*/
export type signatur_aktor =
{
darstellen : (aktor : mod_vtm.mod_aufbau.mod_aktor.typ_aktor)=>Array<lib_xml.typ_knoten>;
}
;
/**
* @author kcf <vidofnir@folksprak.org>
*/
export var brauch_aktor : lib_brauch.typ_brauch<signatur_aktor> = lib_brauch.erstellen<signatur_aktor>();
/**
* @author kcf <vidofnir@folksprak.org>
*/
export type typ_aktor =
{
aufbau : mod_vtm.mod_aufbau.mod_aktor.typ_aktor;
stelle : mod_vtm.mod_aufbau.mod_stelle.typ_stelle;
}
;
/**
* @author kcf <vidofnir@folksprak.org>
*/
function erstellen
(
aufbau : mod_vtm.mod_aufbau.mod_aktor.typ_aktor,
stelle : mod_vtm.mod_aufbau.mod_stelle.typ_stelle
)
: typ_aktor
{
return {
"aufbau": aufbau,
"stelle": stelle
};
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
export function erstellen_manifestation
(
aufbau : mod_vtm.mod_aufbau.mod_aktor.typ_aktor,
stelle : mod_vtm.mod_aufbau.mod_stelle.typ_stelle
)
: typ_manifestation<mod_vtm.mod_aufbau.mod_aktor.typ_aktor>
{
return {
"art": "svg_aktor",
"angaben": erstellen(aufbau, stelle),
};
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function darstellen(aktor_ : typ_aktor) : lib_xml.typ_knoten
{
let aktor : mod_vtm.mod_aufbau.mod_aktor.typ_aktor = aktor_.aufbau;
let knoten_rahmen = function () : lib_xml.typ_knoten
{
return (
pfad
(
mod_vtm.mod_helfer.sequenz(6).map(i => lib_vektor.polar(((i+0.5)/6) * (2*Math.PI), 0.5)),
true,
{
"class": "rahmen"
}
)
);
}
;
let position : mod_position.typ_position = mod_position.von_stelle(aktor_.stelle);
let knoten_feld : lib_xml.typ_knoten = (
lib_xml.erstellen_normal
(
"g",
{
"class": "feld",
"rel": mod_vtm.mod_aufbau.mod_stelle.hash(aktor_.stelle),
"transform": translation(position.x, position.y),
},
(
[knoten_rahmen()]
.concat(lib_brauch.anwenden<signatur_aktor>(brauch_aktor, aktor.art)["darstellen"](aktor))
)
)
);
return knoten_feld;
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
function binden(aktor : typ_aktor) : void
{
}
/**
* @author kcf <vidofnir@folksprak.org>
*/
lib_brauch.umsetzen<signatur_manifestation<mod_vtm.mod_aufbau.mod_aktor.typ_aktor, lib_xml.typ_knoten>>
(
brauch_manifestation,
"svg_aktor",
{
"darstellen": (manifestation) => darstellen(manifestation.angaben),
"binden": (manifestation) => binden(manifestation.angaben),
}
)
;
}
}
}
}