@inweb/markup 25.8.19 → 25.8.21

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.
Files changed (48) hide show
  1. package/dist/markup.js +94 -57
  2. package/dist/markup.js.map +1 -1
  3. package/dist/markup.min.js +1 -1
  4. package/dist/markup.module.js +87 -37
  5. package/dist/markup.module.js.map +1 -1
  6. package/lib/index.d.ts +1 -1
  7. package/lib/markup/IMarkup.d.ts +27 -16
  8. package/lib/markup/IMarkupArrow.d.ts +8 -16
  9. package/lib/markup/IMarkupCloud.d.ts +9 -18
  10. package/lib/markup/IMarkupColorable.d.ts +5 -4
  11. package/lib/markup/IMarkupEllipse.d.ts +9 -18
  12. package/lib/markup/IMarkupImage.d.ts +14 -17
  13. package/lib/markup/IMarkupLine.d.ts +44 -11
  14. package/lib/markup/IMarkupObject.d.ts +25 -15
  15. package/lib/markup/IMarkupRectangle.d.ts +9 -18
  16. package/lib/markup/IMarkupText.d.ts +7 -14
  17. package/lib/markup/IWorldTransform.d.ts +1 -1
  18. package/lib/markup/Konva/KonvaArrow.d.ts +2 -2
  19. package/lib/markup/Konva/KonvaCloud.d.ts +1 -1
  20. package/lib/markup/Konva/KonvaEllipse.d.ts +2 -2
  21. package/lib/markup/Konva/KonvaImage.d.ts +4 -2
  22. package/lib/markup/Konva/KonvaLine.d.ts +2 -11
  23. package/lib/markup/Konva/KonvaMarkup.d.ts +2 -2
  24. package/lib/markup/Konva/KonvaRectangle.d.ts +1 -1
  25. package/lib/markup/Konva/KonvaText.d.ts +2 -2
  26. package/lib/markup/Konva/MarkupColor.d.ts +19 -18
  27. package/package.json +3 -3
  28. package/src/index.ts +1 -1
  29. package/src/markup/IMarkup.ts +28 -16
  30. package/src/markup/IMarkupArrow.ts +8 -16
  31. package/src/markup/IMarkupCloud.ts +9 -18
  32. package/src/markup/IMarkupColorable.ts +5 -4
  33. package/src/markup/IMarkupEllipse.ts +9 -18
  34. package/src/markup/IMarkupImage.ts +14 -17
  35. package/src/markup/IMarkupLine.ts +46 -11
  36. package/src/markup/IMarkupObject.ts +25 -15
  37. package/src/markup/IMarkupRectangle.ts +9 -18
  38. package/src/markup/IMarkupText.ts +7 -14
  39. package/src/markup/IWorldTransform.ts +1 -1
  40. package/src/markup/Konva/KonvaArrow.ts +6 -4
  41. package/src/markup/Konva/KonvaCloud.ts +4 -3
  42. package/src/markup/Konva/KonvaEllipse.ts +6 -4
  43. package/src/markup/Konva/KonvaImage.ts +27 -14
  44. package/src/markup/Konva/KonvaLine.ts +9 -13
  45. package/src/markup/Konva/KonvaMarkup.ts +15 -15
  46. package/src/markup/Konva/KonvaRectangle.ts +3 -2
  47. package/src/markup/Konva/KonvaText.ts +6 -4
  48. package/src/markup/Konva/MarkupColor.ts +22 -23
@@ -22,57 +22,56 @@
22
22
  ///////////////////////////////////////////////////////////////////////////////
23
23
 
24
24
  /**
25
- * Markup color.
25
+ * Defines the markup color helper object.
26
26
  */
27
27
  export class MarkupColor {
28
28
  public R: number;
29
29
  public G: number;
30
30
  public B: number;
31
-
32
- private _hex: string;
31
+ public HEX: string;
33
32
 
34
33
  /**
35
- * Color in #000000 format
34
+ * Creates an instance of the color.
35
+ *
36
+ * @param r - The `red` component of the color, as a number between 0 and 255.
37
+ * @param g - The `green` component of the color, as a number between 0 and 255.
38
+ * @param b - The `blue` component of the color, as a number between 0 and 255.
36
39
  */
37
- get HexColor(): string {
38
- return "#" + this._hex;
40
+ constructor(r: number, g: number, b: number) {
41
+ this.setColor(r, g, b);
39
42
  }
40
43
 
41
44
  /**
42
- * Color as object with r,g,b properties
45
+ * Returns the color as a string in hexadecimal color syntax `#RGB` using its primary color
46
+ * components (red, green, blue) written as hexadecimal numbers.
43
47
  */
44
- get RGB(): { r: number; g: number; b: number } {
45
- return { r: this.R, g: this.G, b: this.B };
48
+ public asHex(): string {
49
+ return "#" + this.HEX;
46
50
  }
47
51
 
48
52
  /**
49
- * Create an instance of Color
50
- *
51
- * @param r - Red color in [0,255] range
52
- * @param g - Green color in [0,255] range
53
- * @param b - Blue color in [0,255] range
53
+ * Returns the color as an {r, g, b} object.
54
54
  */
55
- constructor(r: number, g: number, b: number) {
56
- this.setColor(r, g, b);
55
+ public asRGB(): { r: number; g: number; b: number } {
56
+ return { r: this.R, g: this.G, b: this.B };
57
57
  }
58
58
 
59
59
  /**
60
- * Set Color for current instance
60
+ * Sets the color.
61
61
  *
62
- * @param r - Red color in [0,255] range
63
- * @param g - Green color in [0,255] range
64
- * @param b - Blue color in [0,255] range
62
+ * @param r - The `red` component of the color, as a number between 0 and 255.
63
+ * @param g - The `green` component of the color, as a number between 0 and 255.
64
+ * @param b - The `blue` component of the color, as a number between 0 and 255.
65
65
  */
66
66
  public setColor(r: number, g: number, b: number): void {
67
67
  this.R = r;
68
68
  this.G = g;
69
69
  this.B = b;
70
-
71
- this._hex = this.rgbToHex(r, g, b);
70
+ this.HEX = this.rgbToHex(r, g, b);
72
71
  }
73
72
 
74
73
  private rgbToHex(r: number, g: number, b: number): string {
75
- const valueToHex = (c) => {
74
+ const valueToHex = (c: number) => {
76
75
  const hex = c.toString(16);
77
76
  return hex === "0" ? "00" : hex;
78
77
  };