UNPKG

jianpurender

Version:

Render music score using SVG on browsers.

1 lines 2.74 kB
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.mm=e():t.mm=e()}(global,(()=>(()=>{"use strict";var t={d:(e,n)=>{for(var l in n)t.o(n,l)&&!t.o(e,l)&&Object.defineProperty(e,l,{enumerable:!0,get:n[l]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{SVGNS:()=>n,createSVGGroupChild:()=>i,drawSVGPath:()=>l,drawSVGText:()=>r,highlightElement:()=>s,resetElementHighlight:()=>c,setBlinkAnimation:()=>u,setFill:()=>o,setStroke:()=>a});const n="http://www.w3.org/2000/svg";function l(t,e,l,r,i,u,o=1){const a=document.createElementNS(n,"path");return a.setAttributeNS(null,"d",e),a.setAttributeNS(null,"transform",`translate(${l}, ${r}) scale(${i}, ${u})`),o<1&&a.setAttributeNS(null,"opacity",`${o}`),t.appendChild(a),a}function r(t,e,l,r,i,u="normal",o="middle",a="middle",s="currentColor",c=1){const d=document.createElementNS(n,"text");d.setAttributeNS(null,"font-family","sans-serif"),d.setAttributeNS(null,"font-size",i),d.setAttributeNS(null,"font-weight",u),d.setAttributeNS(null,"x",`${l}`),d.setAttributeNS(null,"y",`${r}`),d.setAttributeNS(null,"text-anchor",o),d.setAttributeNS(null,"dominant-baseline",a),"currentColor"!==s&&d.setAttributeNS(null,"fill",s),c<1&&d.setAttributeNS(null,"opacity",`${c}`);const b=document.createTextNode(e);return d.appendChild(b),t.appendChild(d),d}function i(t,e){const l=document.createElementNS(n,"g");return e&&l.setAttribute("data-id",e),t.appendChild(l),l}function u(t,e=!0,l="1s"){let r=t.querySelector('animate[attributeName="opacity"]');return e?r?(r.setAttributeNS(null,"repeatCount","indefinite"),r.beginElement()):(r=document.createElementNS(n,"animate"),r.setAttributeNS(null,"attributeName","opacity"),r.setAttributeNS(null,"values","1;0.2;1"),r.setAttributeNS(null,"keyTimes","0;0.5;1"),r.setAttributeNS(null,"dur",l),r.setAttributeNS(null,"repeatCount","indefinite"),t.appendChild(r)):(r&&(r.endElement(),r.setAttributeNS(null,"repeatCount","0"),t.style.opacity="1"),t.style.opacity="1"),t}function o(t,e){t.setAttributeNS(null,"fill",e)}function a(t,e,n){t.setAttributeNS(null,"stroke",e),t.setAttributeNS(null,"stroke-width",`${n}`)}function s(t,e){const n=[];return t.matches("text, path")&&n.push(t),t.querySelectorAll("text, path").forEach((t=>{n.push(t)})),n.forEach((t=>{"none"!==t.getAttribute("fill")&&t.setAttribute("fill",e)})),t}function c(t,e){t.querySelectorAll("text, path").forEach((t=>{"none"!==t.getAttribute("fill")&&t.setAttribute("fill",e)}))}return e})()));