if ellipse is found, consider it a circle with r=rx+ry/2 (fix #2)
This commit is contained in:
parent
124ce4779f
commit
2e2728f4e2
1 changed files with 8 additions and 2 deletions
|
@ -392,19 +392,25 @@ async function processScrolls(svg: XMLDocument): Promise<VideoScrollDef[]> {
|
||||||
}
|
}
|
||||||
|
|
||||||
function processAudio(svg: XMLDocument): AudioAreaDef[] {
|
function processAudio(svg: XMLDocument): AudioAreaDef[] {
|
||||||
return Array.from(svg.getElementsByTagName("circle"))
|
const circles: (SVGCircleElement | SVGEllipseElement)[] = Array.from(svg.getElementsByTagName("circle"));
|
||||||
|
const ellipses: (SVGCircleElement | SVGEllipseElement)[] = Array.from(svg.getElementsByTagName("ellipse"));
|
||||||
|
return circles.concat(ellipses)
|
||||||
.filter((el) => Array.from(el.children).some((el) => el.tagName == "desc"))
|
.filter((el) => Array.from(el.children).some((el) => el.tagName == "desc"))
|
||||||
.map((el) => {
|
.map((el) => {
|
||||||
const descNode = Array.from(el.children).find((el) => el.tagName == "desc");
|
const descNode = Array.from(el.children).find((el) => el.tagName == "desc");
|
||||||
console.debug(`[SVG/AUDIOAREAS] Found audio area #${el.id}: ${descNode?.textContent}`);
|
console.debug(`[SVG/AUDIOAREAS] Found audio area #${el.id}: ${descNode?.textContent}`);
|
||||||
const audioSrc = descNode!.textContent!.trim();
|
const audioSrc = descNode!.textContent!.trim();
|
||||||
|
|
||||||
|
const radius = el.hasAttribute("r") ?
|
||||||
|
(el as SVGCircleElement).r.baseVal.value :
|
||||||
|
((el as SVGEllipseElement).rx.baseVal.value + (el as SVGEllipseElement).ry.baseVal.value) / 2;
|
||||||
|
|
||||||
el.classList.add("internal");
|
el.classList.add("internal");
|
||||||
|
|
||||||
return {
|
return {
|
||||||
cx: el.cx.baseVal.value,
|
cx: el.cx.baseVal.value,
|
||||||
cy: el.cy.baseVal.value,
|
cy: el.cy.baseVal.value,
|
||||||
radius: el.r.baseVal.value,
|
radius,
|
||||||
src: `content/${audioSrc}`,
|
src: `content/${audioSrc}`,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue