From 3f1028cf98ddcf2dccf43bc157e5a8c2f1896e5b Mon Sep 17 00:00:00 2001 From: Shallowmallow Date: Sun, 14 Jan 2024 10:30:03 +0100 Subject: [PATCH 1/4] No need of SIGNIFICANT_DECIMAL_DIGITS --- haxe/ui/util/MathUtil.hx | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/haxe/ui/util/MathUtil.hx b/haxe/ui/util/MathUtil.hx index 5c0aae0f9..a2035b685 100644 --- a/haxe/ui/util/MathUtil.hx +++ b/haxe/ui/util/MathUtil.hx @@ -3,8 +3,7 @@ package haxe.ui.util; class MathUtil { public static inline var MAX_INT:Int = 2147483647; // 2**31 - 1 public static inline var MIN_INT:Int = -2147483648; - public static inline var SIGNIFICANT_DECIMAL_DIGITS:Int = 7; // 32 bit floats have 24 bits precision log10(2**24) ≈ 7.225 (for 64 bits it's 15) - public static inline var MAX_FLOAT_DIFFERENCE:Float = 0.0000001; // account for floating-point inaccuracy + public static inline var MAX_FLOAT_DIFFERENCE:Float = 0.0000001; // account for floating-point inaccuracy, 32 bit floats have 24 bits precision log10(2**24) ≈ 7.225 (for 64 bits it's 15) public static inline function distance(x1:Float, y1:Float, x2:Float, y2:Float):Float { return Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)); @@ -24,7 +23,7 @@ class MathUtil { if (!Math.isFinite(v1) || !Math.isFinite(v2)) { return Math.NaN; } - var p = Std.int(Math.min(SIGNIFICANT_DECIMAL_DIGITS, Math.max(precision(v1), precision(v2)))); + var p = Std.int(Math.max(precision(v1), precision(v2))); var e = 1; for ( i in 0...p) { e *= 10; @@ -42,7 +41,7 @@ class MathUtil { if (!Math.isFinite(v) || !Math.isFinite(n)) { return Math.NaN; } - var p = Std.int(Math.min(SIGNIFICANT_DECIMAL_DIGITS, Math.max(precision(v), precision(n)))); + var p = Std.int(Math.max(precision(v), precision(n))); var inv = 1.0 / n; return round(Math.fround(v * inv) / inv, p); } From b2e2b39b954c687a68c2c5f3796e5b6979d8c3a6 Mon Sep 17 00:00:00 2001 From: Shallowmallow Date: Sun, 14 Jan 2024 10:32:40 +0100 Subject: [PATCH 2/4] docs corrections --- haxe/ui/core/Component.hx | 4 ++-- haxe/ui/styles/Style.hx | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/haxe/ui/core/Component.hx b/haxe/ui/core/Component.hx index 9cec9ee48..a4deb4cca 100644 --- a/haxe/ui/core/Component.hx +++ b/haxe/ui/core/Component.hx @@ -1645,8 +1645,8 @@ class Component extends ComponentImpl /** The gap between the component and its children, on the right side **/ @:style(layout) public var paddingTop:Null; /** The gap between the component and its children, on the bottom **/ @:style(layout) public var paddingBottom:Null; - /** The gap between the component and its children, on the top **/ @:style(layout) public var horizontalSpacing:Null; - /** The gap between the component and its children, on the left side **/ @:style(layout) public var verticalSpacing:Null; + /** The horizontal spacing between the component's children in pixels **/ @:style(layout) public var horizontalSpacing:Null; + /** The vertical spacing between the component's children in pixels **/ @:style(layout) public var verticalSpacing:Null; /** The amount of left offsetting to apply to the calculated position **/ @:style public var marginLeft:Null; /** The amount of right offsetting to apply to the calculated position**/ @:style public var marginRight:Null; diff --git a/haxe/ui/styles/Style.hx b/haxe/ui/styles/Style.hx index a8c51be50..68563aa1e 100644 --- a/haxe/ui/styles/Style.hx +++ b/haxe/ui/styles/Style.hx @@ -56,8 +56,8 @@ class Style { /** The amount of right offset to apply to the calculated position **/ @:optional public var marginRight:Null; /** The amount of bottom offset to apply to the calculated position **/ @:optional public var marginBottom:Null; - /** The vertical spacing between the component's children in pixels**/ @:optional public var horizontalSpacing:Null; - /** The horizontal spacing between the component's children in pixels**/ @:optional public var verticalSpacing:Null; + /** The horizontal spacing between the component's children in pixels**/ @:optional public var horizontalSpacing:Null; + /** The vertical spacing between the component's children in pixels**/ @:optional public var verticalSpacing:Null; /** The color of the text **/ @:optional public var color:Null; From ff396d3a859bc0b6d1de16ff9bbb45cacd1064f6 Mon Sep 17 00:00:00 2001 From: Shallowmallow Date: Sun, 14 Jan 2024 11:32:26 +0100 Subject: [PATCH 3/4] Comment --- haxe/ui/util/MathUtil.hx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/haxe/ui/util/MathUtil.hx b/haxe/ui/util/MathUtil.hx index a2035b685..9b099cd4d 100644 --- a/haxe/ui/util/MathUtil.hx +++ b/haxe/ui/util/MathUtil.hx @@ -9,6 +9,10 @@ class MathUtil { return Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)); } + /** + Precision is the number of significant decimal digits + Returns a precision between 0 and 7 + **/ public static inline function precision(v:Float):Int { var e = 1; var p = 0; From b13073f98d51cf6798f7d0ee1f37413871406d0c Mon Sep 17 00:00:00 2001 From: Shallowmallow Date: Sun, 14 Jan 2024 11:35:20 +0100 Subject: [PATCH 4/4] formatting --- haxe/ui/styles/Style.hx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/haxe/ui/styles/Style.hx b/haxe/ui/styles/Style.hx index 68563aa1e..f17e191a7 100644 --- a/haxe/ui/styles/Style.hx +++ b/haxe/ui/styles/Style.hx @@ -56,8 +56,8 @@ class Style { /** The amount of right offset to apply to the calculated position **/ @:optional public var marginRight:Null; /** The amount of bottom offset to apply to the calculated position **/ @:optional public var marginBottom:Null; - /** The horizontal spacing between the component's children in pixels**/ @:optional public var horizontalSpacing:Null; - /** The vertical spacing between the component's children in pixels**/ @:optional public var verticalSpacing:Null; + /** The horizontal spacing between the component's children in pixels**/ @:optional public var horizontalSpacing:Null; + /** The vertical spacing between the component's children in pixels**/ @:optional public var verticalSpacing:Null; /** The color of the text **/ @:optional public var color:Null;