jianpurender
Version:
Render music score using SVG on browsers.
1 lines • 2.75 kB
JavaScript
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.svg_tools=e():t.svg_tools=e()}(self,(()=>(()=>{"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:()=>a,resetElementHighlight:()=>c,setBlinkAnimation:()=>u,setFill:()=>o,setStroke:()=>s});const n="http://www.w3.org/2000/svg";function l(t,e,l,r,i,u,o=1){const s=document.createElementNS(n,"path");return s.setAttributeNS(null,"d",e),s.setAttributeNS(null,"transform",`translate(${l}, ${r}) scale(${i}, ${u})`),o<1&&s.setAttributeNS(null,"opacity",`${o}`),t.appendChild(s),s}function r(t,e,l,r,i,u="normal",o="middle",s="middle",a="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",s),"currentColor"!==a&&d.setAttributeNS(null,"fill",a),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 s(t,e,n){t.setAttributeNS(null,"stroke",e),t.setAttributeNS(null,"stroke-width",`${n}`)}function a(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})()));