2 lines
30 KiB
JavaScript
Raw Normal View History

2026-05-31 13:21:13 +02:00
"use strict";var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};function e(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}var n=function(){return n=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var a in e=arguments[n])Object.prototype.hasOwnProperty.call(e,a)&&(t[a]=e[a]);return t},n.apply(this,arguments)};function r(t,e,n){if(n||2===arguments.length)for(var r,a=0,s=e.length;a<s;a++)!r&&a in e||(r||(r=Array.prototype.slice.call(e,0,a)),r[a]=e[a]);return t.concat(r||Array.prototype.slice.call(e))}function a(t,e,n){if(t&&t.length){const[r,a]=e,s=Math.PI/180*n,o=Math.cos(s),i=Math.sin(s);for(const e of t){const[t,n]=e;e[0]=(t-r)*o-(n-a)*i+r,e[1]=(t-r)*i+(n-a)*o+a}}}function s(t,e){return t[0]===e[0]&&t[1]===e[1]}function o(t,e,n,r=1){const o=n,i=Math.max(e,.1),h=t[0]&&t[0][0]&&"number"==typeof t[0][0]?[t]:t,u=[0,0];if(o)for(const t of h)a(t,u,o);const p=function(t,e,n){const r=[];for(const e of t){const t=[...e];s(t[0],t[t.length-1])||t.push([t[0][0],t[0][1]]),t.length>2&&r.push(t)}const a=[];e=Math.max(e,.1);const o=[];for(const t of r)for(let e=0;e<t.length-1;e++){const n=t[e],r=t[e+1];if(n[1]!==r[1]){const t=Math.min(n[1],r[1]);o.push({ymin:t,ymax:Math.max(n[1],r[1]),x:t===n[1]?n[0]:r[0],islope:(r[0]-n[0])/(r[1]-n[1])})}}if(o.sort(((t,e)=>t.ymin<e.ymin?-1:t.ymin>e.ymin?1:t.x<e.x?-1:t.x>e.x?1:t.ymax===e.ymax?0:(t.ymax-e.ymax)/Math.abs(t.ymax-e.ymax))),!o.length)return a;let i=[],h=o[0].ymin,u=0;for(;i.length||o.length;){if(o.length){let t=-1;for(let e=0;e<o.length&&!(o[e].ymin>h);e++)t=e;o.splice(0,t+1).forEach((t=>{i.push({s:h,edge:t})}))}if(i=i.filter((t=>!(t.edge.ymax<=h))),i.sort(((t,e)=>t.edge.x===e.edge.x?0:(t.edge.x-e.edge.x)/Math.abs(t.edge.x-e.edge.x))),(1!==n||u%e==0)&&i.length>1)for(let t=0;t<i.length;t+=2){const e=t+1;if(e>=i.length)break;const n=i[t].edge,r=i[e].edge;a.push([[Math.round(n.x),h],[Math.round(r.x),h]])}h+=n,i.forEach((t=>{t.edge.x=t.edge.x+n*t.edge.islope})),u++}return a}(h,i,r);if(o){for(const t of h)a(t,u,-o);!function(t,e,n){const r=[];t.forEach((t=>r.push(...t))),a(r,e,n)}(p,u,-o)}return p}function i(t,e){var n,r=e.hachureAngle+90,a=e.hachureGap;a<0&&(a=4*e.strokeWidth),a=Math.round(Math.max(a,.1));var s=1;return e.roughness>=1&&((null===(n=e.randomizer)||void 0===n?void 0:n.next())||Math.random())>.7&&(s=a),o(t,a,r,s||1)}"function"==typeof SuppressedError&&SuppressedError;var h=function(){function t(t){this.helper=t}return t.prototype.fillPolygons=function(t,e){return this._fillPolygons(t,e)},t.prototype._fillPolygons=function(t,e){var n=i(t,e);return{type:"fillSketch",ops:this.renderLines(n,e)}},t.prototype.renderLines=function(t,e){for(var n=[],r=0,a=t;r<a.length;r++){var s=a[r];n.push.apply(n,this.helper.doubleLineOps(s[0][0],s[0][1],s[1][0],s[1][1],e))}return n},t}();function u(t){var e=t[0],n=t[1];return Math.sqrt(Math.pow(e[0]-n[0],2)+Math.pow(e[1]-n[1],2))}var p=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return e(n,t),n.prototype.fillPolygons=function(t,e){var n=e.hachureGap;n<0&&(n=4*e.strokeWidth),n=Math.max(n,.1);for(var a=i(t,Object.assign({},e,{hachureGap:n})),s=Math.PI/180*e.hachureAngle,o=[],h=.5*n*Math.cos(s),p=.5*n*Math.sin(s),l=0,c=a;l<c.length;l++){var f=c[l],d=f[0],g=f[1];u([d,g])&&o.push([[d[0]-h,d[1]+p],r([],g,!0)],[[d[0]+h,d[1]-p],r([],g,!0)])}return{type:"fillSketch",ops:this.renderLines(o,e)}},n}(h),l=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return e(n,t),n.prototype.fillPolygons=function(t,e){var n=this._fillPolygons(t,e),r=Object.assign({},e,{hachureAngle:e.hachureAngle+90}),a=this._fillPolygons(t,r);return n.ops=n.ops.concat(a.ops),n},n}(h),c=function(){function t(t){this.helper=t}return t.prototype.fillPolygons=function(t,e){var n=i(t,e=Obje