@mlightcad/common 1.1.1 → 1.1.3
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 +201 -12
- package/lib/AcCmColor.d.ts +162 -3
- package/lib/AcCmColor.d.ts.map +1 -1
- package/lib/AcCmColor.js +187 -9
- package/lib/AcCmColor.js.map +1 -1
- package/lib/AcCmColorUtil.d.ts +35 -3
- package/lib/AcCmColorUtil.d.ts.map +1 -1
- package/lib/AcCmColorUtil.js +43 -7
- package/lib/AcCmColorUtil.js.map +1 -1
- package/lib/AcCmErrors.d.ts +33 -0
- package/lib/AcCmErrors.d.ts.map +1 -1
- package/lib/AcCmErrors.js +33 -0
- package/lib/AcCmErrors.js.map +1 -1
- package/lib/AcCmEventDispatcher.d.ts +53 -0
- package/lib/AcCmEventDispatcher.d.ts.map +1 -1
- package/lib/AcCmEventDispatcher.js +37 -0
- package/lib/AcCmEventDispatcher.js.map +1 -1
- package/lib/AcCmEventManager.d.ts +40 -1
- package/lib/AcCmEventManager.d.ts.map +1 -1
- package/lib/AcCmEventManager.js +40 -1
- package/lib/AcCmEventManager.js.map +1 -1
- package/lib/AcCmLodashUtils.d.ts +125 -18
- package/lib/AcCmLodashUtils.d.ts.map +1 -1
- package/lib/AcCmLodashUtils.js +127 -20
- package/lib/AcCmLodashUtils.js.map +1 -1
- package/lib/AcCmLogUtil.d.ts +51 -2
- package/lib/AcCmLogUtil.d.ts.map +1 -1
- package/lib/AcCmLogUtil.js +51 -2
- package/lib/AcCmLogUtil.js.map +1 -1
- package/lib/AcCmObject.d.ts +58 -4
- package/lib/AcCmObject.d.ts.map +1 -1
- package/lib/AcCmObject.js +31 -2
- package/lib/AcCmObject.js.map +1 -1
- package/lib/AcCmPerformanceCollector.d.ts +22 -1
- package/lib/AcCmPerformanceCollector.d.ts.map +1 -1
- package/lib/AcCmPerformanceCollector.js +9 -0
- package/lib/AcCmPerformanceCollector.js.map +1 -1
- package/lib/AcCmStringUtil.d.ts +37 -4
- package/lib/AcCmStringUtil.d.ts.map +1 -1
- package/lib/AcCmStringUtil.js +37 -4
- package/lib/AcCmStringUtil.js.map +1 -1
- package/lib/AcCmTaskScheduler.d.ts +84 -15
- package/lib/AcCmTaskScheduler.d.ts.map +1 -1
- package/lib/AcCmTaskScheduler.js +71 -7
- package/lib/AcCmTaskScheduler.js.map +1 -1
- package/lib/loader/AcCmFileLoader.d.ts +45 -8
- package/lib/loader/AcCmFileLoader.d.ts.map +1 -1
- package/lib/loader/AcCmFileLoader.js +52 -2
- package/lib/loader/AcCmFileLoader.js.map +1 -1
- package/lib/loader/AcCmLoader.d.ts +34 -1
- package/lib/loader/AcCmLoader.d.ts.map +1 -1
- package/lib/loader/AcCmLoader.js +29 -1
- package/lib/loader/AcCmLoader.js.map +1 -1
- package/lib/loader/AcCmLoadingManager.d.ts +64 -17
- package/lib/loader/AcCmLoadingManager.d.ts.map +1 -1
- package/lib/loader/AcCmLoadingManager.js +43 -4
- package/lib/loader/AcCmLoadingManager.js.map +1 -1
- package/package.json +1 -1
package/dist/common.js
CHANGED
|
@@ -422,15 +422,34 @@ function b(n, e, t) {
|
|
|
422
422
|
return Math.max(e, Math.min(t, n));
|
|
423
423
|
}
|
|
424
424
|
const O = class O {
|
|
425
|
+
/**
|
|
426
|
+
* Constructs a new AcCmColor instance.
|
|
427
|
+
* Initializes the color to "ByLayer" (index 256) and null RGB values.
|
|
428
|
+
*/
|
|
425
429
|
constructor() {
|
|
426
430
|
this._colorIndex = 256, this._color = null, this._colorName = null;
|
|
427
431
|
}
|
|
432
|
+
/**
|
|
433
|
+
* Gets the current color value.
|
|
434
|
+
*
|
|
435
|
+
* @returns {number | null} The color value (RGB or index).
|
|
436
|
+
*/
|
|
428
437
|
get color() {
|
|
429
438
|
return this._color;
|
|
430
439
|
}
|
|
440
|
+
/**
|
|
441
|
+
* Sets the color value.
|
|
442
|
+
*
|
|
443
|
+
* @param {number | null} value - The color value to set (RGB or index).
|
|
444
|
+
*/
|
|
431
445
|
set color(e) {
|
|
432
446
|
e == null ? this._color = null : (this._color = Math.round(b(e, 0, 256 * 256 * 256 - 1)), this._colorIndex = this.getColorIndexByValue(this._color), this._colorName = this.getColorNameByValue(this._color));
|
|
433
447
|
}
|
|
448
|
+
/**
|
|
449
|
+
* Gets the hexadecimal representation of the current color.
|
|
450
|
+
*
|
|
451
|
+
* @returns {string} The hexadecimal color string (e.g., "0xFFFFFF").
|
|
452
|
+
*/
|
|
434
453
|
get hexColor() {
|
|
435
454
|
if (this._color && this._color > 0 && this._color <= 16777215) {
|
|
436
455
|
let e = this._color.toString(16).toUpperCase();
|
|
@@ -440,35 +459,73 @@ const O = class O {
|
|
|
440
459
|
}
|
|
441
460
|
return "";
|
|
442
461
|
}
|
|
462
|
+
/**
|
|
463
|
+
* Gets the CSS RGB color string representation.
|
|
464
|
+
*
|
|
465
|
+
* @returns {string} The CSS RGB color string (e.g., "rgb(255,255,255)").
|
|
466
|
+
*/
|
|
443
467
|
get cssColor() {
|
|
444
468
|
return `rgb(${this.red},${this.green},${this.blue})`;
|
|
445
469
|
}
|
|
470
|
+
/**
|
|
471
|
+
* Gets the red component of the current color.
|
|
472
|
+
*
|
|
473
|
+
* @returns {number | null} The red component (0-255).
|
|
474
|
+
*/
|
|
446
475
|
get red() {
|
|
447
476
|
return this.color ? this.color >> 16 & 255 : null;
|
|
448
477
|
}
|
|
478
|
+
/**
|
|
479
|
+
* Gets the green component of the current color.
|
|
480
|
+
*
|
|
481
|
+
* @returns {number | null} The green component (0-255).
|
|
482
|
+
*/
|
|
449
483
|
get green() {
|
|
450
484
|
return this.color ? this.color >> 8 & 255 : null;
|
|
451
485
|
}
|
|
486
|
+
/**
|
|
487
|
+
* Gets the blue component of the current color.
|
|
488
|
+
*
|
|
489
|
+
* @returns {number | null} The blue component (0-255).
|
|
490
|
+
*/
|
|
452
491
|
get blue() {
|
|
453
492
|
return this.color ? this.color & 255 : null;
|
|
454
493
|
}
|
|
455
494
|
/**
|
|
456
|
-
* AutoCAD color index value. The index value will be in the range 0 to 256.
|
|
457
|
-
*
|
|
495
|
+
* Gets the AutoCAD color index value. The index value will be in the range 0 to 256.
|
|
496
|
+
* 0 and 256 are special values.
|
|
497
|
+
*
|
|
498
|
+
* @returns {number | null} The color index.
|
|
499
|
+
*/
|
|
500
|
+
get colorIndex() {
|
|
501
|
+
return this._colorIndex;
|
|
502
|
+
}
|
|
503
|
+
/**
|
|
504
|
+
* Sets the AutoCAD color index value. If value less than 0 is set, 0 will be used. If value greater than
|
|
505
|
+
* 256 is set, 256 will be used.
|
|
458
506
|
* - 0 indicates that the entity uses the color of the BlockReference that's displaying it. If the entity
|
|
459
507
|
* is not displayed through a block reference (for example, it is directly owned by the model space
|
|
460
508
|
* block table record) and its color is 0, then it will display as though its color were 7.
|
|
461
509
|
* - 256 indicates that the entity uses the color specified in the layer table record it references.
|
|
510
|
+
*
|
|
511
|
+
* @param {number | null} value - The color index to set (0-256).
|
|
462
512
|
*/
|
|
463
|
-
get colorIndex() {
|
|
464
|
-
return this._colorIndex;
|
|
465
|
-
}
|
|
466
513
|
set colorIndex(e) {
|
|
467
514
|
e == null ? this._colorIndex = null : (this._colorIndex = b(e, 0, 256), this._color = T[e], this._colorName = this.getColorNameByValue(this._color));
|
|
468
515
|
}
|
|
516
|
+
/**
|
|
517
|
+
* Gets the name of the current color.
|
|
518
|
+
*
|
|
519
|
+
* @returns {string | null} The color name.
|
|
520
|
+
*/
|
|
469
521
|
get colorName() {
|
|
470
522
|
return this._colorName;
|
|
471
523
|
}
|
|
524
|
+
/**
|
|
525
|
+
* Sets the color by name.
|
|
526
|
+
*
|
|
527
|
+
* @param {string | null} value - The color name to set.
|
|
528
|
+
*/
|
|
472
529
|
set colorName(e) {
|
|
473
530
|
if (e) {
|
|
474
531
|
const t = I[e.toLowerCase()];
|
|
@@ -476,54 +533,140 @@ const O = class O {
|
|
|
476
533
|
} else
|
|
477
534
|
this._colorName = null;
|
|
478
535
|
}
|
|
536
|
+
/**
|
|
537
|
+
* Checks if the color has a name.
|
|
538
|
+
*
|
|
539
|
+
* @returns {boolean} True if the color has no name, false otherwise.
|
|
540
|
+
*/
|
|
479
541
|
get hasColorName() {
|
|
480
542
|
return this._colorName == null;
|
|
481
543
|
}
|
|
544
|
+
/**
|
|
545
|
+
* Checks if the color has an index.
|
|
546
|
+
*
|
|
547
|
+
* @returns {boolean} True if the color has no index, false otherwise.
|
|
548
|
+
*/
|
|
482
549
|
get hasColorIndex() {
|
|
483
550
|
return this._colorIndex == null;
|
|
484
551
|
}
|
|
552
|
+
/**
|
|
553
|
+
* Checks if the color is set to "ByLayer".
|
|
554
|
+
*
|
|
555
|
+
* @returns {boolean} True if the color is "ByLayer", false otherwise.
|
|
556
|
+
*/
|
|
485
557
|
get isByLayer() {
|
|
486
558
|
return this.colorIndex == 256;
|
|
487
559
|
}
|
|
560
|
+
/**
|
|
561
|
+
* Sets the color to "ByLayer".
|
|
562
|
+
*
|
|
563
|
+
* @returns {AcCmColor} The current instance.
|
|
564
|
+
*/
|
|
488
565
|
setByLayer() {
|
|
489
566
|
return this.colorIndex = 256, this;
|
|
490
567
|
}
|
|
568
|
+
/**
|
|
569
|
+
* Checks if the color is set to "ByBlock".
|
|
570
|
+
*
|
|
571
|
+
* @returns {boolean} True if the color is "ByBlock", false otherwise.
|
|
572
|
+
*/
|
|
491
573
|
get isByBlock() {
|
|
492
574
|
return this.colorIndex == 0;
|
|
493
575
|
}
|
|
576
|
+
/**
|
|
577
|
+
* Sets the color to "ByBlock".
|
|
578
|
+
*
|
|
579
|
+
* @returns {AcCmColor} The current instance.
|
|
580
|
+
*/
|
|
494
581
|
setByBlock() {
|
|
495
582
|
return this.colorIndex = 0, this;
|
|
496
583
|
}
|
|
584
|
+
/**
|
|
585
|
+
* Sets the color using a scalar value (RGB).
|
|
586
|
+
*
|
|
587
|
+
* @param {number} scalar - The scalar value (0-255).
|
|
588
|
+
* @returns {AcCmColor} The current instance.
|
|
589
|
+
*/
|
|
497
590
|
setScalar(e) {
|
|
498
591
|
return this.setRGB(e, e, e), this;
|
|
499
592
|
}
|
|
593
|
+
/**
|
|
594
|
+
* Sets the color using RGB values.
|
|
595
|
+
*
|
|
596
|
+
* @param {number} r - The red component (0-255).
|
|
597
|
+
* @param {number} g - The green component (0-255).
|
|
598
|
+
* @param {number} b - The blue component (0-255).
|
|
599
|
+
* @returns {AcCmColor} The current instance.
|
|
600
|
+
*/
|
|
500
601
|
setRGB(e, t, r) {
|
|
501
602
|
const o = Math.round(b(e, 0, 255)), i = Math.round(b(t, 0, 255)), l = Math.round(b(r, 0, 255));
|
|
502
603
|
return this.color = (o << 16) + (i << 8) + l, this;
|
|
503
604
|
}
|
|
605
|
+
/**
|
|
606
|
+
* Sets the color by name.
|
|
607
|
+
*
|
|
608
|
+
* @param {string} style - The color name to set.
|
|
609
|
+
* @returns {AcCmColor} The current instance.
|
|
610
|
+
*/
|
|
504
611
|
setColorName(e) {
|
|
505
612
|
const t = I[e.toLowerCase()];
|
|
506
613
|
return t !== void 0 ? this.color = t : console.warn("Unknown color " + e), this;
|
|
507
614
|
}
|
|
615
|
+
/**
|
|
616
|
+
* Clones the current AcCmColor instance.
|
|
617
|
+
*
|
|
618
|
+
* @returns {AcCmColor} A new AcCmColor instance with the same color and index.
|
|
619
|
+
*/
|
|
508
620
|
clone() {
|
|
509
621
|
const e = new O();
|
|
510
622
|
return e.colorIndex = this.colorIndex, e.color = this.color, e._colorName = this._colorName, this;
|
|
511
623
|
}
|
|
624
|
+
/**
|
|
625
|
+
* Copies the color from another AcCmColor instance.
|
|
626
|
+
*
|
|
627
|
+
* @param {AcCmColor} color - The color to copy from.
|
|
628
|
+
* @returns {AcCmColor} The current instance.
|
|
629
|
+
*/
|
|
512
630
|
copy(e) {
|
|
513
631
|
return this.colorIndex = e.colorIndex, this.color = e.color, this._colorName = e._colorName, this;
|
|
514
632
|
}
|
|
633
|
+
/**
|
|
634
|
+
* Checks if two AcCmColor instances are equal.
|
|
635
|
+
*
|
|
636
|
+
* @param {AcCmColor} c - The color to compare with.
|
|
637
|
+
* @returns {boolean} True if the colors and their indices are the same.
|
|
638
|
+
*/
|
|
515
639
|
equals(e) {
|
|
516
640
|
return e.color == this.color && e.colorIndex == this.colorIndex && e._colorName == this._colorName;
|
|
517
641
|
}
|
|
642
|
+
/**
|
|
643
|
+
* Returns a string representation of the color.
|
|
644
|
+
*
|
|
645
|
+
* @returns {string} The color name or hexadecimal string.
|
|
646
|
+
*/
|
|
518
647
|
toString() {
|
|
519
648
|
return this.isByLayer ? "ByLayer" : this.isByBlock ? "ByBlock" : this.colorName ? this.colorName : this.hexColor;
|
|
520
649
|
}
|
|
650
|
+
/**
|
|
651
|
+
* Finds the color name associated with a given RGB value.
|
|
652
|
+
*
|
|
653
|
+
* @private
|
|
654
|
+
* @param {number} target - The RGB value to find a name for.
|
|
655
|
+
* @returns {string | null} The color name if found, null otherwise.
|
|
656
|
+
*/
|
|
521
657
|
getColorNameByValue(e) {
|
|
522
658
|
for (const [t, r] of Object.entries(I))
|
|
523
659
|
if (r === e)
|
|
524
660
|
return t;
|
|
525
661
|
return null;
|
|
526
662
|
}
|
|
663
|
+
/**
|
|
664
|
+
* Finds the AutoCAD color index associated with a given RGB value.
|
|
665
|
+
*
|
|
666
|
+
* @private
|
|
667
|
+
* @param {number} target - The RGB value to find an index for.
|
|
668
|
+
* @returns {number | null} The color index if found, null otherwise.
|
|
669
|
+
*/
|
|
527
670
|
getColorIndexByValue(e) {
|
|
528
671
|
const t = T.length - 1;
|
|
529
672
|
for (let r = 1; r < t; ++r)
|
|
@@ -872,11 +1015,30 @@ class F {
|
|
|
872
1015
|
t && Z(r, t), this.attributes = r, this.changed = {};
|
|
873
1016
|
}
|
|
874
1017
|
/**
|
|
875
|
-
*
|
|
1018
|
+
* Gets the value of an attribute.
|
|
1019
|
+
*
|
|
1020
|
+
* For strongly-typed access to attributes, use the `get` method privately in public getter properties.
|
|
1021
|
+
*
|
|
1022
|
+
* @template A - The key type extending string keys of T.
|
|
1023
|
+
* @param {A} key - The attribute key to retrieve.
|
|
1024
|
+
* @returns {T[A] | undefined} The attribute value or undefined if not set.
|
|
1025
|
+
*
|
|
876
1026
|
* @example
|
|
1027
|
+
* ```typescript
|
|
1028
|
+
* // Get a single attribute value
|
|
1029
|
+
* const name = obj.get('name')
|
|
1030
|
+
* const visible = obj.get('visible')
|
|
1031
|
+
*
|
|
1032
|
+
* // Check if attribute exists
|
|
1033
|
+
* if (obj.get('name') !== undefined) {
|
|
1034
|
+
* console.log('Name is set')
|
|
1035
|
+
* }
|
|
1036
|
+
*
|
|
1037
|
+
* // For strongly-typed subclasses
|
|
877
1038
|
* get name(): string {
|
|
878
|
-
*
|
|
1039
|
+
* return super.get("name")
|
|
879
1040
|
* }
|
|
1041
|
+
* ```
|
|
880
1042
|
*/
|
|
881
1043
|
get(e) {
|
|
882
1044
|
return this.attributes[e];
|
|
@@ -1016,11 +1178,26 @@ class _ {
|
|
|
1016
1178
|
}
|
|
1017
1179
|
class se {
|
|
1018
1180
|
/**
|
|
1019
|
-
* Converts a byte count to a human-readable string using
|
|
1181
|
+
* Converts a byte count to a human-readable string using appropriate size units.
|
|
1182
|
+
*
|
|
1183
|
+
* Automatically selects the most appropriate unit (B, KB, MB, GB, TB) based on the size
|
|
1184
|
+
* and formats the result with the specified number of decimal places.
|
|
1020
1185
|
*
|
|
1021
|
-
* @param bytes - The number of bytes.
|
|
1022
|
-
* @param decimals - Number of decimal places to include
|
|
1023
|
-
* @returns A formatted string with the appropriate unit.
|
|
1186
|
+
* @param {number} bytes - The number of bytes to format.
|
|
1187
|
+
* @param {number} [decimals=2] - Number of decimal places to include in the result.
|
|
1188
|
+
* @returns {string} A formatted string with the appropriate unit.
|
|
1189
|
+
*
|
|
1190
|
+
* @example
|
|
1191
|
+
* ```typescript
|
|
1192
|
+
* import { AcTrStringUtil } from './AcCmStringUtil'
|
|
1193
|
+
*
|
|
1194
|
+
* // Format different byte sizes
|
|
1195
|
+
* AcTrStringUtil.formatBytes(0) // "0 B"
|
|
1196
|
+
* AcTrStringUtil.formatBytes(1024) // "1 KB"
|
|
1197
|
+
* AcTrStringUtil.formatBytes(1024 * 1024) // "1 MB"
|
|
1198
|
+
* AcTrStringUtil.formatBytes(1536, 1) // "1.5 KB"
|
|
1199
|
+
* AcTrStringUtil.formatBytes(2048000, 0) // "2 MB"
|
|
1200
|
+
* ```
|
|
1024
1201
|
*/
|
|
1025
1202
|
static formatBytes(e, t = 2) {
|
|
1026
1203
|
if (e === 0) return "0 B";
|
|
@@ -1029,11 +1206,23 @@ class se {
|
|
|
1029
1206
|
}
|
|
1030
1207
|
}
|
|
1031
1208
|
class ie {
|
|
1209
|
+
/**
|
|
1210
|
+
* Creates a new task with the specified name.
|
|
1211
|
+
*
|
|
1212
|
+
* @param {string} name - The name identifier for this task.
|
|
1213
|
+
*/
|
|
1032
1214
|
constructor(e) {
|
|
1033
1215
|
this.name = e;
|
|
1034
1216
|
}
|
|
1035
1217
|
/**
|
|
1036
|
-
* Executes the task.
|
|
1218
|
+
* Executes the task with the given input.
|
|
1219
|
+
*
|
|
1220
|
+
* This method must be implemented by subclasses to define the actual work
|
|
1221
|
+
* performed by the task. Can return either a synchronous result or a Promise.
|
|
1222
|
+
*
|
|
1223
|
+
* @param {TIn} _input - The input data for the task.
|
|
1224
|
+
* @returns {TOut | Promise<TOut>} The task result, either synchronous or asynchronous.
|
|
1225
|
+
* @throws {Error} When the method is not implemented by a subclass.
|
|
1037
1226
|
*/
|
|
1038
1227
|
run(e) {
|
|
1039
1228
|
throw new Error("run() must be implemented by subclass");
|
package/lib/AcCmColor.d.ts
CHANGED
|
@@ -1,42 +1,201 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview This module provides color handling functionality for AutoCAD files,
|
|
3
|
+
* including color representation, color name mapping, and color index conversion.
|
|
4
|
+
*
|
|
5
|
+
* The module supports various color formats including RGB values, named colors,
|
|
6
|
+
* AutoCAD color indices, and special values like "ByLayer" and "ByBlock".
|
|
7
|
+
*
|
|
8
|
+
* @module AcCmColor
|
|
9
|
+
* @version 1.0.0
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Represents a color in AutoCAD, supporting various color formats.
|
|
13
|
+
*
|
|
14
|
+
* @class AcCmColor
|
|
15
|
+
* @version 1.0.0
|
|
16
|
+
*/
|
|
1
17
|
export declare class AcCmColor {
|
|
2
18
|
private _colorIndex;
|
|
3
19
|
private _color;
|
|
4
20
|
private _colorName;
|
|
5
21
|
static NAMES: Record<string, number>;
|
|
22
|
+
/**
|
|
23
|
+
* Constructs a new AcCmColor instance.
|
|
24
|
+
* Initializes the color to "ByLayer" (index 256) and null RGB values.
|
|
25
|
+
*/
|
|
6
26
|
constructor();
|
|
27
|
+
/**
|
|
28
|
+
* Gets the current color value.
|
|
29
|
+
*
|
|
30
|
+
* @returns {number | null} The color value (RGB or index).
|
|
31
|
+
*/
|
|
7
32
|
get color(): number | null;
|
|
33
|
+
/**
|
|
34
|
+
* Sets the color value.
|
|
35
|
+
*
|
|
36
|
+
* @param {number | null} value - The color value to set (RGB or index).
|
|
37
|
+
*/
|
|
8
38
|
set color(value: number | null);
|
|
39
|
+
/**
|
|
40
|
+
* Gets the hexadecimal representation of the current color.
|
|
41
|
+
*
|
|
42
|
+
* @returns {string} The hexadecimal color string (e.g., "0xFFFFFF").
|
|
43
|
+
*/
|
|
9
44
|
get hexColor(): string;
|
|
45
|
+
/**
|
|
46
|
+
* Gets the CSS RGB color string representation.
|
|
47
|
+
*
|
|
48
|
+
* @returns {string} The CSS RGB color string (e.g., "rgb(255,255,255)").
|
|
49
|
+
*/
|
|
10
50
|
get cssColor(): string;
|
|
51
|
+
/**
|
|
52
|
+
* Gets the red component of the current color.
|
|
53
|
+
*
|
|
54
|
+
* @returns {number | null} The red component (0-255).
|
|
55
|
+
*/
|
|
11
56
|
get red(): number | null;
|
|
57
|
+
/**
|
|
58
|
+
* Gets the green component of the current color.
|
|
59
|
+
*
|
|
60
|
+
* @returns {number | null} The green component (0-255).
|
|
61
|
+
*/
|
|
12
62
|
get green(): number | null;
|
|
63
|
+
/**
|
|
64
|
+
* Gets the blue component of the current color.
|
|
65
|
+
*
|
|
66
|
+
* @returns {number | null} The blue component (0-255).
|
|
67
|
+
*/
|
|
13
68
|
get blue(): number | null;
|
|
14
69
|
/**
|
|
15
|
-
* AutoCAD color index value. The index value will be in the range 0 to 256.
|
|
16
|
-
*
|
|
70
|
+
* Gets the AutoCAD color index value. The index value will be in the range 0 to 256.
|
|
71
|
+
* 0 and 256 are special values.
|
|
72
|
+
*
|
|
73
|
+
* @returns {number | null} The color index.
|
|
74
|
+
*/
|
|
75
|
+
get colorIndex(): number | null;
|
|
76
|
+
/**
|
|
77
|
+
* Sets the AutoCAD color index value. If value less than 0 is set, 0 will be used. If value greater than
|
|
78
|
+
* 256 is set, 256 will be used.
|
|
17
79
|
* - 0 indicates that the entity uses the color of the BlockReference that's displaying it. If the entity
|
|
18
80
|
* is not displayed through a block reference (for example, it is directly owned by the model space
|
|
19
81
|
* block table record) and its color is 0, then it will display as though its color were 7.
|
|
20
82
|
* - 256 indicates that the entity uses the color specified in the layer table record it references.
|
|
83
|
+
*
|
|
84
|
+
* @param {number | null} value - The color index to set (0-256).
|
|
21
85
|
*/
|
|
22
|
-
get colorIndex(): number | null;
|
|
23
86
|
set colorIndex(value: number | null);
|
|
87
|
+
/**
|
|
88
|
+
* Gets the name of the current color.
|
|
89
|
+
*
|
|
90
|
+
* @returns {string | null} The color name.
|
|
91
|
+
*/
|
|
24
92
|
get colorName(): string | null;
|
|
93
|
+
/**
|
|
94
|
+
* Sets the color by name.
|
|
95
|
+
*
|
|
96
|
+
* @param {string | null} value - The color name to set.
|
|
97
|
+
*/
|
|
25
98
|
set colorName(value: string | null);
|
|
99
|
+
/**
|
|
100
|
+
* Checks if the color has a name.
|
|
101
|
+
*
|
|
102
|
+
* @returns {boolean} True if the color has no name, false otherwise.
|
|
103
|
+
*/
|
|
26
104
|
get hasColorName(): boolean;
|
|
105
|
+
/**
|
|
106
|
+
* Checks if the color has an index.
|
|
107
|
+
*
|
|
108
|
+
* @returns {boolean} True if the color has no index, false otherwise.
|
|
109
|
+
*/
|
|
27
110
|
get hasColorIndex(): boolean;
|
|
111
|
+
/**
|
|
112
|
+
* Checks if the color is set to "ByLayer".
|
|
113
|
+
*
|
|
114
|
+
* @returns {boolean} True if the color is "ByLayer", false otherwise.
|
|
115
|
+
*/
|
|
28
116
|
get isByLayer(): boolean;
|
|
117
|
+
/**
|
|
118
|
+
* Sets the color to "ByLayer".
|
|
119
|
+
*
|
|
120
|
+
* @returns {AcCmColor} The current instance.
|
|
121
|
+
*/
|
|
29
122
|
setByLayer(): this;
|
|
123
|
+
/**
|
|
124
|
+
* Checks if the color is set to "ByBlock".
|
|
125
|
+
*
|
|
126
|
+
* @returns {boolean} True if the color is "ByBlock", false otherwise.
|
|
127
|
+
*/
|
|
30
128
|
get isByBlock(): boolean;
|
|
129
|
+
/**
|
|
130
|
+
* Sets the color to "ByBlock".
|
|
131
|
+
*
|
|
132
|
+
* @returns {AcCmColor} The current instance.
|
|
133
|
+
*/
|
|
31
134
|
setByBlock(): this;
|
|
135
|
+
/**
|
|
136
|
+
* Sets the color using a scalar value (RGB).
|
|
137
|
+
*
|
|
138
|
+
* @param {number} scalar - The scalar value (0-255).
|
|
139
|
+
* @returns {AcCmColor} The current instance.
|
|
140
|
+
*/
|
|
32
141
|
setScalar(scalar: number): this;
|
|
142
|
+
/**
|
|
143
|
+
* Sets the color using RGB values.
|
|
144
|
+
*
|
|
145
|
+
* @param {number} r - The red component (0-255).
|
|
146
|
+
* @param {number} g - The green component (0-255).
|
|
147
|
+
* @param {number} b - The blue component (0-255).
|
|
148
|
+
* @returns {AcCmColor} The current instance.
|
|
149
|
+
*/
|
|
33
150
|
setRGB(r: number, g: number, b: number): this;
|
|
151
|
+
/**
|
|
152
|
+
* Sets the color by name.
|
|
153
|
+
*
|
|
154
|
+
* @param {string} style - The color name to set.
|
|
155
|
+
* @returns {AcCmColor} The current instance.
|
|
156
|
+
*/
|
|
34
157
|
setColorName(style: string): this;
|
|
158
|
+
/**
|
|
159
|
+
* Clones the current AcCmColor instance.
|
|
160
|
+
*
|
|
161
|
+
* @returns {AcCmColor} A new AcCmColor instance with the same color and index.
|
|
162
|
+
*/
|
|
35
163
|
clone(): this;
|
|
164
|
+
/**
|
|
165
|
+
* Copies the color from another AcCmColor instance.
|
|
166
|
+
*
|
|
167
|
+
* @param {AcCmColor} color - The color to copy from.
|
|
168
|
+
* @returns {AcCmColor} The current instance.
|
|
169
|
+
*/
|
|
36
170
|
copy(color: AcCmColor): this;
|
|
171
|
+
/**
|
|
172
|
+
* Checks if two AcCmColor instances are equal.
|
|
173
|
+
*
|
|
174
|
+
* @param {AcCmColor} c - The color to compare with.
|
|
175
|
+
* @returns {boolean} True if the colors and their indices are the same.
|
|
176
|
+
*/
|
|
37
177
|
equals(c: AcCmColor): boolean;
|
|
178
|
+
/**
|
|
179
|
+
* Returns a string representation of the color.
|
|
180
|
+
*
|
|
181
|
+
* @returns {string} The color name or hexadecimal string.
|
|
182
|
+
*/
|
|
38
183
|
toString(): string;
|
|
184
|
+
/**
|
|
185
|
+
* Finds the color name associated with a given RGB value.
|
|
186
|
+
*
|
|
187
|
+
* @private
|
|
188
|
+
* @param {number} target - The RGB value to find a name for.
|
|
189
|
+
* @returns {string | null} The color name if found, null otherwise.
|
|
190
|
+
*/
|
|
39
191
|
private getColorNameByValue;
|
|
192
|
+
/**
|
|
193
|
+
* Finds the AutoCAD color index associated with a given RGB value.
|
|
194
|
+
*
|
|
195
|
+
* @private
|
|
196
|
+
* @param {number} target - The RGB value to find an index for.
|
|
197
|
+
* @returns {number | null} The color index if found, null otherwise.
|
|
198
|
+
*/
|
|
40
199
|
private getColorIndexByValue;
|
|
41
200
|
}
|
|
42
201
|
//# sourceMappingURL=AcCmColor.d.ts.map
|
package/lib/AcCmColor.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AcCmColor.d.ts","sourceRoot":"","sources":["../src/AcCmColor.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"AcCmColor.d.ts","sourceRoot":"","sources":["../src/AcCmColor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAoNH;;;;;GAKG;AACH,qBAAa,SAAS;IACpB,OAAO,CAAC,WAAW,CAAe;IAClC,OAAO,CAAC,MAAM,CAAe;IAC7B,OAAO,CAAC,UAAU,CAAe;IACjC,MAAM,CAAC,KAAK,yBAAiB;IAE7B;;;OAGG;;IAOH;;;;OAIG;IACH,IAAI,KAAK,IASQ,MAAM,GAAG,IAAI,CAP7B;IAED;;;;OAIG;IACH,IAAI,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,EAQ7B;IAED;;;;OAIG;IACH,IAAI,QAAQ,WAWX;IAED;;;;OAIG;IACH,IAAI,QAAQ,WAEX;IAED;;;;OAIG;IACH,IAAI,GAAG,kBAEN;IAED;;;;OAIG;IACH,IAAI,KAAK,kBAER;IAED;;;;OAIG;IACH,IAAI,IAAI,kBAEP;IAED;;;;;OAKG;IACH,IAAI,UAAU,IAaQ,MAAM,GAAG,IAAI,CAXlC;IACD;;;;;;;;;OASG;IACH,IAAI,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,EAQlC;IAED;;;;OAIG;IACH,IAAI,SAAS,IAQQ,MAAM,GAAG,IAAI,CANjC;IACD;;;;OAIG;IACH,IAAI,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,EAejC;IAED;;;;OAIG;IACH,IAAI,YAAY,YAEf;IAED;;;;OAIG;IACH,IAAI,aAAa,YAEhB;IAED;;;;OAIG;IACH,IAAI,SAAS,YAEZ;IACD;;;;OAIG;IACH,UAAU;IAKV;;;;OAIG;IACH,IAAI,SAAS,YAEZ;IACD;;;;OAIG;IACH,UAAU;IAKV;;;;;OAKG;IACH,SAAS,CAAC,MAAM,EAAE,MAAM;IAKxB;;;;;;;OAOG;IACH,MAAM,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM;IAQtC;;;;;OAKG;IACH,YAAY,CAAC,KAAK,EAAE,MAAM;IAY1B;;;;OAIG;IACH,KAAK;IAQL;;;;;OAKG;IACH,IAAI,CAAC,KAAK,EAAE,SAAS;IAOrB;;;;;OAKG;IACH,MAAM,CAAC,CAAC,EAAE,SAAS;IAQnB;;;;OAIG;IACH,QAAQ;IAYR;;;;;;OAMG;IACH,OAAO,CAAC,mBAAmB;IAS3B;;;;;;OAMG;IACH,OAAO,CAAC,oBAAoB;CAS7B"}
|