@mlightcad/common 1.0.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/LICENSE +21 -0
- package/dist/common.js +1226 -0
- package/dist/common.umd.cjs +1 -0
- package/lib/AcCmColor.d.ts +42 -0
- package/lib/AcCmColor.d.ts.map +1 -0
- package/lib/AcCmColor.js +456 -0
- package/lib/AcCmColor.js.map +1 -0
- package/lib/AcCmColorUtil.d.ts +9 -0
- package/lib/AcCmColorUtil.d.ts.map +1 -0
- package/lib/AcCmColorUtil.js +54 -0
- package/lib/AcCmColorUtil.js.map +1 -0
- package/lib/AcCmErrors.d.ts +23 -0
- package/lib/AcCmErrors.d.ts.map +1 -0
- package/lib/AcCmErrors.js +37 -0
- package/lib/AcCmErrors.js.map +1 -0
- package/lib/AcCmEventDispatcher.d.ts +48 -0
- package/lib/AcCmEventDispatcher.d.ts.map +1 -0
- package/lib/AcCmEventDispatcher.js +60 -0
- package/lib/AcCmEventDispatcher.js.map +1 -0
- package/lib/AcCmEventManager.d.ts +27 -0
- package/lib/AcCmEventManager.d.ts.map +1 -0
- package/lib/AcCmEventManager.js +94 -0
- package/lib/AcCmEventManager.js.map +1 -0
- package/lib/AcCmLogUtil.d.ts +31 -0
- package/lib/AcCmLogUtil.d.ts.map +1 -0
- package/lib/AcCmLogUtil.js +23 -0
- package/lib/AcCmLogUtil.js.map +1 -0
- package/lib/AcCmObject.d.ts +96 -0
- package/lib/AcCmObject.d.ts.map +1 -0
- package/lib/AcCmObject.js +175 -0
- package/lib/AcCmObject.js.map +1 -0
- package/lib/AcCmPerformanceCollector.d.ts +68 -0
- package/lib/AcCmPerformanceCollector.d.ts.map +1 -0
- package/lib/AcCmPerformanceCollector.js +110 -0
- package/lib/AcCmPerformanceCollector.js.map +1 -0
- package/lib/AcCmStringUtil.d.ts +11 -0
- package/lib/AcCmStringUtil.d.ts.map +1 -0
- package/lib/AcCmStringUtil.js +25 -0
- package/lib/AcCmStringUtil.js.map +1 -0
- package/lib/AcCmTaskScheduler.d.ts +70 -0
- package/lib/AcCmTaskScheduler.d.ts.map +1 -0
- package/lib/AcCmTaskScheduler.js +173 -0
- package/lib/AcCmTaskScheduler.js.map +1 -0
- package/lib/index.d.ts +11 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +11 -0
- package/lib/index.js.map +1 -0
- package/lib/loader/AcCmFileLoader.d.ts +58 -0
- package/lib/loader/AcCmFileLoader.d.ts.map +1 -0
- package/lib/loader/AcCmFileLoader.js +225 -0
- package/lib/loader/AcCmFileLoader.js.map +1 -0
- package/lib/loader/AcCmLoader.d.ts +92 -0
- package/lib/loader/AcCmLoader.d.ts.map +1 -0
- package/lib/loader/AcCmLoader.js +88 -0
- package/lib/loader/AcCmLoader.js.map +1 -0
- package/lib/loader/AcCmLoadingManager.d.ts +119 -0
- package/lib/loader/AcCmLoadingManager.d.ts.map +1 -0
- package/lib/loader/AcCmLoadingManager.js +133 -0
- package/lib/loader/AcCmLoadingManager.js.map +1 -0
- package/lib/loader/index.d.ts +3 -0
- package/lib/loader/index.d.ts.map +1 -0
- package/lib/loader/index.js +3 -0
- package/lib/loader/index.js.map +1 -0
- package/package.json +44 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(h,f){typeof exports=="object"&&typeof module<"u"?f(exports,require("lodash-es")):typeof define=="function"&&define.amd?define(["exports","lodash-es"],f):(h=typeof globalThis<"u"?globalThis:h||self,f(h.common={},h.lodashEs))})(this,function(h,f){"use strict";function $(c,e){for(var t=0;t<e.length;t++){const r=e[t];if(typeof r!="string"&&!Array.isArray(r)){for(const n in r)if(n!=="default"&&!(n in c)){const i=Object.getOwnPropertyDescriptor(r,n);i&&Object.defineProperty(c,n,i.get?i:{enumerable:!0,get:()=>r[n]})}}}return Object.freeze(Object.defineProperty(c,Symbol.toStringTag,{value:"Module"}))}const I={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];function L(c,e,t){return Math.max(e,Math.min(t,c))}const k=class k{constructor(){this._colorIndex=256,this._color=null,this._colorName=null}get color(){return this._color}set color(e){e==null?this._color=null:(this._color=Math.round(L(e,0,256*256*256-1)),this._colorIndex=this.getColorIndexByValue(this._color),this._colorName=this.getColorNameByValue(this._color))}get hexColor(){if(this._color&&this._color>0&&this._color<=16777215){let e=this._color.toString(16).toUpperCase();for(;e.length<6;)e="0"+e;return`0x${e}`}return""}get cssColor(){return`rgb(${this.red},${this.green},${this.blue})`}get red(){return this.color?this.color>>16&255:null}get green(){return this.color?this.color>>8&255:null}get blue(){return this.color?this.color&255:null}get colorIndex(){return this._colorIndex}set colorIndex(e){e==null?this._colorIndex=null:(this._colorIndex=L(e,0,256),this._color=T[e],this._colorName=this.getColorNameByValue(this._color))}get colorName(){return this._colorName}set colorName(e){if(e){const t=I[e.toLowerCase()];t!==void 0?(this._colorName=e,this._color=t,this._colorIndex=this.getColorIndexByValue(this._color)):console.warn("Unknown color: "+e)}else this._colorName=null}get hasColorName(){return this._colorName==null}get hasColorIndex(){return this._colorIndex==null}get isByLayer(){return this.colorIndex==256}setByLayer(){return this.colorIndex=256,this}get isByBlock(){return this.colorIndex==0}setByBlock(){return this.colorIndex=0,this}setScalar(e){return this.setRGB(e,e,e),this}setRGB(e,t,r){const n=Math.round(L(e,0,255)),i=Math.round(L(t,0,255)),s=Math.round(L(r,0,255));return this.color=(n<<16)+(i<<8)+s,this}setColorName(e){const t=I[e.toLowerCase()];return t!==void 0?this.color=t:console.warn("Unknown color "+e),this}clone(){const e=new k;return e.colorIndex=this.colorIndex,e.color=this.color,e._colorName=this._colorName,this}copy(e){return this.colorIndex=e.colorIndex,this.color=e.color,this._colorName=e._colorName,this}equals(e){return e.color==this.color&&e.colorIndex==this.colorIndex&&e._colorName==this._colorName}toString(){return this.isByLayer?"ByLayer":this.isByBlock?"ByBlock":this.colorName?this.colorName:this.hexColor}getColorNameByValue(e){for(const[t,r]of Object.entries(I))if(r===e)return t;return null}getColorIndexByValue(e){const t=T.length-1;for(let r=1;r<t;++r)if(T[r]===e)return r;return null}};k.NAMES=I;let O=k;const G={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 H{constructor(){this._listeners={}}addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const r=this._listeners;r[e]===void 0&&(r[e]=[]),r[e].indexOf(t)===-1&&r[e].push(t)}hasEventListener(e,t){if(this._listeners===void 0)return!1;const r=this._listeners;return r[e]!==void 0&&r[e].indexOf(t)!==-1}removeEventListener(e,t){if(this._listeners===void 0)return;const n=this._listeners[e];if(n!==void 0){const i=n.indexOf(t);i!==-1&&n.splice(i,1)}}dispatchEvent(e){if(this._listeners===void 0)return;const r=this._listeners[e.type];if(r!==void 0){e.target=this;const n=r.slice(0);for(let i=0,s=n.length;i<s;i++)n[i].call(this,e)}}}class M{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 r of this.listeners)r.call(null,e,...t)}}var z=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function K(c){return c&&c.__esModule&&Object.prototype.hasOwnProperty.call(c,"default")?c.default:c}var P={exports:{}};(function(c){(function(e,t){c.exports?c.exports=t():e.log=t()})(z,function(){var e=function(){},t="undefined",r=typeof window!==t&&typeof window.navigator!==t&&/Trident\/|MSIE /.test(window.navigator.userAgent),n=["trace","debug","info","warn","error"],i={},s=null;function p(l,u){var o=l[u];if(typeof o.bind=="function")return o.bind(l);try{return Function.prototype.bind.call(o,l)}catch{return function(){return Function.prototype.apply.apply(o,[l,arguments])}}}function v(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function b(l){return l==="debug"&&(l="log"),typeof console===t?!1:l==="trace"&&r?v:console[l]!==void 0?p(console,l):console.log!==void 0?p(console,"log"):e}function y(){for(var l=this.getLevel(),u=0;u<n.length;u++){var o=n[u];this[o]=u<l?e:this.methodFactory(o,l,this.name)}if(this.log=this.debug,typeof console===t&&l<this.levels.SILENT)return"No console available for logging"}function B(l){return function(){typeof console!==t&&(y.call(this),this[l].apply(this,arguments))}}function g(l,u,o){return b(l)||B.apply(this,arguments)}function q(l,u){var o=this,A,S,_,m="loglevel";typeof l=="string"?m+=":"+l:typeof l=="symbol"&&(m=void 0);function re(a){var d=(n[a]||"silent").toUpperCase();if(!(typeof window===t||!m)){try{window.localStorage[m]=d;return}catch{}try{window.document.cookie=encodeURIComponent(m)+"="+d+";"}catch{}}}function F(){var a;if(!(typeof window===t||!m)){try{a=window.localStorage[m]}catch{}if(typeof a===t)try{var d=window.document.cookie,N=encodeURIComponent(m),V=d.indexOf(N+"=");V!==-1&&(a=/^([^;]+)/.exec(d.slice(V+N.length+1))[1])}catch{}return o.levels[a]===void 0&&(a=void 0),a}}function ne(){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 C(a){var d=a;if(typeof d=="string"&&o.levels[d.toUpperCase()]!==void 0&&(d=o.levels[d.toUpperCase()]),typeof d=="number"&&d>=0&&d<=o.levels.SILENT)return d;throw new TypeError("log.setLevel() called with invalid level: "+a)}o.name=l,o.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},o.methodFactory=u||g,o.getLevel=function(){return _??S??A},o.setLevel=function(a,d){return _=C(a),d!==!1&&re(_),y.call(o)},o.setDefaultLevel=function(a){S=C(a),F()||o.setLevel(a,!1)},o.resetLevel=function(){_=null,ne(),y.call(o)},o.enableAll=function(a){o.setLevel(o.levels.TRACE,a)},o.disableAll=function(a){o.setLevel(o.levels.SILENT,a)},o.rebuild=function(){if(s!==o&&(A=C(s.getLevel())),y.call(o),s===o)for(var a in i)i[a].rebuild()},A=C(s?s.getLevel():"WARN");var j=F();j!=null&&(_=C(j)),y.call(o)}s=new q,s.getLogger=function(u){if(typeof u!="symbol"&&typeof u!="string"||u==="")throw new TypeError("You must supply a name when creating a logger.");var o=i[u];return o||(o=i[u]=new q(u,s.methodFactory)),o};var te=typeof window!==t?window.log:void 0;return s.noConflict=function(){return typeof window!==t&&window.log===s&&(window.log=te),s},s.getLoggers=function(){return i},s.default=s,s})})(P);var R=P.exports;const W=$({__proto__:null,default:K(R)},[R]),Y=!0,E=W;E.setLevel("debug");const Z=c=>{try{E.setLevel(c)}catch(e){E.setLevel("error"),E.error(e)}};class x{constructor(e,t){this.events={attrChanged:new M,modelChanged:new M},this._changing=!1,this._previousAttributes={},this._pending=!1;const r=e||{};t&&f.defaults(r,t),this.attributes=r,this.changed={}}get(e){return this.attributes[e]}set(e,t,r){if(e==null)return this;let n;typeof e=="object"?(n=e,r=t):(n={},n[e]=t),r||(r={});const i=r.unset,s=r.silent,p=[],v=this._changing;this._changing=!0,v||(this._previousAttributes=f.clone(this.attributes),this.changed={});const b=this.attributes,y=this.changed,B=this._previousAttributes;for(const g in n)t=n[g],f.isEqual(b[g],t)||p.push(g),f.isEqual(B[g],t)?delete y[g]:y[g]=t,i?delete b[g]:b[g]=t;if(!s){p.length&&(this._pending=r);for(let g=0;g<p.length;g++)this.events.attrChanged.dispatch({object:this,attrName:p[g],attrValue:b[p[g]],options:r})}if(v)return this;if(!s)for(;this._pending;)r=this._pending,this._pending=!1,this.events.modelChanged.dispatch({object:this,options:r});return this._pending=!1,this._changing=!1,this}has(e){return this.get(e)!=null}hasChanged(e){return e==null?!f.isEmpty(this.changed):f.has(this.changed,e)}changedAttributes(e){if(!e)return this.hasChanged()?f.clone(this.changed):{};const t=this._changing?this._previousAttributes:this.attributes,r={};for(const n in e){const i=e[n];f.isEqual(t[n],i)||(r[n]=i)}return r}previous(e){return e==null||!this._previousAttributes?null:this._previousAttributes[e]}previousAttributes(){return f.clone(this._previousAttributes)}clone(){const e=f.clone(this.attributes);return new x(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 J{static formatBytes(e,t=2){if(e===0)return"0 B";const r=1024,n=Math.max(0,t),i=["B","KB","MB","GB","TB"],s=Math.floor(Math.log(e)/Math.log(r)),p=e/Math.pow(r,s);return`${parseFloat(p.toFixed(n))} ${i[s]}`}}class X{constructor(e){this.name=e}run(e){throw new Error("run() must be implemented by subclass")}}class Q{constructor(){this.tasks=[],this.onProgress=()=>{},this.onComplete=()=>{},this.onError=()=>{}}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 r=e;for(let n=0;n<t;n++){const i=this.tasks[n];try{r=await new Promise((s,p)=>{setTimeout(async()=>{try{const v=await i.run(r);this.onProgress((n+1)/t,i),s(v)}catch(v){p(v)}},0)})}catch(s){this.onError(s,n,i);return}}this.onComplete(r)}}class U{constructor(e,t,r){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=r}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,r=this.handlers.length;t<r;t+=2){const n=this.handlers[t],i=this.handlers[t+1];if(n.global&&(n.lastIndex=0),n.test(e))return i}return null}}const D=new U;class ee{constructor(e){this.manager=e!==void 0?e:D,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}loadAsync(e,t){return new Promise((r,n)=>{this.load(e,r,t,n)})}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=O,h.AcCmErrors=G,h.AcCmEventDispatcher=H,h.AcCmEventManager=M,h.AcCmLoader=ee,h.AcCmLoadingManager=U,h.AcCmObject=x,h.AcCmPerformanceCollector=w,h.AcCmTask=X,h.AcCmTaskScheduler=Q,h.AcTrStringUtil=J,h.DEBUG_MODE=Y,h.DefaultLoadingManager=D,h.log=E,h.setLogLevel=Z,Object.defineProperty(h,Symbol.toStringTag,{value:"Module"})});
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export declare class AcCmColor {
|
|
2
|
+
private _colorIndex;
|
|
3
|
+
private _color;
|
|
4
|
+
private _colorName;
|
|
5
|
+
static NAMES: Record<string, number>;
|
|
6
|
+
constructor();
|
|
7
|
+
get color(): number | null;
|
|
8
|
+
set color(value: number | null);
|
|
9
|
+
get hexColor(): string;
|
|
10
|
+
get cssColor(): string;
|
|
11
|
+
get red(): number | null;
|
|
12
|
+
get green(): number | null;
|
|
13
|
+
get blue(): number | null;
|
|
14
|
+
/**
|
|
15
|
+
* AutoCAD color index value. The index value will be in the range 0 to 256. 0 and 256 are special values.
|
|
16
|
+
* If value less than 0 is set, 0 will be used. If value greater than 256 is set, 256 will be used.
|
|
17
|
+
* - 0 indicates that the entity uses the color of the BlockReference that's displaying it. If the entity
|
|
18
|
+
* is not displayed through a block reference (for example, it is directly owned by the model space
|
|
19
|
+
* block table record) and its color is 0, then it will display as though its color were 7.
|
|
20
|
+
* - 256 indicates that the entity uses the color specified in the layer table record it references.
|
|
21
|
+
*/
|
|
22
|
+
get colorIndex(): number | null;
|
|
23
|
+
set colorIndex(value: number | null);
|
|
24
|
+
get colorName(): string | null;
|
|
25
|
+
set colorName(value: string | null);
|
|
26
|
+
get hasColorName(): boolean;
|
|
27
|
+
get hasColorIndex(): boolean;
|
|
28
|
+
get isByLayer(): boolean;
|
|
29
|
+
setByLayer(): this;
|
|
30
|
+
get isByBlock(): boolean;
|
|
31
|
+
setByBlock(): this;
|
|
32
|
+
setScalar(scalar: number): this;
|
|
33
|
+
setRGB(r: number, g: number, b: number): this;
|
|
34
|
+
setColorName(style: string): this;
|
|
35
|
+
clone(): this;
|
|
36
|
+
copy(color: AcCmColor): this;
|
|
37
|
+
equals(c: AcCmColor): boolean;
|
|
38
|
+
toString(): string;
|
|
39
|
+
private getColorNameByValue;
|
|
40
|
+
private getColorIndexByValue;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=AcCmColor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AcCmColor.d.ts","sourceRoot":"","sources":["../src/AcCmColor.ts"],"names":[],"mappings":"AA+LA,qBAAa,SAAS;IACpB,OAAO,CAAC,WAAW,CAAe;IAClC,OAAO,CAAC,MAAM,CAAe;IAC7B,OAAO,CAAC,UAAU,CAAe;IACjC,MAAM,CAAC,KAAK,yBAAiB;;IAQ7B,IAAI,KAAK,IAIQ,MAAM,GAAG,IAAI,CAF7B;IAED,IAAI,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,EAQ7B;IAED,IAAI,QAAQ,WAWX;IAED,IAAI,QAAQ,WAEX;IAED,IAAI,GAAG,kBAEN;IAED,IAAI,KAAK,kBAER;IAED,IAAI,IAAI,kBAEP;IAED;;;;;;;OAOG;IACH,IAAI,UAAU,IAGQ,MAAM,GAAG,IAAI,CADlC;IACD,IAAI,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,EAQlC;IAED,IAAI,SAAS,IAGQ,MAAM,GAAG,IAAI,CADjC;IACD,IAAI,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,EAejC;IAED,IAAI,YAAY,YAEf;IAED,IAAI,aAAa,YAEhB;IAED,IAAI,SAAS,YAEZ;IACD,UAAU;IAKV,IAAI,SAAS,YAEZ;IACD,UAAU;IAKV,SAAS,CAAC,MAAM,EAAE,MAAM;IAKxB,MAAM,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM;IAQtC,YAAY,CAAC,KAAK,EAAE,MAAM;IAY1B,KAAK;IAQL,IAAI,CAAC,KAAK,EAAE,SAAS;IAOrB,MAAM,CAAC,CAAC,EAAE,SAAS;IAQnB,QAAQ;IAYR,OAAO,CAAC,mBAAmB;IAS3B,OAAO,CAAC,oBAAoB;CAS7B"}
|
package/lib/AcCmColor.js
ADDED
|
@@ -0,0 +1,456 @@
|
|
|
1
|
+
var __values = (this && this.__values) || function(o) {
|
|
2
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
3
|
+
if (m) return m.call(o);
|
|
4
|
+
if (o && typeof o.length === "number") return {
|
|
5
|
+
next: function () {
|
|
6
|
+
if (o && i >= o.length) o = void 0;
|
|
7
|
+
return { value: o && o[i++], done: !o };
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
11
|
+
};
|
|
12
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
13
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
14
|
+
if (!m) return o;
|
|
15
|
+
var i = m.call(o), r, ar = [], e;
|
|
16
|
+
try {
|
|
17
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
18
|
+
}
|
|
19
|
+
catch (error) { e = { error: error }; }
|
|
20
|
+
finally {
|
|
21
|
+
try {
|
|
22
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
23
|
+
}
|
|
24
|
+
finally { if (e) throw e.error; }
|
|
25
|
+
}
|
|
26
|
+
return ar;
|
|
27
|
+
};
|
|
28
|
+
var _colorKeywords = {
|
|
29
|
+
aliceblue: 0xf0f8ff,
|
|
30
|
+
antiquewhite: 0xfaebd7,
|
|
31
|
+
aqua: 0x00ffff,
|
|
32
|
+
aquamarine: 0x7fffd4,
|
|
33
|
+
azure: 0xf0ffff,
|
|
34
|
+
beige: 0xf5f5dc,
|
|
35
|
+
bisque: 0xffe4c4,
|
|
36
|
+
black: 0x000000,
|
|
37
|
+
blanchedalmond: 0xffebcd,
|
|
38
|
+
blue: 0x0000ff,
|
|
39
|
+
blueviolet: 0x8a2be2,
|
|
40
|
+
brown: 0xa52a2a,
|
|
41
|
+
burlywood: 0xdeb887,
|
|
42
|
+
cadetblue: 0x5f9ea0,
|
|
43
|
+
chartreuse: 0x7fff00,
|
|
44
|
+
chocolate: 0xd2691e,
|
|
45
|
+
coral: 0xff7f50,
|
|
46
|
+
cornflowerblue: 0x6495ed,
|
|
47
|
+
cornsilk: 0xfff8dc,
|
|
48
|
+
crimson: 0xdc143c,
|
|
49
|
+
cyan: 0x00ffff,
|
|
50
|
+
darkblue: 0x00008b,
|
|
51
|
+
darkcyan: 0x008b8b,
|
|
52
|
+
darkgoldenrod: 0xb8860b,
|
|
53
|
+
darkgray: 0xa9a9a9,
|
|
54
|
+
darkgreen: 0x006400,
|
|
55
|
+
darkkhaki: 0xbdb76b,
|
|
56
|
+
darkmagenta: 0x8b008b,
|
|
57
|
+
darkolivegreen: 0x556b2f,
|
|
58
|
+
darkorange: 0xff8c00,
|
|
59
|
+
darkorchid: 0x9932cc,
|
|
60
|
+
darkred: 0x8b0000,
|
|
61
|
+
darksalmon: 0xe9967a,
|
|
62
|
+
darkseagreen: 0x8fbc8f,
|
|
63
|
+
darkslateblue: 0x483d8b,
|
|
64
|
+
darkslategray: 0x2f4f4f,
|
|
65
|
+
darkturquoise: 0x00ced1,
|
|
66
|
+
darkviolet: 0x9400d3,
|
|
67
|
+
deeppink: 0xff1493,
|
|
68
|
+
deepskyblue: 0x00bfff,
|
|
69
|
+
dimgrey: 0x696969,
|
|
70
|
+
dodgerblue: 0x1e90ff,
|
|
71
|
+
firebrick: 0xb22222,
|
|
72
|
+
floralwhite: 0xfffaf0,
|
|
73
|
+
forestgreen: 0x228b22,
|
|
74
|
+
fuchsia: 0xff00ff,
|
|
75
|
+
gainsboro: 0xdcdcdc,
|
|
76
|
+
ghostwhite: 0xf8f8ff,
|
|
77
|
+
gold: 0xffd700,
|
|
78
|
+
goldenrod: 0xdaa520,
|
|
79
|
+
gray: 0x808080,
|
|
80
|
+
green: 0x008000,
|
|
81
|
+
greenyellow: 0xadff2f,
|
|
82
|
+
grey: 0x808080,
|
|
83
|
+
honeydew: 0xf0fff0,
|
|
84
|
+
hotpink: 0xff69b4,
|
|
85
|
+
indianred: 0xcd5c5c,
|
|
86
|
+
indigo: 0x4b0082,
|
|
87
|
+
ivory: 0xfffff0,
|
|
88
|
+
khaki: 0xf0e68c,
|
|
89
|
+
lavender: 0xe6e6fa,
|
|
90
|
+
lavenderblush: 0xfff0f5,
|
|
91
|
+
lawngreen: 0x7cfc00,
|
|
92
|
+
lemonchiffon: 0xfffacd,
|
|
93
|
+
lightblue: 0xadd8e6,
|
|
94
|
+
lightcoral: 0xf08080,
|
|
95
|
+
lightcyan: 0xe0ffff,
|
|
96
|
+
lightgoldenrodyellow: 0xfafad2,
|
|
97
|
+
lightgray: 0xd3d3d3,
|
|
98
|
+
lightgreen: 0x90ee90,
|
|
99
|
+
lightgrey: 0xd3d3d3,
|
|
100
|
+
lightpink: 0xffb6c1,
|
|
101
|
+
lightsalmon: 0xffa07a,
|
|
102
|
+
lightseagreen: 0x20b2aa,
|
|
103
|
+
lightskyblue: 0x87cefa,
|
|
104
|
+
lightslategray: 0x778899,
|
|
105
|
+
lightslategrey: 0x778899,
|
|
106
|
+
lightsteelblue: 0xb0c4de,
|
|
107
|
+
lightyellow: 0xffffe0,
|
|
108
|
+
lime: 0x00ff00,
|
|
109
|
+
limegreen: 0x32cd32,
|
|
110
|
+
linen: 0xfaf0e6,
|
|
111
|
+
magenta: 0xff00ff,
|
|
112
|
+
maroon: 0x800000,
|
|
113
|
+
mediumaquamarine: 0x66cdaa,
|
|
114
|
+
mediumblue: 0x0000cd,
|
|
115
|
+
mediumorchid: 0xba55d3,
|
|
116
|
+
mediumpurple: 0x9370db,
|
|
117
|
+
mediumseagreen: 0x3cb371,
|
|
118
|
+
mediumslateblue: 0x7b68ee,
|
|
119
|
+
mediumspringgreen: 0x00fa9a,
|
|
120
|
+
mediumturquoise: 0x48d1cc,
|
|
121
|
+
mediumvioletred: 0xc71585,
|
|
122
|
+
midnightblue: 0x191970,
|
|
123
|
+
mintcream: 0xf5fffa,
|
|
124
|
+
mistyrose: 0xffe4e1,
|
|
125
|
+
moccasin: 0xffe4b5,
|
|
126
|
+
navajowhite: 0xffdead,
|
|
127
|
+
navy: 0x000080,
|
|
128
|
+
oldlace: 0xfdf5e6,
|
|
129
|
+
olive: 0x808000,
|
|
130
|
+
olivedrab: 0x6b8e23,
|
|
131
|
+
orange: 0xffa500,
|
|
132
|
+
orangered: 0xff4500,
|
|
133
|
+
orchid: 0xda70d6,
|
|
134
|
+
palegoldenrod: 0xeee8aa,
|
|
135
|
+
palegreen: 0x98fb98,
|
|
136
|
+
paleturquoise: 0xafeeee,
|
|
137
|
+
palevioletred: 0xdb7093,
|
|
138
|
+
papayawhip: 0xffefd5,
|
|
139
|
+
peachpuff: 0xffdab9,
|
|
140
|
+
peru: 0xcd853f,
|
|
141
|
+
pink: 0xffc0cb,
|
|
142
|
+
plum: 0xdda0dd,
|
|
143
|
+
powderblue: 0xb0e0e6,
|
|
144
|
+
purple: 0x800080,
|
|
145
|
+
rebeccapurple: 0x663399,
|
|
146
|
+
red: 0xff0000,
|
|
147
|
+
rosybrown: 0xbc8f8f,
|
|
148
|
+
royalblue: 0x4169e1,
|
|
149
|
+
saddlebrown: 0x8b4513,
|
|
150
|
+
salmon: 0xfa8072,
|
|
151
|
+
sandybrown: 0xf4a460,
|
|
152
|
+
seagreen: 0x2e8b57,
|
|
153
|
+
seashell: 0xfff5ee,
|
|
154
|
+
sienna: 0xa0522d,
|
|
155
|
+
silver: 0xc0c0c0,
|
|
156
|
+
skyblue: 0x87ceeb,
|
|
157
|
+
slateblue: 0x6a5acd,
|
|
158
|
+
slategrey: 0x708090,
|
|
159
|
+
snow: 0xfffafa,
|
|
160
|
+
springgreen: 0x00ff7f,
|
|
161
|
+
steelblue: 0x4682b4,
|
|
162
|
+
tan: 0xd2b48c,
|
|
163
|
+
teal: 0x008080,
|
|
164
|
+
thistle: 0xd8bfd8,
|
|
165
|
+
tomato: 0xff6347,
|
|
166
|
+
turquoise: 0x40e0d0,
|
|
167
|
+
violet: 0xee82ee,
|
|
168
|
+
wheat: 0xf5deb3,
|
|
169
|
+
white: 0xffffff,
|
|
170
|
+
whitesmoke: 0xf5f5f5,
|
|
171
|
+
yellow: 0xffff00,
|
|
172
|
+
yellowgreen: 0x9acd32
|
|
173
|
+
};
|
|
174
|
+
/**
|
|
175
|
+
* AutoCAD files sometimes use an indexed color value between 1 and 255 inclusive.
|
|
176
|
+
* Each value corresponds to a color. index 1 is red, that is 16711680 or 0xFF0000.
|
|
177
|
+
* index 0 and 256, while included in this array, are actually reserved for inheritance
|
|
178
|
+
* values in AutoCAD so they should not be used for index color lookups.
|
|
179
|
+
*/
|
|
180
|
+
var AUTO_CAD_COLOR_INDEX = [
|
|
181
|
+
0, 16711680, 16776960, 65280, 65535, 255, 16711935, 16777215, 8421504,
|
|
182
|
+
12632256, 16711680, 16744319, 13369344, 13395558, 10027008, 10046540, 8323072,
|
|
183
|
+
8339263, 4980736, 4990502, 16727808, 16752511, 13382400, 13401958, 10036736,
|
|
184
|
+
10051404, 8331008, 8343359, 4985600, 4992806, 16744192, 16760703, 13395456,
|
|
185
|
+
13408614, 10046464, 10056268, 8339200, 8347455, 4990464, 4995366, 16760576,
|
|
186
|
+
16768895, 13408512, 13415014, 10056192, 10061132, 8347392, 8351551, 4995328,
|
|
187
|
+
4997670, 16776960, 16777087, 13421568, 13421670, 10000384, 10000460, 8355584,
|
|
188
|
+
8355647, 5000192, 5000230, 12582656, 14679935, 10079232, 11717734, 7510016,
|
|
189
|
+
8755276, 6258432, 7307071, 3755008, 4344870, 8388352, 12582783, 6736896,
|
|
190
|
+
10079334, 5019648, 7510092, 4161280, 6258495, 2509824, 3755046, 4194048,
|
|
191
|
+
10485631, 3394560, 8375398, 2529280, 6264908, 2064128, 5209919, 1264640,
|
|
192
|
+
3099686, 65280, 8388479, 52224, 6736998, 38912, 5019724, 32512, 4161343,
|
|
193
|
+
19456, 2509862, 65343, 8388511, 52275, 6737023, 38950, 5019743, 32543,
|
|
194
|
+
4161359, 19475, 2509871, 65407, 8388543, 52326, 6737049, 38988, 5019762,
|
|
195
|
+
32575, 4161375, 19494, 2509881, 65471, 8388575, 52377, 6737074, 39026,
|
|
196
|
+
5019781, 32607, 4161391, 19513, 2509890, 65535, 8388607, 52428, 6737100,
|
|
197
|
+
39064, 5019800, 32639, 4161407, 19532, 2509900, 49151, 8380415, 39372,
|
|
198
|
+
6730444, 29336, 5014936, 24447, 4157311, 14668, 2507340, 32767, 8372223,
|
|
199
|
+
26316, 6724044, 19608, 5010072, 16255, 4153215, 9804, 2505036, 16383, 8364031,
|
|
200
|
+
13260, 6717388, 9880, 5005208, 8063, 4149119, 4940, 2502476, 255, 8355839,
|
|
201
|
+
204, 6710988, 152, 5000344, 127, 4145023, 76, 2500172, 4129023, 10452991,
|
|
202
|
+
3342540, 8349388, 2490520, 6245528, 2031743, 5193599, 1245260, 3089996,
|
|
203
|
+
8323327, 12550143, 6684876, 10053324, 4980888, 7490712, 4128895, 6242175,
|
|
204
|
+
2490444, 3745356, 12517631, 14647295, 10027212, 11691724, 7471256, 8735896,
|
|
205
|
+
6226047, 7290751, 3735628, 4335180, 16711935, 16744447, 13369548, 13395660,
|
|
206
|
+
9961624, 9981080, 8323199, 8339327, 4980812, 4990540, 16711871, 16744415,
|
|
207
|
+
13369497, 13395634, 9961586, 9981061, 8323167, 8339311, 4980793, 4990530,
|
|
208
|
+
16711807, 16744383, 13369446, 13395609, 9961548, 9981042, 8323135, 8339295,
|
|
209
|
+
4980774, 4990521, 16711743, 16744351, 13369395, 13395583, 9961510, 9981023,
|
|
210
|
+
8323103, 8339279, 4980755, 4990511, 3355443, 5987163, 8684676, 11382189,
|
|
211
|
+
14079702, 16777215, 0
|
|
212
|
+
];
|
|
213
|
+
function clamp(value, min, max) {
|
|
214
|
+
return Math.max(min, Math.min(max, value));
|
|
215
|
+
}
|
|
216
|
+
var AcCmColor = /** @class */ (function () {
|
|
217
|
+
function AcCmColor() {
|
|
218
|
+
this._colorIndex = 256;
|
|
219
|
+
this._color = null;
|
|
220
|
+
this._colorName = null;
|
|
221
|
+
}
|
|
222
|
+
Object.defineProperty(AcCmColor.prototype, "color", {
|
|
223
|
+
get: function () {
|
|
224
|
+
return this._color;
|
|
225
|
+
},
|
|
226
|
+
set: function (value) {
|
|
227
|
+
if (value == null) {
|
|
228
|
+
this._color = null;
|
|
229
|
+
}
|
|
230
|
+
else {
|
|
231
|
+
this._color = Math.round(clamp(value, 0, 256 * 256 * 256 - 1));
|
|
232
|
+
this._colorIndex = this.getColorIndexByValue(this._color);
|
|
233
|
+
this._colorName = this.getColorNameByValue(this._color);
|
|
234
|
+
}
|
|
235
|
+
},
|
|
236
|
+
enumerable: false,
|
|
237
|
+
configurable: true
|
|
238
|
+
});
|
|
239
|
+
Object.defineProperty(AcCmColor.prototype, "hexColor", {
|
|
240
|
+
get: function () {
|
|
241
|
+
// Ensure the number is a valid RGB value
|
|
242
|
+
if (this._color && this._color > 0 && this._color <= 0xffffff) {
|
|
243
|
+
var hexString = this._color.toString(16).toUpperCase();
|
|
244
|
+
// Pad the string with leading zeros if necessary
|
|
245
|
+
while (hexString.length < 6) {
|
|
246
|
+
hexString = '0' + hexString;
|
|
247
|
+
}
|
|
248
|
+
return "0x".concat(hexString);
|
|
249
|
+
}
|
|
250
|
+
return '';
|
|
251
|
+
},
|
|
252
|
+
enumerable: false,
|
|
253
|
+
configurable: true
|
|
254
|
+
});
|
|
255
|
+
Object.defineProperty(AcCmColor.prototype, "cssColor", {
|
|
256
|
+
get: function () {
|
|
257
|
+
return "rgb(".concat(this.red, ",").concat(this.green, ",").concat(this.blue, ")");
|
|
258
|
+
},
|
|
259
|
+
enumerable: false,
|
|
260
|
+
configurable: true
|
|
261
|
+
});
|
|
262
|
+
Object.defineProperty(AcCmColor.prototype, "red", {
|
|
263
|
+
get: function () {
|
|
264
|
+
return this.color ? (this.color >> 16) & 255 : null;
|
|
265
|
+
},
|
|
266
|
+
enumerable: false,
|
|
267
|
+
configurable: true
|
|
268
|
+
});
|
|
269
|
+
Object.defineProperty(AcCmColor.prototype, "green", {
|
|
270
|
+
get: function () {
|
|
271
|
+
return this.color ? (this.color >> 8) & 255 : null;
|
|
272
|
+
},
|
|
273
|
+
enumerable: false,
|
|
274
|
+
configurable: true
|
|
275
|
+
});
|
|
276
|
+
Object.defineProperty(AcCmColor.prototype, "blue", {
|
|
277
|
+
get: function () {
|
|
278
|
+
return this.color ? this.color & 255 : null;
|
|
279
|
+
},
|
|
280
|
+
enumerable: false,
|
|
281
|
+
configurable: true
|
|
282
|
+
});
|
|
283
|
+
Object.defineProperty(AcCmColor.prototype, "colorIndex", {
|
|
284
|
+
/**
|
|
285
|
+
* AutoCAD color index value. The index value will be in the range 0 to 256. 0 and 256 are special values.
|
|
286
|
+
* If value less than 0 is set, 0 will be used. If value greater than 256 is set, 256 will be used.
|
|
287
|
+
* - 0 indicates that the entity uses the color of the BlockReference that's displaying it. If the entity
|
|
288
|
+
* is not displayed through a block reference (for example, it is directly owned by the model space
|
|
289
|
+
* block table record) and its color is 0, then it will display as though its color were 7.
|
|
290
|
+
* - 256 indicates that the entity uses the color specified in the layer table record it references.
|
|
291
|
+
*/
|
|
292
|
+
get: function () {
|
|
293
|
+
return this._colorIndex;
|
|
294
|
+
},
|
|
295
|
+
set: function (value) {
|
|
296
|
+
if (value == null) {
|
|
297
|
+
this._colorIndex = null;
|
|
298
|
+
}
|
|
299
|
+
else {
|
|
300
|
+
this._colorIndex = clamp(value, 0, 256);
|
|
301
|
+
this._color = AUTO_CAD_COLOR_INDEX[value];
|
|
302
|
+
this._colorName = this.getColorNameByValue(this._color);
|
|
303
|
+
}
|
|
304
|
+
},
|
|
305
|
+
enumerable: false,
|
|
306
|
+
configurable: true
|
|
307
|
+
});
|
|
308
|
+
Object.defineProperty(AcCmColor.prototype, "colorName", {
|
|
309
|
+
get: function () {
|
|
310
|
+
return this._colorName;
|
|
311
|
+
},
|
|
312
|
+
set: function (value) {
|
|
313
|
+
if (value) {
|
|
314
|
+
var color = _colorKeywords[value.toLowerCase()];
|
|
315
|
+
if (color !== undefined) {
|
|
316
|
+
// red
|
|
317
|
+
this._colorName = value;
|
|
318
|
+
this._color = color;
|
|
319
|
+
this._colorIndex = this.getColorIndexByValue(this._color);
|
|
320
|
+
}
|
|
321
|
+
else {
|
|
322
|
+
// unknown color
|
|
323
|
+
console.warn('Unknown color: ' + value);
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
else {
|
|
327
|
+
this._colorName = null;
|
|
328
|
+
}
|
|
329
|
+
},
|
|
330
|
+
enumerable: false,
|
|
331
|
+
configurable: true
|
|
332
|
+
});
|
|
333
|
+
Object.defineProperty(AcCmColor.prototype, "hasColorName", {
|
|
334
|
+
get: function () {
|
|
335
|
+
return this._colorName == null;
|
|
336
|
+
},
|
|
337
|
+
enumerable: false,
|
|
338
|
+
configurable: true
|
|
339
|
+
});
|
|
340
|
+
Object.defineProperty(AcCmColor.prototype, "hasColorIndex", {
|
|
341
|
+
get: function () {
|
|
342
|
+
return this._colorIndex == null;
|
|
343
|
+
},
|
|
344
|
+
enumerable: false,
|
|
345
|
+
configurable: true
|
|
346
|
+
});
|
|
347
|
+
Object.defineProperty(AcCmColor.prototype, "isByLayer", {
|
|
348
|
+
get: function () {
|
|
349
|
+
return this.colorIndex == 256;
|
|
350
|
+
},
|
|
351
|
+
enumerable: false,
|
|
352
|
+
configurable: true
|
|
353
|
+
});
|
|
354
|
+
AcCmColor.prototype.setByLayer = function () {
|
|
355
|
+
this.colorIndex = 256;
|
|
356
|
+
return this;
|
|
357
|
+
};
|
|
358
|
+
Object.defineProperty(AcCmColor.prototype, "isByBlock", {
|
|
359
|
+
get: function () {
|
|
360
|
+
return this.colorIndex == 0;
|
|
361
|
+
},
|
|
362
|
+
enumerable: false,
|
|
363
|
+
configurable: true
|
|
364
|
+
});
|
|
365
|
+
AcCmColor.prototype.setByBlock = function () {
|
|
366
|
+
this.colorIndex = 0;
|
|
367
|
+
return this;
|
|
368
|
+
};
|
|
369
|
+
AcCmColor.prototype.setScalar = function (scalar) {
|
|
370
|
+
this.setRGB(scalar, scalar, scalar);
|
|
371
|
+
return this;
|
|
372
|
+
};
|
|
373
|
+
AcCmColor.prototype.setRGB = function (r, g, b) {
|
|
374
|
+
var red = Math.round(clamp(r, 0, 255));
|
|
375
|
+
var green = Math.round(clamp(g, 0, 255));
|
|
376
|
+
var blue = Math.round(clamp(b, 0, 255));
|
|
377
|
+
this.color = (red << 16) + (green << 8) + blue;
|
|
378
|
+
return this;
|
|
379
|
+
};
|
|
380
|
+
AcCmColor.prototype.setColorName = function (style) {
|
|
381
|
+
var color = _colorKeywords[style.toLowerCase()];
|
|
382
|
+
if (color !== undefined) {
|
|
383
|
+
// red
|
|
384
|
+
this.color = color;
|
|
385
|
+
}
|
|
386
|
+
else {
|
|
387
|
+
// unknown color
|
|
388
|
+
console.warn('Unknown color ' + style);
|
|
389
|
+
}
|
|
390
|
+
return this;
|
|
391
|
+
};
|
|
392
|
+
AcCmColor.prototype.clone = function () {
|
|
393
|
+
var clonedColor = new AcCmColor();
|
|
394
|
+
clonedColor.colorIndex = this.colorIndex;
|
|
395
|
+
clonedColor.color = this.color;
|
|
396
|
+
clonedColor._colorName = this._colorName;
|
|
397
|
+
return this;
|
|
398
|
+
};
|
|
399
|
+
AcCmColor.prototype.copy = function (color) {
|
|
400
|
+
this.colorIndex = color.colorIndex;
|
|
401
|
+
this.color = color.color;
|
|
402
|
+
this._colorName = color._colorName;
|
|
403
|
+
return this;
|
|
404
|
+
};
|
|
405
|
+
AcCmColor.prototype.equals = function (c) {
|
|
406
|
+
return (c.color == this.color &&
|
|
407
|
+
c.colorIndex == this.colorIndex &&
|
|
408
|
+
c._colorName == this._colorName);
|
|
409
|
+
};
|
|
410
|
+
AcCmColor.prototype.toString = function () {
|
|
411
|
+
if (this.isByLayer) {
|
|
412
|
+
return 'ByLayer';
|
|
413
|
+
}
|
|
414
|
+
else if (this.isByBlock) {
|
|
415
|
+
return 'ByBlock';
|
|
416
|
+
}
|
|
417
|
+
else if (this.colorName) {
|
|
418
|
+
return this.colorName;
|
|
419
|
+
}
|
|
420
|
+
else {
|
|
421
|
+
return this.hexColor;
|
|
422
|
+
}
|
|
423
|
+
};
|
|
424
|
+
AcCmColor.prototype.getColorNameByValue = function (target) {
|
|
425
|
+
var e_1, _a;
|
|
426
|
+
try {
|
|
427
|
+
for (var _b = __values(Object.entries(_colorKeywords)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
428
|
+
var _d = __read(_c.value, 2), key = _d[0], value = _d[1];
|
|
429
|
+
if (value === target) {
|
|
430
|
+
return key;
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
435
|
+
finally {
|
|
436
|
+
try {
|
|
437
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
438
|
+
}
|
|
439
|
+
finally { if (e_1) throw e_1.error; }
|
|
440
|
+
}
|
|
441
|
+
return null;
|
|
442
|
+
};
|
|
443
|
+
AcCmColor.prototype.getColorIndexByValue = function (target) {
|
|
444
|
+
var length = AUTO_CAD_COLOR_INDEX.length - 1;
|
|
445
|
+
for (var index = 1; index < length; ++index) {
|
|
446
|
+
if (AUTO_CAD_COLOR_INDEX[index] === target) {
|
|
447
|
+
return index;
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
return null;
|
|
451
|
+
};
|
|
452
|
+
AcCmColor.NAMES = _colorKeywords;
|
|
453
|
+
return AcCmColor;
|
|
454
|
+
}());
|
|
455
|
+
export { AcCmColor };
|
|
456
|
+
//# sourceMappingURL=AcCmColor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AcCmColor.js","sourceRoot":"","sources":["../src/AcCmColor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAM,cAAc,GAA2B;IAC7C,SAAS,EAAE,QAAQ;IACnB,YAAY,EAAE,QAAQ;IACtB,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE,QAAQ;IACpB,KAAK,EAAE,QAAQ;IAC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AO,SAAS,CAAA;QAClB,CAAC;aAAM,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YAC1B,OAAO,IAAI,CAAC,SAAS,CAAA;QACvB,CAAC;aAAM,CAAC;YACN,OAAO,IAAI,CAAC,QAAQ,CAAA;QACtB,CAAC;IACH,CAAC;IAEO,uCAAmB,GAA3B,UAA4B,MAAc;;;YACxC,KAA2B,IAAA,KAAA,SAAA,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,CAAA,gBAAA,4BAAE,CAAC;gBAAjD,IAAA,KAAA,mBAAY,EAAX,GAAG,QAAA,EAAE,KAAK,QAAA;gBACpB,IAAI,KAAK,KAAK,MAAM,EAAE,CAAC;oBACrB,OAAO,GAAG,CAAA;gBACZ,CAAC;YACH,CAAC;;;;;;;;;QACD,OAAO,IAAI,CAAA;IACb,CAAC;IAEO,wCAAoB,GAA5B,UAA6B,MAAc;QACzC,IAAM,MAAM,GAAG,oBAAoB,CAAC,MAAM,GAAG,CAAC,CAAA;QAC9C,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,MAAM,EAAE,EAAE,KAAK,EAAE,CAAC;YAC5C,IAAI,oBAAoB,CAAC,KAAK,CAAC,KAAK,MAAM,EAAE,CAAC;gBAC3C,OAAO,KAAK,CAAA;YACd,CAAC;QACH,CAAC;QACD,OAAO,IAAI,CAAA;IACb,CAAC;IAjMM,eAAK,GAAG,cAAc,CAAA;IAkM/B,gBAAC;CAAA,AAtMD,IAsMC;SAtMY,SAAS"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare class AcCmColorUtil {
|
|
2
|
+
/**
|
|
3
|
+
* Return the truecolor value of the given AutoCAD color index value
|
|
4
|
+
* @param index Input AutoCAD color index value
|
|
5
|
+
* @return Return truecolor value as a number
|
|
6
|
+
*/
|
|
7
|
+
static getAcadColor(index: number): number;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=AcCmColorUtil.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AcCmColorUtil.d.ts","sourceRoot":"","sources":["../src/AcCmColorUtil.ts"],"names":[],"mappings":"AAwCA,qBAAa,aAAa;IACxB;;;;OAIG;IACH,MAAM,CAAC,YAAY,CAAC,KAAK,EAAE,MAAM;CAGlC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AutoCad files sometimes use an indexed color value between 1 and 255 inclusive.
|
|
3
|
+
* Each value corresponds to a color. index 1 is red, that is 16711680 or 0xFF0000.
|
|
4
|
+
* index 0 and 256, while included in this array, are actually reserved for inheritance
|
|
5
|
+
* values in AutoCad so they should not be used for index color lookups.
|
|
6
|
+
*/
|
|
7
|
+
var AUTO_CAD_COLOR_INDEX = [
|
|
8
|
+
0, 16711680, 16776960, 65280, 65535, 255, 16711935, 16777215, 8421504,
|
|
9
|
+
12632256, 16711680, 16744319, 13369344, 13395558, 10027008, 10046540, 8323072,
|
|
10
|
+
8339263, 4980736, 4990502, 16727808, 16752511, 13382400, 13401958, 10036736,
|
|
11
|
+
10051404, 8331008, 8343359, 4985600, 4992806, 16744192, 16760703, 13395456,
|
|
12
|
+
13408614, 10046464, 10056268, 8339200, 8347455, 4990464, 4995366, 16760576,
|
|
13
|
+
16768895, 13408512, 13415014, 10056192, 10061132, 8347392, 8351551, 4995328,
|
|
14
|
+
4997670, 16776960, 16777087, 13421568, 13421670, 10000384, 10000460, 8355584,
|
|
15
|
+
8355647, 5000192, 5000230, 12582656, 14679935, 10079232, 11717734, 7510016,
|
|
16
|
+
8755276, 6258432, 7307071, 3755008, 4344870, 8388352, 12582783, 6736896,
|
|
17
|
+
10079334, 5019648, 7510092, 4161280, 6258495, 2509824, 3755046, 4194048,
|
|
18
|
+
10485631, 3394560, 8375398, 2529280, 6264908, 2064128, 5209919, 1264640,
|
|
19
|
+
3099686, 65280, 8388479, 52224, 6736998, 38912, 5019724, 32512, 4161343,
|
|
20
|
+
19456, 2509862, 65343, 8388511, 52275, 6737023, 38950, 5019743, 32543,
|
|
21
|
+
4161359, 19475, 2509871, 65407, 8388543, 52326, 6737049, 38988, 5019762,
|
|
22
|
+
32575, 4161375, 19494, 2509881, 65471, 8388575, 52377, 6737074, 39026,
|
|
23
|
+
5019781, 32607, 4161391, 19513, 2509890, 65535, 8388607, 52428, 6737100,
|
|
24
|
+
39064, 5019800, 32639, 4161407, 19532, 2509900, 49151, 8380415, 39372,
|
|
25
|
+
6730444, 29336, 5014936, 24447, 4157311, 14668, 2507340, 32767, 8372223,
|
|
26
|
+
26316, 6724044, 19608, 5010072, 16255, 4153215, 9804, 2505036, 16383, 8364031,
|
|
27
|
+
13260, 6717388, 9880, 5005208, 8063, 4149119, 4940, 2502476, 255, 8355839,
|
|
28
|
+
204, 6710988, 152, 5000344, 127, 4145023, 76, 2500172, 4129023, 10452991,
|
|
29
|
+
3342540, 8349388, 2490520, 6245528, 2031743, 5193599, 1245260, 3089996,
|
|
30
|
+
8323327, 12550143, 6684876, 10053324, 4980888, 7490712, 4128895, 6242175,
|
|
31
|
+
2490444, 3745356, 12517631, 14647295, 10027212, 11691724, 7471256, 8735896,
|
|
32
|
+
6226047, 7290751, 3735628, 4335180, 16711935, 16744447, 13369548, 13395660,
|
|
33
|
+
9961624, 9981080, 8323199, 8339327, 4980812, 4990540, 16711871, 16744415,
|
|
34
|
+
13369497, 13395634, 9961586, 9981061, 8323167, 8339311, 4980793, 4990530,
|
|
35
|
+
16711807, 16744383, 13369446, 13395609, 9961548, 9981042, 8323135, 8339295,
|
|
36
|
+
4980774, 4990521, 16711743, 16744351, 13369395, 13395583, 9961510, 9981023,
|
|
37
|
+
8323103, 8339279, 4980755, 4990511, 3355443, 5987163, 8684676, 11382189,
|
|
38
|
+
14079702, 16777215
|
|
39
|
+
];
|
|
40
|
+
var AcCmColorUtil = /** @class */ (function () {
|
|
41
|
+
function AcCmColorUtil() {
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Return the truecolor value of the given AutoCAD color index value
|
|
45
|
+
* @param index Input AutoCAD color index value
|
|
46
|
+
* @return Return truecolor value as a number
|
|
47
|
+
*/
|
|
48
|
+
AcCmColorUtil.getAcadColor = function (index) {
|
|
49
|
+
return AUTO_CAD_COLOR_INDEX[index];
|
|
50
|
+
};
|
|
51
|
+
return AcCmColorUtil;
|
|
52
|
+
}());
|
|
53
|
+
export { AcCmColorUtil };
|
|
54
|
+
//# sourceMappingURL=AcCmColorUtil.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AcCmColorUtil.js","sourceRoot":"","sources":["../src/AcCmColorUtil.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,IAAM,oBAAoB,GAAG;IAC3B,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO;IACrE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO;IAC7E,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ;IAC3E,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ;IAC1E,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ;IAC1E,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO;IAC3E,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO;IAC5E,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE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Aa;QAC/B,OAAO,oBAAoB,CAAC,KAAK,CAAC,CAAA;IACpC,CAAC;IACH,oBAAC;AAAD,CAAC,AATD,IASC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export declare const AcCmErrors: {
|
|
2
|
+
/**
|
|
3
|
+
* Throw error ILLEGAL_PARAMETERS when cannot instantiate from given parameter
|
|
4
|
+
*/
|
|
5
|
+
readonly ILLEGAL_PARAMETERS: ReferenceError;
|
|
6
|
+
/**
|
|
7
|
+
* Throw error ZERO_DIVISION to catch situation of zero division
|
|
8
|
+
*/
|
|
9
|
+
readonly ZERO_DIVISION: Error;
|
|
10
|
+
/**
|
|
11
|
+
* Error to throw from BooleanOperations module in case when fixBoundaryConflicts not capable to fix it
|
|
12
|
+
*/
|
|
13
|
+
readonly UNRESOLVED_BOUNDARY_CONFLICT: Error;
|
|
14
|
+
/**
|
|
15
|
+
* Error to throw from LinkedList:testInfiniteLoop static method
|
|
16
|
+
* in case when circular loop detected in linked list
|
|
17
|
+
*/
|
|
18
|
+
readonly INFINITE_LOOP: Error;
|
|
19
|
+
readonly CANNOT_INVOKE_ABSTRACT_METHOD: Error;
|
|
20
|
+
readonly OPERATION_IS_NOT_SUPPORTED: Error;
|
|
21
|
+
readonly NOT_IMPLEMENTED: Error;
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=AcCmErrors.d.ts.map
|