@mlightcad/common 1.2.6 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/common.js +503 -259
- package/dist/common.umd.cjs +1 -1
- package/lib/AcCmTransparency.d.ts +201 -0
- package/lib/AcCmTransparency.d.ts.map +1 -0
- package/lib/AcCmTransparency.js +315 -0
- package/lib/AcCmTransparency.js.map +1 -0
- package/lib/AcCmTransparencyMethod.d.ts +16 -0
- package/lib/AcCmTransparencyMethod.d.ts.map +1 -0
- package/lib/AcCmTransparencyMethod.js +17 -0
- package/lib/AcCmTransparencyMethod.js.map +1 -0
- package/lib/index.d.ts +3 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +3 -1
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
package/dist/common.umd.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(u,M){typeof exports=="object"&&typeof module<"u"?M(exports):typeof define=="function"&&define.amd?define(["exports"],M):(u=typeof globalThis<"u"?globalThis:u||self,M(u.common={}))})(this,function(u){"use strict";function M(r,e){for(var t=0;t<e.length;t++){const n=e[t];if(typeof n!="string"&&!Array.isArray(n)){for(const s in n)if(s!=="default"&&!(s in r)){const i=Object.getOwnPropertyDescriptor(n,s);i&&Object.defineProperty(r,s,i.get?i:{enumerable:!0,get:()=>n[s]})}}}return Object.freeze(Object.defineProperty(r,Symbol.toStringTag,{value:"Module"}))}var o=(r=>(r[r.ByColor=1]="ByColor",r[r.ByACI=2]="ByACI",r[r.ByLayer=3]="ByLayer",r[r.ByBlock=4]="ByBlock",r[r.None=0]="None",r))(o||{});const x={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},T=[0,16711680,16776960,65280,65535,255,16711935,16777215,8421504,12632256,16711680,16744319,13369344,13395558,10027008,10046540,8323072,8339263,4980736,4990502,16727808,16752511,13382400,13401958,10036736,10051404,8331008,8343359,4985600,4992806,16744192,16760703,13395456,13408614,10046464,10056268,8339200,8347455,4990464,4995366,16760576,16768895,13408512,13415014,10056192,10061132,8347392,8351551,4995328,4997670,16776960,16777087,13421568,13421670,10000384,10000460,8355584,8355647,5000192,5000230,12582656,14679935,10079232,11717734,7510016,8755276,6258432,7307071,3755008,4344870,8388352,12582783,6736896,10079334,5019648,7510092,4161280,6258495,2509824,3755046,4194048,10485631,3394560,8375398,2529280,6264908,2064128,5209919,1264640,3099686,65280,8388479,52224,6736998,38912,5019724,32512,4161343,19456,2509862,65343,8388511,52275,6737023,38950,5019743,32543,4161359,19475,2509871,65407,8388543,52326,6737049,38988,5019762,32575,4161375,19494,2509881,65471,8388575,52377,6737074,39026,5019781,32607,4161391,19513,2509890,65535,8388607,52428,6737100,39064,5019800,32639,4161407,19532,2509900,49151,8380415,39372,6730444,29336,5014936,24447,4157311,14668,2507340,32767,8372223,26316,6724044,19608,5010072,16255,4153215,9804,2505036,16383,8364031,13260,6717388,9880,5005208,8063,4149119,4940,2502476,255,8355839,204,6710988,152,5000344,127,4145023,76,2500172,4129023,10452991,3342540,8349388,2490520,6245528,2031743,5193599,1245260,3089996,8323327,12550143,6684876,10053324,4980888,7490712,4128895,6242175,2490444,3745356,12517631,14647295,10027212,11691724,7471256,8735896,6226047,7290751,3735628,4335180,16711935,16744447,13369548,13395660,9961624,9981080,8323199,8339327,4980812,4990540,16711871,16744415,13369497,13395634,9961586,9981061,8323167,8339311,4980793,4990530,16711807,16744383,13369446,13395609,9961548,9981042,8323135,8339295,4980774,4990521,16711743,16744351,13369395,13395583,9961510,9981023,8323103,8339279,4980755,4990511,3355443,5987163,8684676,11382189,14079702,16777215,0];class _{static getColorByIndex(e){return T[e]}static getIndexByColor(e){const t=T.length-1;for(let n=1;n<t;++n)if(T[n]===e)return n}static getColorByName(e){return x[e.toLowerCase()]}static getNameByColor(e){for(const[t,n]of Object.entries(x))if(n===e)return t}static getNameByIndex(e){const t=this.getColorByIndex(e);return this.getNameByColor(t)}}class v{constructor(e=o.ByLayer,t){this._colorMethod=e,this._colorMethod==o.ByColor&&t==null?this._value=16777215:this._colorMethod==o.ByACI?t==null?this._value=8:t===0?this._colorMethod=o.ByBlock:t===256?this._colorMethod=o.ByLayer:this._value=Math.max(0,Math.min(t,256)):this._value=t}get colorMethod(){return this._colorMethod}set colorMethod(e){this._colorMethod=e}get red(){const e=this.RGB;return e!=null?e>>16&255:void 0}get green(){const e=this.RGB;return e!=null?e>>8&255:void 0}get blue(){const e=this.RGB;return e!=null?e&255:void 0}get RGB(){switch(this._colorMethod){case o.ByColor:case o.ByBlock:case o.ByLayer:return this._value;case o.ByACI:return this._value?_.getColorByIndex(this._value):this._value;default:return}}setRGB(e,t,n){const s=Math.max(0,Math.min(255,Math.round(e))),i=Math.max(0,Math.min(255,Math.round(t))),a=Math.max(0,Math.min(255,Math.round(n)));return this._value=s<<16|i<<8|a,this._colorMethod=o.ByColor,this}setRGBValue(e){return e==null||!Number.isFinite(e)?(console.warn("Invalid RGB value:",e),this):(this._value=e&16777215,this._colorMethod=o.ByColor,this)}setRGBFromCss(e){if(!e)return this;const t=e.trim().toLowerCase();if(t.startsWith("#")){let i=0,a=0,d=0;if(t.length===7)i=parseInt(t.substr(1,2),16),a=parseInt(t.substr(3,2),16),d=parseInt(t.substr(5,2),16);else if(t.length===4)i=parseInt(t[1]+t[1],16),a=parseInt(t[2]+t[2],16),d=parseInt(t[3]+t[3],16);else return console.warn("Invalid hex color:",e),this;return this.setRGB(i,a,d)}const n=t.match(/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);if(n){const i=parseInt(n[1],10),a=parseInt(n[2],10),d=parseInt(n[3],10);return this.setRGB(i,a,d)}const s=_.getColorByName(e);return s!==void 0?this.setRGBValue(s):(console.warn("Unknown CSS color string:",e),this)}setScalar(e){return this.setRGB(e,e,e)}get hexColor(){const e=this.RGB;return e==null?void 0:"0x"+e.toString(16).padStart(6,"0").toUpperCase()}get cssColor(){const e=this.RGB;if(e!=null)return`rgb(${e>>16&255},${e>>8&255},${e&255})`}get colorIndex(){return this._colorMethod===o.ByACI?this._value:this._colorMethod===o.ByLayer?256:this._colorMethod===o.ByBlock?0:void 0}set colorIndex(e){if(e==null)return;const t=Math.max(0,Math.min(256,Math.round(e)));t===0?(this._colorMethod=o.ByBlock,this._value=void 0):t===256?(this._colorMethod=o.ByLayer,this._value=void 0):(this._colorMethod=o.ByACI,this._value=t)}get isByColor(){return this._colorMethod===o.ByColor}get isByACI(){return this._colorMethod===o.ByACI}get isByLayer(){return this._colorMethod===o.ByLayer}setByLayer(e){return this._colorMethod=o.ByLayer,e==null?this._value=256:this._value=e,this}get isByBlock(){return this._colorMethod===o.ByBlock}setByBlock(e){return this._colorMethod=o.ByBlock,e==null?this._value=0:this._value=e,this}get colorName(){switch(this._colorMethod){case o.ByLayer:return"ByLayer";case o.ByBlock:return"ByBlock";case o.ByColor:return this._value?_.getNameByColor(this._value):"";case o.ByACI:return this._value?_.getNameByIndex(this._value):"";default:return}}set colorName(e){if(!e)return;const t=_.getColorByName(e);t!==void 0?(this._value=t,this._colorMethod=o.ByColor):console.warn("Unknown color name:",e)}clone(){const e=new v;return e._colorMethod=this._colorMethod,e._value=this._value,e}copy(e){return this._colorMethod=e._colorMethod,this._value=e._value,this}equals(e){return this._colorMethod===e._colorMethod&&this._value===e._value}toString(){switch(this._colorMethod){case o.ByLayer:return"ByLayer";case o.ByBlock:return"ByBlock";case o.ByACI:return this._value!==void 0?String(this._value):"";case o.ByColor:return this._value?`${this.red},${this.green},${this.blue}`:"";default:return""}}static fromString(e){if(!e)return;const t=e.trim();if(/^bylayer$/i.test(t))return new v(o.ByLayer);if(/^byblock$/i.test(t))return new v(o.ByBlock);if(/^\d{1,3},\d{1,3},\d{1,3}$/i.test(t)){const[s,i,a]=t.split(",").map(Number),d=new v(o.ByColor);return d.setRGB(s,i,a),d}if(/^\d+$/.test(t)){const s=parseInt(t,10);return new v(o.ByACI,s)}const n=_.getColorByName(t);if(n!=null)return new v(o.ByColor,n);console.warn("Unknown color name:",e)}}class Y{constructor(e=o.ByColor,t=0){this._colorMethod=e,this._value=t}get colorMethd(){return this._colorMethod}get red(){return this._value>>16&255}set red(e){this._colorMethod=o.ByColor,this._value=this._value&65535|(e&255)<<16}get green(){return this._value>>8&255}set green(e){this._colorMethod=o.ByColor,this._value=this._value&16711935|(e&255)<<8}get blue(){return this._value&255}set blue(e){this._colorMethod=o.ByColor,this._value=this._value&16776960|e&255}setRGB(e,t,n){this._colorMethod=o.ByColor,this._value=(e&255)<<16|(t&255)<<8|n&255}get colorIndex(){return this._value}set colorIndex(e){this._colorMethod=o.ByACI,this._value=e}get layerIndex(){return this._value}set layerIndex(e){this._colorMethod=o.ByLayer,this._value=e}isByColor(){return this._colorMethod===o.ByColor}isByLayer(){return this._colorMethod===o.ByLayer}isByBlock(){return this._colorMethod===o.ByBlock}isByACI(){return this._colorMethod===o.ByACI}isNone(){return this._colorMethod===o.None}get rawValue(){return this._value}set rawValue(e){this._value=e}}const Z={get ILLEGAL_PARAMETERS(){return new ReferenceError("Illegal Parameters")},get ZERO_DIVISION(){return new Error("Zero division")},get UNRESOLVED_BOUNDARY_CONFLICT(){return new Error("Unresolved boundary conflict in boolean operation")},get INFINITE_LOOP(){return new Error("Infinite loop")},get CANNOT_INVOKE_ABSTRACT_METHOD(){return new Error("Abstract method cannot be invoked")},get OPERATION_IS_NOT_SUPPORTED(){return new Error("Operation is not supported")},get NOT_IMPLEMENTED(){return new Error("Not implemented yet")}};class J{constructor(){this._listeners={}}addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){if(this._listeners===void 0)return!1;const n=this._listeners;return n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){if(this._listeners===void 0)return;const s=this._listeners[e];if(s!==void 0){const i=s.indexOf(t);i!==-1&&s.splice(i,1)}}dispatchEvent(e){if(this._listeners===void 0)return;const n=this._listeners[e.type];if(n!==void 0){e.target=this;const s=n.slice(0);for(let i=0,a=s.length;i<a;i++)s[i].call(this,e)}}}class R{constructor(){this.listeners=[]}addEventListener(e){this.listeners.push(e)}removeEventListener(e){this.listeners=this.listeners.filter(t=>t!==e)}replaceEventListener(e){this.removeEventListener(e),this.addEventListener(e)}dispatch(e,...t){for(const n of this.listeners)n.call(null,e,...t)}}var X=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Q(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var D={exports:{}};(function(r){(function(e,t){r.exports?r.exports=t():e.log=t()})(X,function(){var e=function(){},t="undefined",n=typeof window!==t&&typeof window.navigator!==t&&/Trident\/|MSIE /.test(window.navigator.userAgent),s=["trace","debug","info","warn","error"],i={},a=null;function d(h,f){var l=h[f];if(typeof l.bind=="function")return l.bind(h);try{return Function.prototype.bind.call(l,h)}catch{return function(){return Function.prototype.apply.apply(l,[h,arguments])}}}function A(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function b(h){return h==="debug"&&(h="log"),typeof console===t?!1:h==="trace"&&n?A:console[h]!==void 0?d(console,h):console.log!==void 0?d(console,"log"):e}function m(){for(var h=this.getLevel(),f=0;f<s.length;f++){var l=s[f];this[l]=f<h?e:this.methodFactory(l,h,this.name)}if(this.log=this.debug,typeof console===t&&h<this.levels.SILENT)return"No console available for logging"}function P(h){return function(){typeof console!==t&&(m.call(this),this[h].apply(this,arguments))}}function y(h,f,l){return b(h)||P.apply(this,arguments)}function H(h,f){var l=this,I,U,L,p="loglevel";typeof h=="string"?p+=":"+h:typeof h=="symbol"&&(p=void 0);function ae(c){var g=(s[c]||"silent").toUpperCase();if(!(typeof window===t||!p)){try{window.localStorage[p]=g;return}catch{}try{window.document.cookie=encodeURIComponent(p)+"="+g+";"}catch{}}}function z(){var c;if(!(typeof window===t||!p)){try{c=window.localStorage[p]}catch{}if(typeof c===t)try{var g=window.document.cookie,O=encodeURIComponent(p),W=g.indexOf(O+"=");W!==-1&&(c=/^([^;]+)/.exec(g.slice(W+O.length+1))[1])}catch{}return l.levels[c]===void 0&&(c=void 0),c}}function ue(){if(!(typeof window===t||!p)){try{window.localStorage.removeItem(p)}catch{}try{window.document.cookie=encodeURIComponent(p)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}function E(c){var g=c;if(typeof g=="string"&&l.levels[g.toUpperCase()]!==void 0&&(g=l.levels[g.toUpperCase()]),typeof g=="number"&&g>=0&&g<=l.levels.SILENT)return g;throw new TypeError("log.setLevel() called with invalid level: "+c)}l.name=h,l.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},l.methodFactory=f||y,l.getLevel=function(){return L??U??I},l.setLevel=function(c,g){return L=E(c),g!==!1&&ae(L),m.call(l)},l.setDefaultLevel=function(c){U=E(c),z()||l.setLevel(c,!1)},l.resetLevel=function(){L=null,ue(),m.call(l)},l.enableAll=function(c){l.setLevel(l.levels.TRACE,c)},l.disableAll=function(c){l.setLevel(l.levels.SILENT,c)},l.rebuild=function(){if(a!==l&&(I=E(a.getLevel())),m.call(l),a===l)for(var c in i)i[c].rebuild()},I=E(a?a.getLevel():"WARN");var K=z();K!=null&&(L=E(K)),m.call(l)}a=new H,a.getLogger=function(f){if(typeof f!="symbol"&&typeof f!="string"||f==="")throw new TypeError("You must supply a name when creating a logger.");var l=i[f];return l||(l=i[f]=new H(f,a.methodFactory)),l};var le=typeof window!==t?window.log:void 0;return a.noConflict=function(){return typeof window!==t&&window.log===a&&(window.log=le),a},a.getLoggers=function(){return i},a.default=a,a})})(D);var G=D.exports;const ee=M({__proto__:null,default:Q(G)},[G]),te=!0,C=ee;C.setLevel("debug");const re=r=>{try{C.setLevel(r)}catch(e){C.setLevel("error"),C.error(e)}};function k(r){return r===null||typeof r!="object"?r:Array.isArray(r)?[...r]:{...r}}function N(r){if(r===null||typeof r!="object")return r;if(r instanceof Date)return new Date(r.getTime());if(r instanceof RegExp)return new RegExp(r.source,r.flags);if(Array.isArray(r))return r.map(N);const e={};for(const t in r)Object.prototype.hasOwnProperty.call(r,t)&&(e[t]=N(r[t]));return e}function F(r,...e){for(const t of e)if(t)for(const n in t)Object.prototype.hasOwnProperty.call(t,n)&&r[n]===void 0&&(r[n]=t[n]);return r}function q(r,e){return r!=null&&Object.prototype.hasOwnProperty.call(r,e)}function j(r){return r==null?!0:Array.isArray(r)||typeof r=="string"?r.length===0:r instanceof Map||r instanceof Set?r.size===0:typeof r=="object"?Object.keys(r).length===0:!1}function B(r,e){if(r===e)return!0;if(r==null||e==null)return r===e;if(typeof r!=typeof e)return!1;if(typeof r!="object")return r===e;if(Array.isArray(r)!==Array.isArray(e))return!1;if(Array.isArray(r)){if(r.length!==e.length)return!1;for(let s=0;s<r.length;s++)if(!B(r[s],e[s]))return!1;return!0}const t=Object.keys(r),n=Object.keys(e);if(t.length!==n.length)return!1;for(const s of t)if(!Object.prototype.hasOwnProperty.call(e,s)||!B(r[s],e[s]))return!1;return!0}class S{constructor(e,t){this.events={attrChanged:new R,modelChanged:new R},this._changing=!1,this._previousAttributes={},this._pending=!1;const n=e||{};t&&F(n,t),this.attributes=n,this.changed={}}get(e){return this.attributes[e]}set(e,t,n){if(e==null)return this;let s;typeof e=="object"?(s=e,n=t):(s={},s[e]=t),n||(n={});const i=n.unset,a=n.silent,d=[],A=this._changing;this._changing=!0,A||(this._previousAttributes=k(this.attributes),this.changed={});const b=this.attributes,m=this.changed,P=this._previousAttributes;for(const y in s)t=s[y],B(b[y],t)||d.push(y),B(P[y],t)?delete m[y]:m[y]=t,i?delete b[y]:b[y]=t;if(!a){d.length&&(this._pending=n);for(let y=0;y<d.length;y++)this.events.attrChanged.dispatch({object:this,attrName:d[y],attrValue:b[d[y]],options:n})}if(A)return this;if(!a)for(;this._pending;)n=this._pending,this._pending=!1,this.events.modelChanged.dispatch({object:this,options:n});return this._pending=!1,this._changing=!1,this}has(e){return this.get(e)!=null}hasChanged(e){return e==null?!j(this.changed):q(this.changed,e)}changedAttributes(e){if(!e)return this.hasChanged()?k(this.changed):{};const t=this._changing?this._previousAttributes:this.attributes,n={};for(const s in e){const i=e[s];B(t[s],i)||(n[s]=i)}return n}previous(e){return e==null||!this._previousAttributes?null:this._previousAttributes[e]}previousAttributes(){return k(this._previousAttributes)}clone(){const e=k(this.attributes);return new S(e)}}class w{constructor(){this.entries=new Map}static getInstance(){return w.instance||(w.instance=new w),w.instance}collect(e){this.entries.set(e.name,e)}printAll(){for(const[e,t]of this.entries)console.log(`${e}:`),console.log(t.format())}clear(){this.entries.clear()}getAll(){return Array.from(this.entries.values())}getEntry(e){return this.entries.get(e)}remove(e){return this.entries.delete(e)}}class ne{static formatBytes(e,t=2){if(e===0)return"0 B";const n=1024,s=Math.max(0,t),i=["B","KB","MB","GB","TB"],a=Math.floor(Math.log(e)/Math.log(n)),d=e/Math.pow(n,a);return`${parseFloat(d.toFixed(s))} ${i[a]}`}}class se{constructor(e){this.name=e}run(e){throw new Error("run() must be implemented by subclass")}}class oe{constructor(){this.tasks=[],this.onProgress=()=>{},this.onComplete=()=>{},this.onError=()=>!1}scheduleTask(e){return new Promise((t,n)=>{const s=()=>{Promise.resolve(e()).then(t).catch(n)};typeof window<"u"&&typeof window.requestAnimationFrame=="function"?window.requestAnimationFrame(s):setTimeout(s,0)})}addTask(e){this.tasks.push(e)}setProgressCallback(e){this.onProgress=e}setCompleteCallback(e){this.onComplete=e}setErrorCallback(e){this.onError=e}async run(e){const t=this.tasks.length;let n=e;for(let s=0;s<t;s++){const i=this.tasks[s];try{n=await this.scheduleTask(async()=>{const a=await i.run(n);return this.onProgress((s+1)/t,i),a})}catch(a){if(this.onError({error:a,taskIndex:s,task:i}))break}}this.onComplete(n)}}class ${constructor(e,t,n){this.isLoading=!1,this.itemsLoaded=0,this.itemsTotal=0,this.urlModifier=void 0,this.handlers=[],this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n}itemStart(e){this.itemsTotal++,this.isLoading===!1&&this.onStart!==void 0&&this.onStart(e,this.itemsLoaded,this.itemsTotal),this.isLoading=!0}itemEnd(e){this.itemsLoaded++,this.onProgress!==void 0&&this.onProgress(e,this.itemsLoaded,this.itemsTotal),this.itemsLoaded===this.itemsTotal&&(this.isLoading=!1,this.onLoad!==void 0&&this.onLoad())}itemError(e){this.onError!==void 0&&this.onError(e)}resolveURL(e){return this.urlModifier?this.urlModifier(e):e}setURLModifier(e){return this.urlModifier=e,this}addHandler(e,t){return this.handlers.push(e,t),this}removeHandler(e){const t=this.handlers.indexOf(e);return t!==-1&&this.handlers.splice(t,2),this}getHandler(e){for(let t=0,n=this.handlers.length;t<n;t+=2){const s=this.handlers[t],i=this.handlers[t+1];if(s.global&&(s.lastIndex=0),s.test(e))return i}return null}}const V=new $;class ie{constructor(e){this.manager=e!==void 0?e:V,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}loadAsync(e,t){return new Promise((n,s)=>{this.load(e,n,t,s)})}parse(e){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}}u.AcCmColor=v,u.AcCmColorMethod=o,u.AcCmColorUtil=_,u.AcCmEntityColor=Y,u.AcCmErrors=Z,u.AcCmEventDispatcher=J,u.AcCmEventManager=R,u.AcCmLoader=ie,u.AcCmLoadingManager=$,u.AcCmObject=S,u.AcCmPerformanceCollector=w,u.AcCmTask=se,u.AcCmTaskScheduler=oe,u.AcTrStringUtil=ne,u.DEBUG_MODE=te,u.DefaultLoadingManager=V,u.clone=k,u.deepClone=N,u.defaults=F,u.has=q,u.isEmpty=j,u.isEqual=B,u.log=C,u.setLogLevel=re,Object.defineProperty(u,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(h,E){typeof exports=="object"&&typeof module<"u"?E(exports):typeof define=="function"&&define.amd?define(["exports"],E):(h=typeof globalThis<"u"?globalThis:h||self,E(h.common={}))})(this,function(h){"use strict";function E(r,e){for(var t=0;t<e.length;t++){const n=e[t];if(typeof n!="string"&&!Array.isArray(n)){for(const s in n)if(s!=="default"&&!(s in r)){const i=Object.getOwnPropertyDescriptor(n,s);i&&Object.defineProperty(r,s,i.get?i:{enumerable:!0,get:()=>n[s]})}}}return Object.freeze(Object.defineProperty(r,Symbol.toStringTag,{value:"Module"}))}var o=(r=>(r[r.ByColor=1]="ByColor",r[r.ByACI=2]="ByACI",r[r.ByLayer=3]="ByLayer",r[r.ByBlock=4]="ByBlock",r[r.None=0]="None",r))(o||{});const G={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},S=[0,16711680,16776960,65280,65535,255,16711935,16777215,8421504,12632256,16711680,16744319,13369344,13395558,10027008,10046540,8323072,8339263,4980736,4990502,16727808,16752511,13382400,13401958,10036736,10051404,8331008,8343359,4985600,4992806,16744192,16760703,13395456,13408614,10046464,10056268,8339200,8347455,4990464,4995366,16760576,16768895,13408512,13415014,10056192,10061132,8347392,8351551,4995328,4997670,16776960,16777087,13421568,13421670,10000384,10000460,8355584,8355647,5000192,5000230,12582656,14679935,10079232,11717734,7510016,8755276,6258432,7307071,3755008,4344870,8388352,12582783,6736896,10079334,5019648,7510092,4161280,6258495,2509824,3755046,4194048,10485631,3394560,8375398,2529280,6264908,2064128,5209919,1264640,3099686,65280,8388479,52224,6736998,38912,5019724,32512,4161343,19456,2509862,65343,8388511,52275,6737023,38950,5019743,32543,4161359,19475,2509871,65407,8388543,52326,6737049,38988,5019762,32575,4161375,19494,2509881,65471,8388575,52377,6737074,39026,5019781,32607,4161391,19513,2509890,65535,8388607,52428,6737100,39064,5019800,32639,4161407,19532,2509900,49151,8380415,39372,6730444,29336,5014936,24447,4157311,14668,2507340,32767,8372223,26316,6724044,19608,5010072,16255,4153215,9804,2505036,16383,8364031,13260,6717388,9880,5005208,8063,4149119,4940,2502476,255,8355839,204,6710988,152,5000344,127,4145023,76,2500172,4129023,10452991,3342540,8349388,2490520,6245528,2031743,5193599,1245260,3089996,8323327,12550143,6684876,10053324,4980888,7490712,4128895,6242175,2490444,3745356,12517631,14647295,10027212,11691724,7471256,8735896,6226047,7290751,3735628,4335180,16711935,16744447,13369548,13395660,9961624,9981080,8323199,8339327,4980812,4990540,16711871,16744415,13369497,13395634,9961586,9981061,8323167,8339311,4980793,4990530,16711807,16744383,13369446,13395609,9961548,9981042,8323135,8339295,4980774,4990521,16711743,16744351,13369395,13395583,9961510,9981023,8323103,8339279,4980755,4990511,3355443,5987163,8684676,11382189,14079702,16777215,0];class w{static getColorByIndex(e){return S[e]}static getIndexByColor(e){const t=S.length-1;for(let n=1;n<t;++n)if(S[n]===e)return n}static getColorByName(e){return G[e.toLowerCase()]}static getNameByColor(e){for(const[t,n]of Object.entries(G))if(n===e)return t}static getNameByIndex(e){const t=this.getColorByIndex(e);return this.getNameByColor(t)}}class _{constructor(e=o.ByLayer,t){this._colorMethod=e,this._colorMethod==o.ByColor&&t==null?this._value=16777215:this._colorMethod==o.ByACI?t==null?this._value=8:t===0?this._colorMethod=o.ByBlock:t===256?this._colorMethod=o.ByLayer:this._value=Math.max(0,Math.min(t,256)):this._value=t}get colorMethod(){return this._colorMethod}set colorMethod(e){this._colorMethod=e}get red(){const e=this.RGB;return e!=null?e>>16&255:void 0}get green(){const e=this.RGB;return e!=null?e>>8&255:void 0}get blue(){const e=this.RGB;return e!=null?e&255:void 0}get RGB(){switch(this._colorMethod){case o.ByColor:case o.ByBlock:case o.ByLayer:return this._value;case o.ByACI:return this._value?w.getColorByIndex(this._value):this._value;default:return}}setRGB(e,t,n){const s=Math.max(0,Math.min(255,Math.round(e))),i=Math.max(0,Math.min(255,Math.round(t))),a=Math.max(0,Math.min(255,Math.round(n)));return this._value=s<<16|i<<8|a,this._colorMethod=o.ByColor,this}setRGBValue(e){return e==null||!Number.isFinite(e)?(console.warn("Invalid RGB value:",e),this):(this._value=e&16777215,this._colorMethod=o.ByColor,this)}setRGBFromCss(e){if(!e)return this;const t=e.trim().toLowerCase();if(t.startsWith("#")){let i=0,a=0,d=0;if(t.length===7)i=parseInt(t.substr(1,2),16),a=parseInt(t.substr(3,2),16),d=parseInt(t.substr(5,2),16);else if(t.length===4)i=parseInt(t[1]+t[1],16),a=parseInt(t[2]+t[2],16),d=parseInt(t[3]+t[3],16);else return console.warn("Invalid hex color:",e),this;return this.setRGB(i,a,d)}const n=t.match(/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);if(n){const i=parseInt(n[1],10),a=parseInt(n[2],10),d=parseInt(n[3],10);return this.setRGB(i,a,d)}const s=w.getColorByName(e);return s!==void 0?this.setRGBValue(s):(console.warn("Unknown CSS color string:",e),this)}setScalar(e){return this.setRGB(e,e,e)}get hexColor(){const e=this.RGB;return e==null?void 0:"0x"+e.toString(16).padStart(6,"0").toUpperCase()}get cssColor(){const e=this.RGB;if(e!=null)return`rgb(${e>>16&255},${e>>8&255},${e&255})`}get colorIndex(){return this._colorMethod===o.ByACI?this._value:this._colorMethod===o.ByLayer?256:this._colorMethod===o.ByBlock?0:void 0}set colorIndex(e){if(e==null)return;const t=Math.max(0,Math.min(256,Math.round(e)));t===0?(this._colorMethod=o.ByBlock,this._value=void 0):t===256?(this._colorMethod=o.ByLayer,this._value=void 0):(this._colorMethod=o.ByACI,this._value=t)}get isByColor(){return this._colorMethod===o.ByColor}get isByACI(){return this._colorMethod===o.ByACI}get isByLayer(){return this._colorMethod===o.ByLayer}setByLayer(e){return this._colorMethod=o.ByLayer,e==null?this._value=256:this._value=e,this}get isByBlock(){return this._colorMethod===o.ByBlock}setByBlock(e){return this._colorMethod=o.ByBlock,e==null?this._value=0:this._value=e,this}get colorName(){switch(this._colorMethod){case o.ByLayer:return"ByLayer";case o.ByBlock:return"ByBlock";case o.ByColor:return this._value?w.getNameByColor(this._value):"";case o.ByACI:return this._value?w.getNameByIndex(this._value):"";default:return}}set colorName(e){if(!e)return;const t=w.getColorByName(e);t!==void 0?(this._value=t,this._colorMethod=o.ByColor):console.warn("Unknown color name:",e)}clone(){const e=new _;return e._colorMethod=this._colorMethod,e._value=this._value,e}copy(e){return this._colorMethod=e._colorMethod,this._value=e._value,this}equals(e){return this._colorMethod===e._colorMethod&&this._value===e._value}toString(){switch(this._colorMethod){case o.ByLayer:return"ByLayer";case o.ByBlock:return"ByBlock";case o.ByACI:return this._value!==void 0?String(this._value):"";case o.ByColor:return this._value?`${this.red},${this.green},${this.blue}`:"";default:return""}}static fromString(e){if(!e)return;const t=e.trim();if(/^bylayer$/i.test(t))return new _(o.ByLayer);if(/^byblock$/i.test(t))return new _(o.ByBlock);if(/^\d{1,3},\d{1,3},\d{1,3}$/i.test(t)){const[s,i,a]=t.split(",").map(Number),d=new _(o.ByColor);return d.setRGB(s,i,a),d}if(/^\d+$/.test(t)){const s=parseInt(t,10);return new _(o.ByACI,s)}const n=w.getColorByName(t);if(n!=null)return new _(o.ByColor,n);console.warn("Unknown color name:",e)}}class J{constructor(e=o.ByColor,t=0){this._colorMethod=e,this._value=t}get colorMethd(){return this._colorMethod}get red(){return this._value>>16&255}set red(e){this._colorMethod=o.ByColor,this._value=this._value&65535|(e&255)<<16}get green(){return this._value>>8&255}set green(e){this._colorMethod=o.ByColor,this._value=this._value&16711935|(e&255)<<8}get blue(){return this._value&255}set blue(e){this._colorMethod=o.ByColor,this._value=this._value&16776960|e&255}setRGB(e,t,n){this._colorMethod=o.ByColor,this._value=(e&255)<<16|(t&255)<<8|n&255}get colorIndex(){return this._value}set colorIndex(e){this._colorMethod=o.ByACI,this._value=e}get layerIndex(){return this._value}set layerIndex(e){this._colorMethod=o.ByLayer,this._value=e}isByColor(){return this._colorMethod===o.ByColor}isByLayer(){return this._colorMethod===o.ByLayer}isByBlock(){return this._colorMethod===o.ByBlock}isByACI(){return this._colorMethod===o.ByACI}isNone(){return this._colorMethod===o.None}get rawValue(){return this._value}set rawValue(e){this._value=e}}const X={get ILLEGAL_PARAMETERS(){return new ReferenceError("Illegal Parameters")},get ZERO_DIVISION(){return new Error("Zero division")},get UNRESOLVED_BOUNDARY_CONFLICT(){return new Error("Unresolved boundary conflict in boolean operation")},get INFINITE_LOOP(){return new Error("Infinite loop")},get CANNOT_INVOKE_ABSTRACT_METHOD(){return new Error("Abstract method cannot be invoked")},get OPERATION_IS_NOT_SUPPORTED(){return new Error("Operation is not supported")},get NOT_IMPLEMENTED(){return new Error("Not implemented yet")}};class Q{constructor(){this._listeners={}}addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){if(this._listeners===void 0)return!1;const n=this._listeners;return n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){if(this._listeners===void 0)return;const s=this._listeners[e];if(s!==void 0){const i=s.indexOf(t);i!==-1&&s.splice(i,1)}}dispatchEvent(e){if(this._listeners===void 0)return;const n=this._listeners[e.type];if(n!==void 0){e.target=this;const s=n.slice(0);for(let i=0,a=s.length;i<a;i++)s[i].call(this,e)}}}class T{constructor(){this.listeners=[]}addEventListener(e){this.listeners.push(e)}removeEventListener(e){this.listeners=this.listeners.filter(t=>t!==e)}replaceEventListener(e){this.removeEventListener(e),this.addEventListener(e)}dispatch(e,...t){for(const n of this.listeners)n.call(null,e,...t)}}function C(r){return r===null||typeof r!="object"?r:Array.isArray(r)?[...r]:{...r}}function P(r){if(r===null||typeof r!="object")return r;if(r instanceof Date)return new Date(r.getTime());if(r instanceof RegExp)return new RegExp(r.source,r.flags);if(Array.isArray(r))return r.map(P);const e={};for(const t in r)Object.prototype.hasOwnProperty.call(r,t)&&(e[t]=P(r[t]));return e}function q(r,...e){for(const t of e)if(t)for(const n in t)Object.prototype.hasOwnProperty.call(t,n)&&r[n]===void 0&&(r[n]=t[n]);return r}function F(r,e){return r!=null&&Object.prototype.hasOwnProperty.call(r,e)}function j(r){return r==null?!0:Array.isArray(r)||typeof r=="string"?r.length===0:r instanceof Map||r instanceof Set?r.size===0:typeof r=="object"?Object.keys(r).length===0:!1}function b(r,e){if(r===e)return!0;if(r==null||e==null)return r===e;if(typeof r!=typeof e)return!1;if(typeof r!="object")return r===e;if(Array.isArray(r)!==Array.isArray(e))return!1;if(Array.isArray(r)){if(r.length!==e.length)return!1;for(let s=0;s<r.length;s++)if(!b(r[s],e[s]))return!1;return!0}const t=Object.keys(r),n=Object.keys(e);if(t.length!==n.length)return!1;for(const s of t)if(!Object.prototype.hasOwnProperty.call(e,s)||!b(r[s],e[s]))return!1;return!0}var ee=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function te(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var $={exports:{}};(function(r){(function(e,t){r.exports?r.exports=t():e.log=t()})(ee,function(){var e=function(){},t="undefined",n=typeof window!==t&&typeof window.navigator!==t&&/Trident\/|MSIE /.test(window.navigator.userAgent),s=["trace","debug","info","warn","error"],i={},a=null;function d(u,g){var l=u[g];if(typeof l.bind=="function")return l.bind(u);try{return Function.prototype.bind.call(l,u)}catch{return function(){return Function.prototype.apply.apply(l,[u,arguments])}}}function O(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function M(u){return u==="debug"&&(u="log"),typeof console===t?!1:u==="trace"&&n?O:console[u]!==void 0?d(console,u):console.log!==void 0?d(console,"log"):e}function B(){for(var u=this.getLevel(),g=0;g<s.length;g++){var l=s[g];this[l]=g<u?e:this.methodFactory(l,u,this.name)}if(this.log=this.debug,typeof console===t&&u<this.levels.SILENT)return"No console available for logging"}function x(u){return function(){typeof console!==t&&(B.call(this),this[u].apply(this,arguments))}}function p(u,g,l){return M(u)||x.apply(this,arguments)}function K(u,g){var l=this,R,D,k,m="loglevel";typeof u=="string"?m+=":"+u:typeof u=="symbol"&&(m=void 0);function ue(c){var f=(s[c]||"silent").toUpperCase();if(!(typeof window===t||!m)){try{window.localStorage[m]=f;return}catch{}try{window.document.cookie=encodeURIComponent(m)+"="+f+";"}catch{}}}function W(){var c;if(!(typeof window===t||!m)){try{c=window.localStorage[m]}catch{}if(typeof c===t)try{var f=window.document.cookie,N=encodeURIComponent(m),Z=f.indexOf(N+"=");Z!==-1&&(c=/^([^;]+)/.exec(f.slice(Z+N.length+1))[1])}catch{}return l.levels[c]===void 0&&(c=void 0),c}}function ce(){if(!(typeof window===t||!m)){try{window.localStorage.removeItem(m)}catch{}try{window.document.cookie=encodeURIComponent(m)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}function A(c){var f=c;if(typeof f=="string"&&l.levels[f.toUpperCase()]!==void 0&&(f=l.levels[f.toUpperCase()]),typeof f=="number"&&f>=0&&f<=l.levels.SILENT)return f;throw new TypeError("log.setLevel() called with invalid level: "+c)}l.name=u,l.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},l.methodFactory=g||p,l.getLevel=function(){return k??D??R},l.setLevel=function(c,f){return k=A(c),f!==!1&&ue(k),B.call(l)},l.setDefaultLevel=function(c){D=A(c),W()||l.setLevel(c,!1)},l.resetLevel=function(){k=null,ce(),B.call(l)},l.enableAll=function(c){l.setLevel(l.levels.TRACE,c)},l.disableAll=function(c){l.setLevel(l.levels.SILENT,c)},l.rebuild=function(){if(a!==l&&(R=A(a.getLevel())),B.call(l),a===l)for(var c in i)i[c].rebuild()},R=A(a?a.getLevel():"WARN");var Y=W();Y!=null&&(k=A(Y)),B.call(l)}a=new K,a.getLogger=function(g){if(typeof g!="symbol"&&typeof g!="string"||g==="")throw new TypeError("You must supply a name when creating a logger.");var l=i[g];return l||(l=i[g]=new K(g,a.methodFactory)),l};var he=typeof window!==t?window.log:void 0;return a.noConflict=function(){return typeof window!==t&&window.log===a&&(window.log=he),a},a.getLoggers=function(){return i},a.default=a,a})})($);var V=$.exports;const re=E({__proto__:null,default:te(V)},[V]),ne=!0,I=re;I.setLevel("debug");const se=r=>{try{I.setLevel(r)}catch(e){I.setLevel("error"),I.error(e)}};class U{constructor(e,t){this.events={attrChanged:new T,modelChanged:new T},this._changing=!1,this._previousAttributes={},this._pending=!1;const n=e||{};t&&q(n,t),this.attributes=n,this.changed={}}get(e){return this.attributes[e]}set(e,t,n){if(e==null)return this;let s;typeof e=="object"?(s=e,n=t):(s={},s[e]=t),n||(n={});const i=n.unset,a=n.silent,d=[],O=this._changing;this._changing=!0,O||(this._previousAttributes=C(this.attributes),this.changed={});const M=this.attributes,B=this.changed,x=this._previousAttributes;for(const p in s)t=s[p],b(M[p],t)||d.push(p),b(x[p],t)?delete B[p]:B[p]=t,i?delete M[p]:M[p]=t;if(!a){d.length&&(this._pending=n);for(let p=0;p<d.length;p++)this.events.attrChanged.dispatch({object:this,attrName:d[p],attrValue:M[d[p]],options:n})}if(O)return this;if(!a)for(;this._pending;)n=this._pending,this._pending=!1,this.events.modelChanged.dispatch({object:this,options:n});return this._pending=!1,this._changing=!1,this}has(e){return this.get(e)!=null}hasChanged(e){return e==null?!j(this.changed):F(this.changed,e)}changedAttributes(e){if(!e)return this.hasChanged()?C(this.changed):{};const t=this._changing?this._previousAttributes:this.attributes,n={};for(const s in e){const i=e[s];b(t[s],i)||(n[s]=i)}return n}previous(e){return e==null||!this._previousAttributes?null:this._previousAttributes[e]}previousAttributes(){return C(this._previousAttributes)}clone(){const e=C(this.attributes);return new U(e)}}class L{constructor(){this.entries=new Map}static getInstance(){return L.instance||(L.instance=new L),L.instance}collect(e){this.entries.set(e.name,e)}printAll(){for(const[e,t]of this.entries)console.log(`${e}:`),console.log(t.format())}clear(){this.entries.clear()}getAll(){return Array.from(this.entries.values())}getEntry(e){return this.entries.get(e)}remove(e){return this.entries.delete(e)}}class oe{static formatBytes(e,t=2){if(e===0)return"0 B";const n=1024,s=Math.max(0,t),i=["B","KB","MB","GB","TB"],a=Math.floor(Math.log(e)/Math.log(n)),d=e/Math.pow(n,a);return`${parseFloat(d.toFixed(s))} ${i[a]}`}}var y=(r=>(r[r.ByLayer=0]="ByLayer",r[r.ByBlock=1]="ByBlock",r[r.ByAlpha=2]="ByAlpha",r[r.ErrorValue=3]="ErrorValue",r))(y||{});class v{constructor(e){e!==void 0?(this._method=y.ByAlpha,this._alpha=v.clampAlpha(e)):(this._method=y.ByLayer,this._alpha=255)}get method(){return this._method}set method(e){this._method=e}get alpha(){return this._alpha}set alpha(e){this._alpha=v.clampAlpha(e),this._method=y.ByAlpha}get percentage(){if(this._method===y.ByAlpha)return Math.round((1-this._alpha/255)*100)}set percentage(e){const t=Math.max(0,Math.min(100,e)),n=Math.round(255*(1-t/100));this.alpha=n}static clampAlpha(e){return Math.max(0,Math.min(255,Math.floor(e)))}get isByAlpha(){return this._method===y.ByAlpha}get isByBlock(){return this._method===y.ByBlock}get isByLayer(){return this._method===y.ByLayer}get isClear(){return this.isByAlpha&&this._alpha===0}get isSolid(){return this.isByAlpha&&this._alpha===255}get isInvalid(){return this._method===y.ErrorValue}serialize(){return this._method<<24|this._alpha}clone(){const e=new v;return e._method=this._method,e._alpha=this._alpha,e}equals(e){return this._method===e._method&&this._alpha===e._alpha}toString(){return this.isByLayer?"ByLayer":this.isByBlock?"ByBlock":this._alpha.toString()}static fromString(e){const t=e.trim();if(/^bylayer$/i.test(t)){const i=new v;return i._method=y.ByLayer,i}if(/^byblock$/i.test(t)){const i=new v;return i._method=y.ByBlock,i}const n=Number(t);if(Number.isInteger(n)&&n>=0&&n<=255)return new v(n);const s=new v;return s._method=y.ErrorValue,s}static deserialize(e){const t=e>>>24&255,n=e&255,s=Object.values(y)[t]??y.ErrorValue,i=new v;return i._method=s,i._alpha=v.clampAlpha(n),i}}class ie{constructor(e){this.name=e}run(e){throw new Error("run() must be implemented by subclass")}}class le{constructor(){this.tasks=[],this.onProgress=()=>{},this.onComplete=()=>{},this.onError=()=>!1}scheduleTask(e){return new Promise((t,n)=>{const s=()=>{Promise.resolve(e()).then(t).catch(n)};typeof window<"u"&&typeof window.requestAnimationFrame=="function"?window.requestAnimationFrame(s):setTimeout(s,0)})}addTask(e){this.tasks.push(e)}setProgressCallback(e){this.onProgress=e}setCompleteCallback(e){this.onComplete=e}setErrorCallback(e){this.onError=e}async run(e){const t=this.tasks.length;let n=e;for(let s=0;s<t;s++){const i=this.tasks[s];try{n=await this.scheduleTask(async()=>{const a=await i.run(n);return this.onProgress((s+1)/t,i),a})}catch(a){if(this.onError({error:a,taskIndex:s,task:i}))break}}this.onComplete(n)}}class z{constructor(e,t,n){this.isLoading=!1,this.itemsLoaded=0,this.itemsTotal=0,this.urlModifier=void 0,this.handlers=[],this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n}itemStart(e){this.itemsTotal++,this.isLoading===!1&&this.onStart!==void 0&&this.onStart(e,this.itemsLoaded,this.itemsTotal),this.isLoading=!0}itemEnd(e){this.itemsLoaded++,this.onProgress!==void 0&&this.onProgress(e,this.itemsLoaded,this.itemsTotal),this.itemsLoaded===this.itemsTotal&&(this.isLoading=!1,this.onLoad!==void 0&&this.onLoad())}itemError(e){this.onError!==void 0&&this.onError(e)}resolveURL(e){return this.urlModifier?this.urlModifier(e):e}setURLModifier(e){return this.urlModifier=e,this}addHandler(e,t){return this.handlers.push(e,t),this}removeHandler(e){const t=this.handlers.indexOf(e);return t!==-1&&this.handlers.splice(t,2),this}getHandler(e){for(let t=0,n=this.handlers.length;t<n;t+=2){const s=this.handlers[t],i=this.handlers[t+1];if(s.global&&(s.lastIndex=0),s.test(e))return i}return null}}const H=new z;class ae{constructor(e){this.manager=e!==void 0?e:H,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}loadAsync(e,t){return new Promise((n,s)=>{this.load(e,n,t,s)})}parse(e){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}}h.AcCmColor=_,h.AcCmColorMethod=o,h.AcCmColorUtil=w,h.AcCmEntityColor=J,h.AcCmErrors=X,h.AcCmEventDispatcher=Q,h.AcCmEventManager=T,h.AcCmLoader=ae,h.AcCmLoadingManager=z,h.AcCmObject=U,h.AcCmPerformanceCollector=L,h.AcCmTask=ie,h.AcCmTaskScheduler=le,h.AcCmTransparency=v,h.AcCmTransparencyMethod=y,h.AcTrStringUtil=oe,h.DEBUG_MODE=ne,h.DefaultLoadingManager=H,h.clone=C,h.deepClone=P,h.defaults=q,h.has=F,h.isEmpty=j,h.isEqual=b,h.log=I,h.setLogLevel=se,Object.defineProperty(h,Symbol.toStringTag,{value:"Module"})});
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import { AcCmTransparencyMethod } from './AcCmTransparencyMethod';
|
|
2
|
+
/**
|
|
3
|
+
* Class representing transparency similar to AutoCAD’s `AcCmTransparency`.
|
|
4
|
+
*
|
|
5
|
+
* Stores both method and alpha information.
|
|
6
|
+
*/
|
|
7
|
+
export declare class AcCmTransparency {
|
|
8
|
+
/** The transparency interpretation method. */
|
|
9
|
+
private _method;
|
|
10
|
+
/**
|
|
11
|
+
* Alpha value in range 0–255 where:
|
|
12
|
+
* - 0 is fully transparent
|
|
13
|
+
* - 255 is fully opaque
|
|
14
|
+
*
|
|
15
|
+
* Only valid when the method is `ByAlpha`.
|
|
16
|
+
*/
|
|
17
|
+
private _alpha;
|
|
18
|
+
/**
|
|
19
|
+
* Creates a new transparency object.
|
|
20
|
+
*
|
|
21
|
+
* @param alpha
|
|
22
|
+
* When provided, constructs with `ByAlpha` method and sets alpha.
|
|
23
|
+
* Must be between 0 and 255.
|
|
24
|
+
*/
|
|
25
|
+
constructor(alpha?: number);
|
|
26
|
+
/** Gets the current transparency method */
|
|
27
|
+
get method(): AcCmTransparencyMethod;
|
|
28
|
+
/**
|
|
29
|
+
* Sets the transparency method.
|
|
30
|
+
* If setting to ByAlpha with no prior alpha, alpha stays 255 (opaque).
|
|
31
|
+
*
|
|
32
|
+
* @param method The new transparency method
|
|
33
|
+
*/
|
|
34
|
+
set method(method: AcCmTransparencyMethod);
|
|
35
|
+
/**
|
|
36
|
+
* Gets the alpha value.
|
|
37
|
+
* Only meaningful if `method === ByAlpha`.
|
|
38
|
+
*/
|
|
39
|
+
get alpha(): number;
|
|
40
|
+
/**
|
|
41
|
+
* Sets the alpha value and force the method to `ByAlpha`.
|
|
42
|
+
*
|
|
43
|
+
* @param alpha 0–255 alpha, clamped internally if out of range
|
|
44
|
+
*/
|
|
45
|
+
set alpha(alpha: number);
|
|
46
|
+
/**
|
|
47
|
+
* Gets the AutoCAD-style transparency percentage.
|
|
48
|
+
*
|
|
49
|
+
* Mapping rules:
|
|
50
|
+
* - 0% = fully opaque (alpha = 255)
|
|
51
|
+
* - 100% = fully transparent (alpha = 0)
|
|
52
|
+
*
|
|
53
|
+
* This matches how AutoCAD displays and stores transparency
|
|
54
|
+
* values in UI and DXF files.
|
|
55
|
+
*
|
|
56
|
+
* If the transparency method is not `ByAlpha`,
|
|
57
|
+
* this method returns `undefined`, because AutoCAD
|
|
58
|
+
* does not define a percentage for ByLayer or ByBlock.
|
|
59
|
+
*
|
|
60
|
+
* @returns Transparency percentage (0–100), or undefined
|
|
61
|
+
*/
|
|
62
|
+
get percentage(): number | undefined;
|
|
63
|
+
/**
|
|
64
|
+
* Sets the transparency using an AutoCAD-style percentage.
|
|
65
|
+
*
|
|
66
|
+
* Mapping rules (AutoCAD compatible):
|
|
67
|
+
* - 0% → fully opaque (alpha = 255)
|
|
68
|
+
* - 100% → fully transparent (alpha = 0)
|
|
69
|
+
*
|
|
70
|
+
* Internally, the alpha value is calculated as:
|
|
71
|
+
* alpha = round(255 × (1 − percentage / 100))
|
|
72
|
+
*
|
|
73
|
+
* This method:
|
|
74
|
+
* - Forces the transparency method to `ByAlpha`
|
|
75
|
+
* - Clamps the percentage to the range 0–100
|
|
76
|
+
* - Preserves ObjectARX value semantics
|
|
77
|
+
*
|
|
78
|
+
* @param percentage Transparency percentage (0–100)
|
|
79
|
+
* @returns This instance (for fluent chaining)
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* const t = new AcCmTransparency();
|
|
83
|
+
* t.setPercentage(50); // ≈ alpha 128
|
|
84
|
+
*
|
|
85
|
+
* t.setPercentage(0); // alpha = 255 (opaque)
|
|
86
|
+
* t.setPercentage(100); // alpha = 0 (clear)
|
|
87
|
+
*/
|
|
88
|
+
set percentage(percentage: number);
|
|
89
|
+
/**
|
|
90
|
+
* Ensures alpha always stays within 0–255.
|
|
91
|
+
*/
|
|
92
|
+
private static clampAlpha;
|
|
93
|
+
/**
|
|
94
|
+
* True if the method is `ByAlpha`.
|
|
95
|
+
*/
|
|
96
|
+
get isByAlpha(): boolean;
|
|
97
|
+
/**
|
|
98
|
+
* True if the method is `ByBlock`.
|
|
99
|
+
*/
|
|
100
|
+
get isByBlock(): boolean;
|
|
101
|
+
/**
|
|
102
|
+
* True if the method is `ByLayer`.
|
|
103
|
+
*/
|
|
104
|
+
get isByLayer(): boolean;
|
|
105
|
+
/**
|
|
106
|
+
* True if transparency is exactly clear (alpha==0 and ByAlpha).
|
|
107
|
+
*/
|
|
108
|
+
get isClear(): boolean;
|
|
109
|
+
/**
|
|
110
|
+
* True if transparency is solid (alpha==255 and ByAlpha).
|
|
111
|
+
*/
|
|
112
|
+
get isSolid(): boolean;
|
|
113
|
+
/**
|
|
114
|
+
* True if current state is invalid (ErrorValue).
|
|
115
|
+
*/
|
|
116
|
+
get isInvalid(): boolean;
|
|
117
|
+
/**
|
|
118
|
+
* Convert this transparency to an integer suitable for storage.
|
|
119
|
+
* Uses a simple bit-encoding: highbits for method and lowbits for alpha.
|
|
120
|
+
*
|
|
121
|
+
* 31 24 23 8 7 0
|
|
122
|
+
* +-------------+--------------+------------+
|
|
123
|
+
* | flags | reserved | alpha |
|
|
124
|
+
* +-------------+--------------+------------+
|
|
125
|
+
*/
|
|
126
|
+
serialize(): number;
|
|
127
|
+
/**
|
|
128
|
+
* Creates a deep copy of this transparency object.
|
|
129
|
+
*
|
|
130
|
+
* This mirrors the value-semantics of ObjectARX `AcCmTransparency`,
|
|
131
|
+
* where copying results in an independent object with the same
|
|
132
|
+
* transparency method and alpha value.
|
|
133
|
+
*
|
|
134
|
+
* @returns A new `AcCmTransparency` instance with identical state.
|
|
135
|
+
*/
|
|
136
|
+
clone(): AcCmTransparency;
|
|
137
|
+
/**
|
|
138
|
+
* Compares this transparency with another one for equality.
|
|
139
|
+
*
|
|
140
|
+
* Two `AcCmTransparency` objects are considered equal if:
|
|
141
|
+
* - Their transparency methods are identical
|
|
142
|
+
* - Their alpha values are identical
|
|
143
|
+
*
|
|
144
|
+
* This mirrors the value semantics of ObjectARX
|
|
145
|
+
* `AcCmTransparency`.
|
|
146
|
+
*
|
|
147
|
+
* @param other The transparency to compare with
|
|
148
|
+
* @returns True if both represent the same transparency
|
|
149
|
+
*
|
|
150
|
+
* @example
|
|
151
|
+
* const a = new AcCmTransparency(128);
|
|
152
|
+
* const b = new AcCmTransparency(128);
|
|
153
|
+
* a.equals(b); // true
|
|
154
|
+
*/
|
|
155
|
+
equals(other: AcCmTransparency): boolean;
|
|
156
|
+
/**
|
|
157
|
+
* Returns a human-readable string representation of the transparency.
|
|
158
|
+
*
|
|
159
|
+
* Behavior:
|
|
160
|
+
* - `"ByLayer"` if transparency is inherited from layer
|
|
161
|
+
* - `"ByBlock"` if transparency is inherited from block
|
|
162
|
+
* - Numeric alpha value (`"0"`–`"255"`) if method is `ByAlpha`
|
|
163
|
+
*
|
|
164
|
+
* This format is intentionally simple and mirrors common
|
|
165
|
+
* AutoCAD UI and DXF text usage.
|
|
166
|
+
*
|
|
167
|
+
* @returns String representation of the transparency
|
|
168
|
+
*
|
|
169
|
+
* @example
|
|
170
|
+
* new AcCmTransparency().toString(); // "ByLayer"
|
|
171
|
+
* new AcCmTransparency(128).toString(); // "128"
|
|
172
|
+
*/
|
|
173
|
+
toString(): string;
|
|
174
|
+
/**
|
|
175
|
+
* Creates an `AcCmTransparency` instance from a string representation.
|
|
176
|
+
*
|
|
177
|
+
* Accepted formats:
|
|
178
|
+
* - `"ByLayer"` (case-insensitive)
|
|
179
|
+
* - `"ByBlock"` (case-insensitive)
|
|
180
|
+
* - Numeric alpha value `"0"`–`"255"`
|
|
181
|
+
*
|
|
182
|
+
* Invalid or out-of-range values will produce an
|
|
183
|
+
* `ErrorValue` transparency.
|
|
184
|
+
*
|
|
185
|
+
* @param value String to parse
|
|
186
|
+
* @returns Parsed `AcCmTransparency` instance
|
|
187
|
+
*
|
|
188
|
+
* @example
|
|
189
|
+
* AcCmTransparency.fromString("ByLayer");
|
|
190
|
+
* AcCmTransparency.fromString("128");
|
|
191
|
+
* AcCmTransparency.fromString("ByBlock");
|
|
192
|
+
*/
|
|
193
|
+
static fromString(value: string): AcCmTransparency;
|
|
194
|
+
/**
|
|
195
|
+
* Deserialize an integer back into a transparency object.
|
|
196
|
+
*
|
|
197
|
+
* @param value 32-bit stored transparency representation
|
|
198
|
+
*/
|
|
199
|
+
static deserialize(value: number): AcCmTransparency;
|
|
200
|
+
}
|
|
201
|
+
//# sourceMappingURL=AcCmTransparency.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AcCmTransparency.d.ts","sourceRoot":"","sources":["../src/AcCmTransparency.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAA;AAEjE;;;;GAIG;AACH,qBAAa,gBAAgB;IAC3B,8CAA8C;IAC9C,OAAO,CAAC,OAAO,CAAwB;IAEvC;;;;;;OAMG;IACH,OAAO,CAAC,MAAM,CAAQ;IAEtB;;;;;;OAMG;gBACS,KAAK,CAAC,EAAE,MAAM;IAU1B,2CAA2C;IAC3C,IAAI,MAAM,IAAI,sBAAsB,CAEnC;IAED;;;;;OAKG;IACH,IAAI,MAAM,CAAC,MAAM,EAAE,sBAAsB,EAExC;IAED;;;OAGG;IACH,IAAI,KAAK,IAAI,MAAM,CAElB;IAED;;;;OAIG;IACH,IAAI,KAAK,CAAC,KAAK,EAAE,MAAM,EAGtB;IAED;;;;;;;;;;;;;;;OAeG;IACH,IAAI,UAAU,IAAI,MAAM,GAAG,SAAS,CAMnC;IAED;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACH,IAAI,UAAU,CAAC,UAAU,EAAE,MAAM,EAIhC;IAED;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,UAAU;IAIzB;;OAEG;IACH,IAAI,SAAS,IAAI,OAAO,CAEvB;IAED;;OAEG;IACH,IAAI,SAAS,IAAI,OAAO,CAEvB;IAED;;OAEG;IACH,IAAI,SAAS,IAAI,OAAO,CAEvB;IAED;;OAEG;IACH,IAAI,OAAO,IAAI,OAAO,CAErB;IAED;;OAEG;IACH,IAAI,OAAO,IAAI,OAAO,CAErB;IAED;;OAEG;IACH,IAAI,SAAS,IAAI,OAAO,CAEvB;IAED;;;;;;;;OAQG;IACH,SAAS,IAAI,MAAM;IAKnB;;;;;;;;OAQG;IACH,KAAK,IAAI,gBAAgB;IAOzB;;;;;;;;;;;;;;;;;OAiBG;IACH,MAAM,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO;IAIxC;;;;;;;;;;;;;;;;OAgBG;IACH,QAAQ,IAAI,MAAM;IAMlB;;;;;;;;;;;;;;;;;;OAkBG;IACH,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,gBAAgB;IA0BlD;;;;OAIG;IACH,MAAM,CAAC,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,gBAAgB;CAWpD"}
|
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
import { AcCmTransparencyMethod } from './AcCmTransparencyMethod';
|
|
2
|
+
/**
|
|
3
|
+
* Class representing transparency similar to AutoCAD’s `AcCmTransparency`.
|
|
4
|
+
*
|
|
5
|
+
* Stores both method and alpha information.
|
|
6
|
+
*/
|
|
7
|
+
var AcCmTransparency = /** @class */ (function () {
|
|
8
|
+
/**
|
|
9
|
+
* Creates a new transparency object.
|
|
10
|
+
*
|
|
11
|
+
* @param alpha
|
|
12
|
+
* When provided, constructs with `ByAlpha` method and sets alpha.
|
|
13
|
+
* Must be between 0 and 255.
|
|
14
|
+
*/
|
|
15
|
+
function AcCmTransparency(alpha) {
|
|
16
|
+
if (alpha !== undefined) {
|
|
17
|
+
this._method = AcCmTransparencyMethod.ByAlpha;
|
|
18
|
+
this._alpha = AcCmTransparency.clampAlpha(alpha);
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
this._method = AcCmTransparencyMethod.ByLayer;
|
|
22
|
+
this._alpha = 255;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
Object.defineProperty(AcCmTransparency.prototype, "method", {
|
|
26
|
+
/** Gets the current transparency method */
|
|
27
|
+
get: function () {
|
|
28
|
+
return this._method;
|
|
29
|
+
},
|
|
30
|
+
/**
|
|
31
|
+
* Sets the transparency method.
|
|
32
|
+
* If setting to ByAlpha with no prior alpha, alpha stays 255 (opaque).
|
|
33
|
+
*
|
|
34
|
+
* @param method The new transparency method
|
|
35
|
+
*/
|
|
36
|
+
set: function (method) {
|
|
37
|
+
this._method = method;
|
|
38
|
+
},
|
|
39
|
+
enumerable: false,
|
|
40
|
+
configurable: true
|
|
41
|
+
});
|
|
42
|
+
Object.defineProperty(AcCmTransparency.prototype, "alpha", {
|
|
43
|
+
/**
|
|
44
|
+
* Gets the alpha value.
|
|
45
|
+
* Only meaningful if `method === ByAlpha`.
|
|
46
|
+
*/
|
|
47
|
+
get: function () {
|
|
48
|
+
return this._alpha;
|
|
49
|
+
},
|
|
50
|
+
/**
|
|
51
|
+
* Sets the alpha value and force the method to `ByAlpha`.
|
|
52
|
+
*
|
|
53
|
+
* @param alpha 0–255 alpha, clamped internally if out of range
|
|
54
|
+
*/
|
|
55
|
+
set: function (alpha) {
|
|
56
|
+
this._alpha = AcCmTransparency.clampAlpha(alpha);
|
|
57
|
+
this._method = AcCmTransparencyMethod.ByAlpha;
|
|
58
|
+
},
|
|
59
|
+
enumerable: false,
|
|
60
|
+
configurable: true
|
|
61
|
+
});
|
|
62
|
+
Object.defineProperty(AcCmTransparency.prototype, "percentage", {
|
|
63
|
+
/**
|
|
64
|
+
* Gets the AutoCAD-style transparency percentage.
|
|
65
|
+
*
|
|
66
|
+
* Mapping rules:
|
|
67
|
+
* - 0% = fully opaque (alpha = 255)
|
|
68
|
+
* - 100% = fully transparent (alpha = 0)
|
|
69
|
+
*
|
|
70
|
+
* This matches how AutoCAD displays and stores transparency
|
|
71
|
+
* values in UI and DXF files.
|
|
72
|
+
*
|
|
73
|
+
* If the transparency method is not `ByAlpha`,
|
|
74
|
+
* this method returns `undefined`, because AutoCAD
|
|
75
|
+
* does not define a percentage for ByLayer or ByBlock.
|
|
76
|
+
*
|
|
77
|
+
* @returns Transparency percentage (0–100), or undefined
|
|
78
|
+
*/
|
|
79
|
+
get: function () {
|
|
80
|
+
if (this._method !== AcCmTransparencyMethod.ByAlpha) {
|
|
81
|
+
return undefined;
|
|
82
|
+
}
|
|
83
|
+
return Math.round((1 - this._alpha / 255) * 100);
|
|
84
|
+
},
|
|
85
|
+
/**
|
|
86
|
+
* Sets the transparency using an AutoCAD-style percentage.
|
|
87
|
+
*
|
|
88
|
+
* Mapping rules (AutoCAD compatible):
|
|
89
|
+
* - 0% → fully opaque (alpha = 255)
|
|
90
|
+
* - 100% → fully transparent (alpha = 0)
|
|
91
|
+
*
|
|
92
|
+
* Internally, the alpha value is calculated as:
|
|
93
|
+
* alpha = round(255 × (1 − percentage / 100))
|
|
94
|
+
*
|
|
95
|
+
* This method:
|
|
96
|
+
* - Forces the transparency method to `ByAlpha`
|
|
97
|
+
* - Clamps the percentage to the range 0–100
|
|
98
|
+
* - Preserves ObjectARX value semantics
|
|
99
|
+
*
|
|
100
|
+
* @param percentage Transparency percentage (0–100)
|
|
101
|
+
* @returns This instance (for fluent chaining)
|
|
102
|
+
*
|
|
103
|
+
* @example
|
|
104
|
+
* const t = new AcCmTransparency();
|
|
105
|
+
* t.setPercentage(50); // ≈ alpha 128
|
|
106
|
+
*
|
|
107
|
+
* t.setPercentage(0); // alpha = 255 (opaque)
|
|
108
|
+
* t.setPercentage(100); // alpha = 0 (clear)
|
|
109
|
+
*/
|
|
110
|
+
set: function (percentage) {
|
|
111
|
+
var p = Math.max(0, Math.min(100, percentage));
|
|
112
|
+
var alpha = Math.round(255 * (1 - p / 100));
|
|
113
|
+
this.alpha = alpha;
|
|
114
|
+
},
|
|
115
|
+
enumerable: false,
|
|
116
|
+
configurable: true
|
|
117
|
+
});
|
|
118
|
+
/**
|
|
119
|
+
* Ensures alpha always stays within 0–255.
|
|
120
|
+
*/
|
|
121
|
+
AcCmTransparency.clampAlpha = function (alpha) {
|
|
122
|
+
return Math.max(0, Math.min(255, Math.floor(alpha)));
|
|
123
|
+
};
|
|
124
|
+
Object.defineProperty(AcCmTransparency.prototype, "isByAlpha", {
|
|
125
|
+
/**
|
|
126
|
+
* True if the method is `ByAlpha`.
|
|
127
|
+
*/
|
|
128
|
+
get: function () {
|
|
129
|
+
return this._method === AcCmTransparencyMethod.ByAlpha;
|
|
130
|
+
},
|
|
131
|
+
enumerable: false,
|
|
132
|
+
configurable: true
|
|
133
|
+
});
|
|
134
|
+
Object.defineProperty(AcCmTransparency.prototype, "isByBlock", {
|
|
135
|
+
/**
|
|
136
|
+
* True if the method is `ByBlock`.
|
|
137
|
+
*/
|
|
138
|
+
get: function () {
|
|
139
|
+
return this._method === AcCmTransparencyMethod.ByBlock;
|
|
140
|
+
},
|
|
141
|
+
enumerable: false,
|
|
142
|
+
configurable: true
|
|
143
|
+
});
|
|
144
|
+
Object.defineProperty(AcCmTransparency.prototype, "isByLayer", {
|
|
145
|
+
/**
|
|
146
|
+
* True if the method is `ByLayer`.
|
|
147
|
+
*/
|
|
148
|
+
get: function () {
|
|
149
|
+
return this._method === AcCmTransparencyMethod.ByLayer;
|
|
150
|
+
},
|
|
151
|
+
enumerable: false,
|
|
152
|
+
configurable: true
|
|
153
|
+
});
|
|
154
|
+
Object.defineProperty(AcCmTransparency.prototype, "isClear", {
|
|
155
|
+
/**
|
|
156
|
+
* True if transparency is exactly clear (alpha==0 and ByAlpha).
|
|
157
|
+
*/
|
|
158
|
+
get: function () {
|
|
159
|
+
return this.isByAlpha && this._alpha === 0;
|
|
160
|
+
},
|
|
161
|
+
enumerable: false,
|
|
162
|
+
configurable: true
|
|
163
|
+
});
|
|
164
|
+
Object.defineProperty(AcCmTransparency.prototype, "isSolid", {
|
|
165
|
+
/**
|
|
166
|
+
* True if transparency is solid (alpha==255 and ByAlpha).
|
|
167
|
+
*/
|
|
168
|
+
get: function () {
|
|
169
|
+
return this.isByAlpha && this._alpha === 255;
|
|
170
|
+
},
|
|
171
|
+
enumerable: false,
|
|
172
|
+
configurable: true
|
|
173
|
+
});
|
|
174
|
+
Object.defineProperty(AcCmTransparency.prototype, "isInvalid", {
|
|
175
|
+
/**
|
|
176
|
+
* True if current state is invalid (ErrorValue).
|
|
177
|
+
*/
|
|
178
|
+
get: function () {
|
|
179
|
+
return this._method === AcCmTransparencyMethod.ErrorValue;
|
|
180
|
+
},
|
|
181
|
+
enumerable: false,
|
|
182
|
+
configurable: true
|
|
183
|
+
});
|
|
184
|
+
/**
|
|
185
|
+
* Convert this transparency to an integer suitable for storage.
|
|
186
|
+
* Uses a simple bit-encoding: highbits for method and lowbits for alpha.
|
|
187
|
+
*
|
|
188
|
+
* 31 24 23 8 7 0
|
|
189
|
+
* +-------------+--------------+------------+
|
|
190
|
+
* | flags | reserved | alpha |
|
|
191
|
+
* +-------------+--------------+------------+
|
|
192
|
+
*/
|
|
193
|
+
AcCmTransparency.prototype.serialize = function () {
|
|
194
|
+
var methodVal = this._method;
|
|
195
|
+
return (methodVal << 24) | this._alpha;
|
|
196
|
+
};
|
|
197
|
+
/**
|
|
198
|
+
* Creates a deep copy of this transparency object.
|
|
199
|
+
*
|
|
200
|
+
* This mirrors the value-semantics of ObjectARX `AcCmTransparency`,
|
|
201
|
+
* where copying results in an independent object with the same
|
|
202
|
+
* transparency method and alpha value.
|
|
203
|
+
*
|
|
204
|
+
* @returns A new `AcCmTransparency` instance with identical state.
|
|
205
|
+
*/
|
|
206
|
+
AcCmTransparency.prototype.clone = function () {
|
|
207
|
+
var copy = new AcCmTransparency();
|
|
208
|
+
copy._method = this._method;
|
|
209
|
+
copy._alpha = this._alpha;
|
|
210
|
+
return copy;
|
|
211
|
+
};
|
|
212
|
+
/**
|
|
213
|
+
* Compares this transparency with another one for equality.
|
|
214
|
+
*
|
|
215
|
+
* Two `AcCmTransparency` objects are considered equal if:
|
|
216
|
+
* - Their transparency methods are identical
|
|
217
|
+
* - Their alpha values are identical
|
|
218
|
+
*
|
|
219
|
+
* This mirrors the value semantics of ObjectARX
|
|
220
|
+
* `AcCmTransparency`.
|
|
221
|
+
*
|
|
222
|
+
* @param other The transparency to compare with
|
|
223
|
+
* @returns True if both represent the same transparency
|
|
224
|
+
*
|
|
225
|
+
* @example
|
|
226
|
+
* const a = new AcCmTransparency(128);
|
|
227
|
+
* const b = new AcCmTransparency(128);
|
|
228
|
+
* a.equals(b); // true
|
|
229
|
+
*/
|
|
230
|
+
AcCmTransparency.prototype.equals = function (other) {
|
|
231
|
+
return this._method === other._method && this._alpha === other._alpha;
|
|
232
|
+
};
|
|
233
|
+
/**
|
|
234
|
+
* Returns a human-readable string representation of the transparency.
|
|
235
|
+
*
|
|
236
|
+
* Behavior:
|
|
237
|
+
* - `"ByLayer"` if transparency is inherited from layer
|
|
238
|
+
* - `"ByBlock"` if transparency is inherited from block
|
|
239
|
+
* - Numeric alpha value (`"0"`–`"255"`) if method is `ByAlpha`
|
|
240
|
+
*
|
|
241
|
+
* This format is intentionally simple and mirrors common
|
|
242
|
+
* AutoCAD UI and DXF text usage.
|
|
243
|
+
*
|
|
244
|
+
* @returns String representation of the transparency
|
|
245
|
+
*
|
|
246
|
+
* @example
|
|
247
|
+
* new AcCmTransparency().toString(); // "ByLayer"
|
|
248
|
+
* new AcCmTransparency(128).toString(); // "128"
|
|
249
|
+
*/
|
|
250
|
+
AcCmTransparency.prototype.toString = function () {
|
|
251
|
+
if (this.isByLayer)
|
|
252
|
+
return 'ByLayer';
|
|
253
|
+
if (this.isByBlock)
|
|
254
|
+
return 'ByBlock';
|
|
255
|
+
return this._alpha.toString();
|
|
256
|
+
};
|
|
257
|
+
/**
|
|
258
|
+
* Creates an `AcCmTransparency` instance from a string representation.
|
|
259
|
+
*
|
|
260
|
+
* Accepted formats:
|
|
261
|
+
* - `"ByLayer"` (case-insensitive)
|
|
262
|
+
* - `"ByBlock"` (case-insensitive)
|
|
263
|
+
* - Numeric alpha value `"0"`–`"255"`
|
|
264
|
+
*
|
|
265
|
+
* Invalid or out-of-range values will produce an
|
|
266
|
+
* `ErrorValue` transparency.
|
|
267
|
+
*
|
|
268
|
+
* @param value String to parse
|
|
269
|
+
* @returns Parsed `AcCmTransparency` instance
|
|
270
|
+
*
|
|
271
|
+
* @example
|
|
272
|
+
* AcCmTransparency.fromString("ByLayer");
|
|
273
|
+
* AcCmTransparency.fromString("128");
|
|
274
|
+
* AcCmTransparency.fromString("ByBlock");
|
|
275
|
+
*/
|
|
276
|
+
AcCmTransparency.fromString = function (value) {
|
|
277
|
+
var v = value.trim();
|
|
278
|
+
if (/^bylayer$/i.test(v)) {
|
|
279
|
+
var t_1 = new AcCmTransparency();
|
|
280
|
+
t_1._method = AcCmTransparencyMethod.ByLayer;
|
|
281
|
+
return t_1;
|
|
282
|
+
}
|
|
283
|
+
if (/^byblock$/i.test(v)) {
|
|
284
|
+
var t_2 = new AcCmTransparency();
|
|
285
|
+
t_2._method = AcCmTransparencyMethod.ByBlock;
|
|
286
|
+
return t_2;
|
|
287
|
+
}
|
|
288
|
+
var alpha = Number(v);
|
|
289
|
+
if (Number.isInteger(alpha) && alpha >= 0 && alpha <= 255) {
|
|
290
|
+
return new AcCmTransparency(alpha);
|
|
291
|
+
}
|
|
292
|
+
// Invalid input → ErrorValue
|
|
293
|
+
var t = new AcCmTransparency();
|
|
294
|
+
t._method = AcCmTransparencyMethod.ErrorValue;
|
|
295
|
+
return t;
|
|
296
|
+
};
|
|
297
|
+
/**
|
|
298
|
+
* Deserialize an integer back into a transparency object.
|
|
299
|
+
*
|
|
300
|
+
* @param value 32-bit stored transparency representation
|
|
301
|
+
*/
|
|
302
|
+
AcCmTransparency.deserialize = function (value) {
|
|
303
|
+
var _a;
|
|
304
|
+
var methodIndex = (value >>> 24) & 0xff;
|
|
305
|
+
var alpha = value & 0xff;
|
|
306
|
+
var method = (_a = Object.values(AcCmTransparencyMethod)[methodIndex]) !== null && _a !== void 0 ? _a : AcCmTransparencyMethod.ErrorValue;
|
|
307
|
+
var t = new AcCmTransparency();
|
|
308
|
+
t._method = method;
|
|
309
|
+
t._alpha = AcCmTransparency.clampAlpha(alpha);
|
|
310
|
+
return t;
|
|
311
|
+
};
|
|
312
|
+
return AcCmTransparency;
|
|
313
|
+
}());
|
|
314
|
+
export { AcCmTransparency };
|
|
315
|
+
//# sourceMappingURL=AcCmTransparency.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AcCmTransparency.js","sourceRoot":"","sources":["../src/AcCmTransparency.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAA;AAEjE;;;;GAIG;AACH;IAaE;;;;;;OAMG;IACH,0BAAY,KAAc;QACxB,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACxB,IAAI,CAAC,OAAO,GAAG,sBAAsB,CAAC,OAAO,CAAA;YAC7C,IAAI,CAAC,MAAM,GAAG,gBAAgB,CAAC,UAAU,CAAC,KAAK,CAAC,CAAA;QAClD,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,OAAO,GAAG,sBAAsB,CAAC,OAAO,CAAA;YAC7C,IAAI,CAAC,MAAM,GAAG,GAAG,CAAA;QACnB,CAAC;IACH,CAAC;IAGD,sBAAI,oCAAM;QADV,2CAA2C;aAC3C;YACE,OAAO,IAAI,CAAC,OAAO,CAAA;QACrB,CAAC;QAED;;;;;WAKG;aACH,UAAW,MAA8B;YACvC,IAAI,CAAC,OAAO,GAAG,MAAM,CAAA;QACvB,CAAC;;;OAVA;IAgBD,sBAAI,mCAAK;QAJT;;;WAGG;aACH;YACE,OAAO,IAAI,CAAC,MAAM,CAAA;QACpB,CAAC;QAED;;;;WAIG;aACH,UAAU,KAAa;YACrB,IAAI,CAAC,MAAM,GAAG,gBAAgB,CAAC,UAAU,CAAC,KAAK,CAAC,CAAA;YAChD,IAAI,CAAC,OAAO,GAAG,sBAAsB,CAAC,OAAO,CAAA;QAC/C,CAAC;;;OAVA;IA4BD,sBAAI,wCAAU;QAhBd;;;;;;;;;;;;;;;WAeG;aACH;YACE,IAAI,IAAI,CAAC,OAAO,KAAK,sBAAsB,CAAC,OAAO,EAAE,CAAC;gBACpD,OAAO,SAAS,CAAA;YAClB,CAAC;YAED,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC,CAAA;QAClD,CAAC;QAED;;;;;;;;;;;;;;;;;;;;;;;;WAwBG;aACH,UAAe,UAAkB;YAC/B,IAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC,CAAA;YAChD,IAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,CAAC,CAAA;YAC7C,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;QACpB,CAAC;;;OA/BA;IAiCD;;OAEG;IACY,2BAAU,GAAzB,UAA0B,KAAa;QACrC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;IACtD,CAAC;IAKD,sBAAI,uCAAS;QAHb;;WAEG;aACH;YACE,OAAO,IAAI,CAAC,OAAO,KAAK,sBAAsB,CAAC,OAAO,CAAA;QACxD,CAAC;;;OAAA;IAKD,sBAAI,uCAAS;QAHb;;WAEG;aACH;YACE,OAAO,IAAI,CAAC,OAAO,KAAK,sBAAsB,CAAC,OAAO,CAAA;QACxD,CAAC;;;OAAA;IAKD,sBAAI,uCAAS;QAHb;;WAEG;aACH;YACE,OAAO,IAAI,CAAC,OAAO,KAAK,sBAAsB,CAAC,OAAO,CAAA;QACxD,CAAC;;;OAAA;IAKD,sBAAI,qCAAO;QAHX;;WAEG;aACH;YACE,OAAO,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,CAAA;QAC5C,CAAC;;;OAAA;IAKD,sBAAI,qCAAO;QAHX;;WAEG;aACH;YACE,OAAO,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC,MAAM,KAAK,GAAG,CAAA;QAC9C,CAAC;;;OAAA;IAKD,sBAAI,uCAAS;QAHb;;WAEG;aACH;YACE,OAAO,IAAI,CAAC,OAAO,KAAK,sBAAsB,CAAC,UAAU,CAAA;QAC3D,CAAC;;;OAAA;IAED;;;;;;;;OAQG;IACH,oCAAS,GAAT;QACE,IAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAA;QAC9B,OAAO,CAAC,SAAS,IAAI,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,CAAA;IACxC,CAAC;IAED;;;;;;;;OAQG;IACH,gCAAK,GAAL;QACE,IAAM,IAAI,GAAG,IAAI,gBAAgB,EAAE,CAAA;QACnC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAA;QAC3B,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAA;QACzB,OAAO,IAAI,CAAA;IACb,CAAC;IAED;;;;;;;;;;;;;;;;;OAiBG;IACH,iCAAM,GAAN,UAAO,KAAuB;QAC5B,OAAO,IAAI,CAAC,OAAO,KAAK,KAAK,CAAC,OAAO,IAAI,IAAI,CAAC,MAAM,KAAK,KAAK,CAAC,MAAM,CAAA;IACvE,CAAC;IAED;;;;;;;;;;;;;;;;OAgBG;IACH,mCAAQ,GAAR;QACE,IAAI,IAAI,CAAC,SAAS;YAAE,OAAO,SAAS,CAAA;QACpC,IAAI,IAAI,CAAC,SAAS;YAAE,OAAO,SAAS,CAAA;QACpC,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAA;IAC/B,CAAC;IAED;;;;;;;;;;;;;;;;;;OAkBG;IACI,2BAAU,GAAjB,UAAkB,KAAa;QAC7B,IAAM,CAAC,GAAG,KAAK,CAAC,IAAI,EAAE,CAAA;QAEtB,IAAI,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;YACzB,IAAM,GAAC,GAAG,IAAI,gBAAgB,EAAE,CAAA;YAChC,GAAC,CAAC,OAAO,GAAG,sBAAsB,CAAC,OAAO,CAAA;YAC1C,OAAO,GAAC,CAAA;QACV,CAAC;QAED,IAAI,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;YACzB,IAAM,GAAC,GAAG,IAAI,gBAAgB,EAAE,CAAA;YAChC,GAAC,CAAC,OAAO,GAAG,sBAAsB,CAAC,OAAO,CAAA;YAC1C,OAAO,GAAC,CAAA;QACV,CAAC;QAED,IAAM,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC,CAAA;QACvB,IAAI,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,KAAK,IAAI,GAAG,EAAE,CAAC;YAC1D,OAAO,IAAI,gBAAgB,CAAC,KAAK,CAAC,CAAA;QACpC,CAAC;QAED,6BAA6B;QAC7B,IAAM,CAAC,GAAG,IAAI,gBAAgB,EAAE,CAAA;QAChC,CAAC,CAAC,OAAO,GAAG,sBAAsB,CAAC,UAAU,CAAA;QAC7C,OAAO,CAAC,CAAA;IACV,CAAC;IAED;;;;OAIG;IACI,4BAAW,GAAlB,UAAmB,KAAa;;QAC9B,IAAM,WAAW,GAAG,CAAC,KAAK,KAAK,EAAE,CAAC,GAAG,IAAI,CAAA;QACzC,IAAM,KAAK,GAAG,KAAK,GAAG,IAAI,CAAA;QAC1B,IAAM,MAAM,GACV,MAAA,MAAM,CAAC,MAAM,CAAC,sBAAsB,CAAC,CAAC,WAAW,CAAC,mCAClD,sBAAsB,CAAC,UAAU,CAAA;QACnC,IAAM,CAAC,GAAG,IAAI,gBAAgB,EAAE,CAAA;QAChC,CAAC,CAAC,OAAO,GAAG,MAAgC,CAAA;QAC5C,CAAC,CAAC,MAAM,GAAG,gBAAgB,CAAC,UAAU,CAAC,KAAK,CAAC,CAAA;QAC7C,OAAO,CAAC,CAAA;IACV,CAAC;IACH,uBAAC;AAAD,CAAC,AA/SD,IA+SC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Defines how transparency is interpreted.
|
|
3
|
+
*
|
|
4
|
+
* This mirrors the `transparencyMethod` enum from ObjectARX:
|
|
5
|
+
* - ByLayer: Use the layer’s transparency
|
|
6
|
+
* - ByBlock: Use a parent block’s transparency
|
|
7
|
+
* - ByAlpha: Use a specific alpha value
|
|
8
|
+
* - ErrorValue: Invalid transparency state
|
|
9
|
+
*/
|
|
10
|
+
export declare enum AcCmTransparencyMethod {
|
|
11
|
+
ByLayer = 0,
|
|
12
|
+
ByBlock = 1,
|
|
13
|
+
ByAlpha = 2,
|
|
14
|
+
ErrorValue = 3
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=AcCmTransparencyMethod.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AcCmTransparencyMethod.d.ts","sourceRoot":"","sources":["../src/AcCmTransparencyMethod.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,oBAAY,sBAAsB;IAChC,OAAO,IAAI;IACX,OAAO,IAAI;IACX,OAAO,IAAI;IACX,UAAU,IAAI;CACf"}
|