@urso/core 0.7.31 → 0.7.33

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@urso/core",
3
- "version": "0.7.31",
3
+ "version": "0.7.33",
4
4
  "description": "HTML5 game engine",
5
5
  "main": "build/js/index.js",
6
6
  "author": "Megbrimef",
@@ -599,6 +599,67 @@ class LibHelper {
599
599
 
600
600
  return string
601
601
  }
602
+
603
+ /**
604
+ * Converts color number to object that contents RGB values
605
+ * @param { Number } color - color number
606
+ * @returns { Object }
607
+ */
608
+ getRGB(color) {
609
+ return {
610
+ alpha: 16777215 < color ? color >>> 24 : 255,
611
+ red: color >> 16 & 255,
612
+ green: color >> 8 & 255,
613
+ blue: 255 & color
614
+ };
615
+ }
616
+
617
+ /**
618
+ * Converts RGB values to 32 bit
619
+ * @param { Number } alpha
620
+ * @param { Number } red
621
+ * @param { Number } green
622
+ * @param { Number } blue
623
+ * @returns { Number }
624
+ */
625
+ getColor32(alpha, red, green, blue) {
626
+ return alpha << 24 | red << 16 | green << 8 | blue;
627
+ }
628
+
629
+ /**
630
+ * Returns color interpolation depends on step value
631
+ * @param { Number } startColor
632
+ * @param { Number } targetColor
633
+ * @param { Number } step - intermediate value from 0 to 1
634
+ * @returns { Number }
635
+ */
636
+ interpolateColor32(startColor, targetColor, step) {
637
+ if(startColor === targetColor)
638
+ return startColor;
639
+
640
+ const startColorRGB = this.getRGB(startColor);
641
+ const targetColorRGB = this.getRGB(targetColor);
642
+ const nextColorRGB = this.interpolateColorRGB(startColorRGB, targetColorRGB, step);
643
+ const color32 = this.getColor32(255, nextColorRGB.red, nextColorRGB.green, nextColorRGB.blue);
644
+ return 16777215 + color32;
645
+ }
646
+
647
+ /**
648
+ * Returns color interpolation as RGB object depends on step value
649
+ * @param { Object } startColorRGB - object that contents start values for red, green and blue
650
+ * @param { Object } targetColorRGB - object that contents target values for red, green and blue
651
+ * @param { Number } step - intermediate value from 0 to 1
652
+ * @returns { Object }
653
+ */
654
+ interpolateColorRGB(startColorRGB, targetColorRGB, step) {
655
+ const nextRGB = {};
656
+
657
+ Object.keys(startColorRGB).forEach(color => {
658
+ nextRGB[color] = (targetColorRGB[color] - startColorRGB[color]) * step + startColorRGB[color];
659
+ });
660
+
661
+ return nextRGB;
662
+ }
602
663
  }
603
664
 
604
665
  module.exports = LibHelper;
@@ -195,6 +195,12 @@ class ModulesObjectsBaseModel {
195
195
 
196
196
  return newTexture;
197
197
  }
198
+
199
+ // sorts children by zIndex
200
+ sortChildren() {
201
+ if(this._baseObject.children?.length > 0)
202
+ this._baseObject.sortChildren();
203
+ }
198
204
  }
199
205
 
200
206
  module.exports = ModulesObjectsBaseModel;
@@ -233,7 +233,7 @@ class ModulesObjectsProxy {
233
233
  'class': 'class',
234
234
  'x': 'x',
235
235
  'y': 'y',
236
- 'z': 'z',
236
+ 'z': 'zIndex',
237
237
  'angle': 'angle',
238
238
  'anchorX': 'anchor.x', //'anchor.x',
239
239
  'anchorY': 'anchor.y', //'anchor.y',