From 547564579df34da8d6d522d212df78c3313d5ca9 Mon Sep 17 00:00:00 2001 From: Mike <45243121+tankf33der@users.noreply.github.com> Date: Sat, 13 Dec 2025 22:46:17 +0200 Subject: [PATCH] math.easing: fix bounce family, add tests (#25956) --- vlib/math/easing/easing.v | 18 +-- vlib/math/easing/easing_test.v | 17 +++ .../v/slow_tests/inout/math_easing_tables.out | 126 +++++++++--------- vlib/v/slow_tests/inout/math_easing_tables.vv | 66 ++++----- 4 files changed, 119 insertions(+), 108 deletions(-) diff --git a/vlib/math/easing/easing.v b/vlib/math/easing/easing.v index bcb48fc8e..8602ad1b0 100644 --- a/vlib/math/easing/easing.v +++ b/vlib/math/easing/easing.v @@ -244,26 +244,20 @@ pub fn in_bounce(x f64) f64 { // out_bounce returns the equivalent of https://easings.net/#easeOutBounce . pub fn out_bounce(x f64) f64 { - if math.close(x, 1.0) { - return 1.0 - } xd1 := x * d1 - return n1 * (if xd1 < 1.0 { - x * x + return if xd1 < 1.0 { + n1 * x * x } else if xd1 < 2.0 { - pow((x - 1.5 / d1), 2.0) + 0.75 + n1 * pow(x - 1.5 / d1, 2.0) + 0.75 } else if xd1 < 2.5 { - pow((x - 2.25 / d1), 2.0) + 0.9375 + n1 * pow(x - 2.25 / d1, 2.0) + 0.9375 } else { - pow((x - 2.625 / d1), 2.0) + 0.984375 - }) + n1 * pow(x - 2.625 / d1, 2.0) + 0.984375 + } } // in_out_bounce returns the equivalent of https://easings.net/#easeInOutBounce . pub fn in_out_bounce(x f64) f64 { - if math.close(x, 1.0) { - return 1.0 - } return if x < 0.5 { (1.0 - out_bounce(1.0 - 2.0 * x)) / 2.0 } else { diff --git a/vlib/math/easing/easing_test.v b/vlib/math/easing/easing_test.v index 6fd1981e1..1ee7630b3 100644 --- a/vlib/math/easing/easing_test.v +++ b/vlib/math/easing/easing_test.v @@ -18,3 +18,20 @@ fn test_in_out_back() { fn test_in_out_expo() { assert easing.in_out_expo(123).eq_epsilon(1.0) } + +fn test_in_bounce() { + assert easing.in_bounce(0.333).eq_epsilon(0.1382769374999998) + assert easing.in_bounce(33).eq_epsilon(-7743) +} + +fn test_in_out_bounce() { + assert easing.in_out_bounce(0.333).eq_epsilon(0.07817887500000009) + assert easing.in_out_bounce(33).eq_epsilon(15511) +} + +fn test_out_bounce() { + assert easing.out_bounce(0.200).eq_epsilon(0.30250000000000005) + assert easing.out_bounce(0.600).eq_epsilon(0.7725) + assert easing.out_bounce(0.800).eq_epsilon(0.94) + assert easing.out_bounce(33).eq_epsilon(7767) +} diff --git a/vlib/v/slow_tests/inout/math_easing_tables.out b/vlib/v/slow_tests/inout/math_easing_tables.out index 3cc6e5957..f955294b4 100644 --- a/vlib/v/slow_tests/inout/math_easing_tables.out +++ b/vlib/v/slow_tests/inout/math_easing_tables.out @@ -2,77 +2,77 @@ +------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+ | x | linear | sine | quad | cubic | quart | quint | expo | circ | back | elastic | bounce | +------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+ -| -0.5 | -0.500 | 0.293 | 0.250 | -0.125 | 0.063 | -0.031 | 0.000 | 0.134 | -0.763 | 0.000 | -8.694 | -| -0.4 | -0.400 | 0.191 | 0.160 | -0.064 | 0.026 | -0.010 | 0.000 | 0.083 | -0.445 | -0.000 | -7.945 | -| -0.3 | -0.300 | 0.109 | 0.090 | -0.027 | 0.008 | -0.002 | 0.000 | 0.046 | -0.226 | -0.000 | -7.347 | -| -0.2 | -0.200 | 0.049 | 0.040 | -0.008 | 0.002 | -0.000 | 0.000 | 0.020 | -0.090 | 0.000 | -6.900 | -| -0.1 | -0.100 | 0.012 | 0.010 | -0.001 | 0.000 | -0.000 | 0.000 | 0.005 | -0.020 | -0.000 | -6.604 | -| -0.0 | -0.000 | 0.000 | 0.000 | -0.000 | 0.000 | -0.000 | 0.000 | 0.000 | -0.000 | 0.000 | 0.000 | -| 0.1 | 0.100 | 0.012 | 0.010 | 0.001 | 0.000 | 0.000 | 0.002 | 0.005 | -0.014 | 0.002 | -6.140 | -| 0.2 | 0.200 | 0.049 | 0.040 | 0.008 | 0.002 | 0.000 | 0.004 | 0.020 | -0.046 | -0.002 | -6.092 | -| 0.3 | 0.300 | 0.109 | 0.090 | 0.027 | 0.008 | 0.002 | 0.008 | 0.046 | -0.080 | -0.004 | -4.853 | -| 0.4 | 0.400 | 0.191 | 0.160 | 0.064 | 0.026 | 0.010 | 0.016 | 0.083 | -0.099 | 0.016 | -4.694 | -| 0.5 | 0.500 | 0.293 | 0.250 | 0.125 | 0.063 | 0.031 | 0.031 | 0.134 | -0.088 | -0.016 | -4.688 | -| 0.6 | 0.600 | 0.412 | 0.360 | 0.216 | 0.130 | 0.078 | 0.063 | 0.200 | -0.029 | -0.031 | -4.832 | -| 0.7 | 0.700 | 0.546 | 0.490 | 0.343 | 0.240 | 0.168 | 0.125 | 0.286 | 0.093 | 0.125 | 0.319 | -| 0.8 | 0.800 | 0.691 | 0.640 | 0.512 | 0.410 | 0.328 | 0.250 | 0.400 | 0.294 | -0.125 | 0.697 | -| 0.9 | 0.900 | 0.844 | 0.810 | 0.729 | 0.656 | 0.590 | 0.500 | 0.564 | 0.591 | -0.250 | 0.924 | -| 1.0 | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 | -| 1.1 | 1.100 | 1.156 | 1.210 | 1.331 | 1.464 | 1.611 | 2.000 | nan | 1.537 | -1.000 | 0.924 | -| 1.2 | 1.200 | 1.309 | 1.440 | 1.728 | 2.074 | 2.488 | 4.000 | nan | 2.218 | -2.000 | 0.698 | -| 1.3 | 1.300 | 1.454 | 1.690 | 2.197 | 2.856 | 3.713 | 8.000 | nan | 3.060 | 8.000 | 0.319 | -| 1.4 | 1.400 | 1.588 | 1.960 | 2.744 | 3.842 | 5.378 | 16.000 | nan | 4.078 | -8.000 | -0.210 | -| 1.5 | 1.500 | 1.707 | 2.250 | 3.375 | 5.063 | 7.594 | 32.000 | nan | 5.289 | -16.000 | -0.891 | +| -0.5 | -0.5000 | 0.2929 | 0.2500 | -0.1250 | 0.0625 | -0.0313 | 0.0000 | 0.1340 | -0.7631 | 0.0000 | -2.2344 | +| -0.4 | -0.4000 | 0.1910 | 0.1600 | -0.0640 | 0.0256 | -0.0102 | 0.0001 | 0.0835 | -0.4452 | -0.0000 | -1.4850 | +| -0.3 | -0.3000 | 0.1090 | 0.0900 | -0.0270 | 0.0081 | -0.0024 | 0.0001 | 0.0461 | -0.2261 | -0.0001 | -0.8869 | +| -0.2 | -0.2000 | 0.0489 | 0.0400 | -0.0080 | 0.0016 | -0.0003 | 0.0002 | 0.0202 | -0.0897 | 0.0002 | -0.4400 | +| -0.1 | -0.1000 | 0.0123 | 0.0100 | -0.0010 | 0.0001 | -0.0000 | 0.0005 | 0.0050 | -0.0197 | -0.0002 | -0.1444 | +| -0.0 | -0.0000 | 0.0000 | 0.0000 | -0.0000 | 0.0000 | -0.0000 | 0.0000 | 0.0000 | -0.0000 | 0.0000 | 0.0000 | +| 0.1 | 0.1000 | 0.0123 | 0.0100 | 0.0010 | 0.0001 | 0.0000 | 0.0020 | 0.0050 | -0.0143 | 0.0020 | 0.0119 | +| 0.2 | 0.2000 | 0.0489 | 0.0400 | 0.0080 | 0.0016 | 0.0003 | 0.0039 | 0.0202 | -0.0465 | -0.0020 | 0.0600 | +| 0.3 | 0.3000 | 0.1090 | 0.0900 | 0.0270 | 0.0081 | 0.0024 | 0.0078 | 0.0461 | -0.0802 | -0.0039 | 0.0694 | +| 0.4 | 0.4000 | 0.1910 | 0.1600 | 0.0640 | 0.0256 | 0.0102 | 0.0156 | 0.0835 | -0.0994 | 0.0156 | 0.2275 | +| 0.5 | 0.5000 | 0.2929 | 0.2500 | 0.1250 | 0.0625 | 0.0313 | 0.0313 | 0.1340 | -0.0877 | -0.0156 | 0.2344 | +| 0.6 | 0.6000 | 0.4122 | 0.3600 | 0.2160 | 0.1296 | 0.0778 | 0.0625 | 0.2000 | -0.0290 | -0.0312 | 0.0900 | +| 0.7 | 0.7000 | 0.5460 | 0.4900 | 0.3430 | 0.2401 | 0.1681 | 0.1250 | 0.2859 | 0.0929 | 0.1250 | 0.3194 | +| 0.8 | 0.8000 | 0.6910 | 0.6400 | 0.5120 | 0.4096 | 0.3277 | 0.2500 | 0.4000 | 0.2942 | -0.1250 | 0.6975 | +| 0.9 | 0.9000 | 0.8436 | 0.8100 | 0.7290 | 0.6561 | 0.5905 | 0.5000 | 0.5641 | 0.5912 | -0.2500 | 0.9244 | +| 1.0 | 1.0000 | 1.0000 | 1.0000 | 1.0000 | 1.0000 | 1.0000 | 1.0000 | 1.0000 | 1.0000 | 1.0000 | 1.0000 | +| 1.1 | 1.1000 | 1.1564 | 1.2100 | 1.3310 | 1.4641 | 1.6105 | 2.0000 | nan | 1.5369 | -1.0000 | 0.9244 | +| 1.2 | 1.2000 | 1.3090 | 1.4400 | 1.7280 | 2.0736 | 2.4883 | 4.0000 | nan | 2.2181 | -2.0000 | 0.6975 | +| 1.3 | 1.3000 | 1.4540 | 1.6900 | 2.1970 | 2.8561 | 3.7129 | 8.0000 | nan | 3.0597 | 8.0000 | 0.3194 | +| 1.4 | 1.4000 | 1.5878 | 1.9600 | 2.7440 | 3.8416 | 5.3782 | 16.0000 | nan | 4.0780 | -8.0000 | -0.2100 | +| 1.5 | 1.5000 | 1.7071 | 2.2500 | 3.3750 | 5.0625 | 7.5938 | 32.0000 | nan | 5.2893 |-16.0000 | -0.8906 | +------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+ out_ functions, compared to the linear one +------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+ | x | linear | sine | quad | cubic | quart | quint | expo | circ | back | elastic | bounce | +------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+ -| -0.5 | -0.500 | -0.707 | -1.250 | -2.375 | -4.063 | -6.594 | -31.000 | nan | -4.289 | 17.000 | 1.891 | -| -0.4 | -0.400 | -0.588 | -0.960 | -1.744 | -2.842 | -4.378 | -15.000 | nan | -3.078 | 9.000 | 1.210 | -| -0.3 | -0.300 | -0.454 | -0.690 | -1.197 | -1.856 | -2.713 | -7.000 | nan | -2.060 | -7.000 | 0.681 | -| -0.2 | -0.200 | -0.309 | -0.440 | -0.728 | -1.074 | -1.488 | -3.000 | nan | -1.218 | 3.000 | 0.303 | -| -0.1 | -0.100 | -0.156 | -0.210 | -0.331 | -0.464 | -0.611 | -1.000 | nan | -0.537 | 2.000 | 0.076 | -| -0.0 | -0.000 | -0.000 | 0.000 | 0.000 | 0.000 | 0.000 | -0.000 | 0.000 | 0.000 | 0.000 | 0.000 | -| 0.1 | 0.100 | 0.156 | 0.190 | 0.271 | 0.344 | 0.410 | 0.500 | 0.436 | 0.409 | 1.250 | 0.076 | -| 0.2 | 0.200 | 0.309 | 0.360 | 0.488 | 0.590 | 0.672 | 0.750 | 0.600 | 0.706 | 1.125 | 0.302 | -| 0.3 | 0.300 | 0.454 | 0.510 | 0.657 | 0.760 | 0.832 | 0.875 | 0.714 | 0.907 | 0.875 | 0.681 | -| 0.4 | 0.400 | 0.588 | 0.640 | 0.784 | 0.870 | 0.922 | 0.938 | 0.800 | 1.029 | 1.031 | 5.832 | -| 0.5 | 0.500 | 0.707 | 0.750 | 0.875 | 0.938 | 0.969 | 0.969 | 0.866 | 1.088 | 1.016 | 5.688 | -| 0.6 | 0.600 | 0.809 | 0.840 | 0.936 | 0.974 | 0.990 | 0.984 | 0.917 | 1.099 | 0.984 | 5.694 | -| 0.7 | 0.700 | 0.891 | 0.910 | 0.973 | 0.992 | 0.998 | 0.992 | 0.954 | 1.080 | 1.004 | 5.853 | -| 0.8 | 0.800 | 0.951 | 0.960 | 0.992 | 0.998 | 1.000 | 0.996 | 0.980 | 1.046 | 1.002 | 7.092 | -| 0.9 | 0.900 | 0.988 | 0.990 | 0.999 | 1.000 | 1.000 | 0.998 | 0.995 | 1.014 | 0.998 | 7.140 | -| 1.0 | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 | -| 1.1 | 1.100 | 0.988 | 0.990 | 1.001 | 1.000 | 1.000 | 1.000 | 0.995 | 1.020 | 1.000 | 7.604 | -| 1.2 | 1.200 | 0.951 | 0.960 | 1.008 | 0.998 | 1.000 | 1.000 | 0.980 | 1.090 | 1.000 | 7.900 | -| 1.3 | 1.300 | 0.891 | 0.910 | 1.027 | 0.992 | 1.002 | 1.000 | 0.954 | 1.226 | 1.000 | 8.347 | -| 1.4 | 1.400 | 0.809 | 0.840 | 1.064 | 0.974 | 1.010 | 1.000 | 0.917 | 1.445 | 1.000 | 8.945 | -| 1.5 | 1.500 | 0.707 | 0.750 | 1.125 | 0.937 | 1.031 | 1.000 | 0.866 | 1.763 | 1.000 | 9.694 | +| -0.5 | -0.5000 | -0.7071 | -1.2500 | -2.3750 | -4.0625 | -6.5938 |-31.0000 | nan | -4.2893 | 17.0000 | 1.8906 | +| -0.4 | -0.4000 | -0.5878 | -0.9600 | -1.7440 | -2.8416 | -4.3782 |-15.0000 | nan | -3.0780 | 9.0000 | 1.2100 | +| -0.3 | -0.3000 | -0.4540 | -0.6900 | -1.1970 | -1.8561 | -2.7129 | -7.0000 | nan | -2.0597 | -7.0000 | 0.6806 | +| -0.2 | -0.2000 | -0.3090 | -0.4400 | -0.7280 | -1.0736 | -1.4883 | -3.0000 | nan | -1.2181 | 3.0000 | 0.3025 | +| -0.1 | -0.1000 | -0.1564 | -0.2100 | -0.3310 | -0.4641 | -0.6105 | -1.0000 | nan | -0.5369 | 2.0000 | 0.0756 | +| -0.0 | -0.0000 | -0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | -0.0000 | 0.0000 | 0.0000 | 0.0000 | 0.0000 | +| 0.1 | 0.1000 | 0.1564 | 0.1900 | 0.2710 | 0.3439 | 0.4095 | 0.5000 | 0.4359 | 0.4088 | 1.2500 | 0.0756 | +| 0.2 | 0.2000 | 0.3090 | 0.3600 | 0.4880 | 0.5904 | 0.6723 | 0.7500 | 0.6000 | 0.7058 | 1.1250 | 0.3025 | +| 0.3 | 0.3000 | 0.4540 | 0.5100 | 0.6570 | 0.7599 | 0.8319 | 0.8750 | 0.7141 | 0.9071 | 0.8750 | 0.6806 | +| 0.4 | 0.4000 | 0.5878 | 0.6400 | 0.7840 | 0.8704 | 0.9222 | 0.9375 | 0.8000 | 1.0290 | 1.0313 | 0.9100 | +| 0.5 | 0.5000 | 0.7071 | 0.7500 | 0.8750 | 0.9375 | 0.9688 | 0.9688 | 0.8660 | 1.0877 | 1.0156 | 0.7656 | +| 0.6 | 0.6000 | 0.8090 | 0.8400 | 0.9360 | 0.9744 | 0.9898 | 0.9844 | 0.9165 | 1.0994 | 0.9844 | 0.7725 | +| 0.7 | 0.7000 | 0.8910 | 0.9100 | 0.9730 | 0.9919 | 0.9976 | 0.9922 | 0.9539 | 1.0802 | 1.0039 | 0.9306 | +| 0.8 | 0.8000 | 0.9511 | 0.9600 | 0.9920 | 0.9984 | 0.9997 | 0.9961 | 0.9798 | 1.0465 | 1.0020 | 0.9400 | +| 0.9 | 0.9000 | 0.9877 | 0.9900 | 0.9990 | 0.9999 | 1.0000 | 0.9980 | 0.9950 | 1.0143 | 0.9980 | 0.9881 | +| 1.0 | 1.0000 | 1.0000 | 1.0000 | 1.0000 | 1.0000 | 1.0000 | 1.0000 | 1.0000 | 1.0000 | 1.0000 | 1.0000 | +| 1.1 | 1.1000 | 0.9877 | 0.9900 | 1.0010 | 0.9999 | 1.0000 | 0.9995 | 0.9950 | 1.0197 | 1.0002 | 1.1444 | +| 1.2 | 1.2000 | 0.9511 | 0.9600 | 1.0080 | 0.9984 | 1.0003 | 0.9998 | 0.9798 | 1.0897 | 0.9998 | 1.4400 | +| 1.3 | 1.3000 | 0.8910 | 0.9100 | 1.0270 | 0.9919 | 1.0024 | 0.9999 | 0.9539 | 1.2261 | 1.0001 | 1.8869 | +| 1.4 | 1.4000 | 0.8090 | 0.8400 | 1.0640 | 0.9744 | 1.0102 | 0.9999 | 0.9165 | 1.4452 | 1.0000 | 2.4850 | +| 1.5 | 1.5000 | 0.7071 | 0.7500 | 1.1250 | 0.9375 | 1.0313 | 1.0000 | 0.8660 | 1.7631 | 1.0000 | 3.2344 | +------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+ in_out_ functions, compared to the linear one +------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+ | x | linear | sine | quad | cubic | quart | quint | expo | circ | back | elastic | bounce | +------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+ -| -0.5 | -0.500 | 0.500 | 0.500 | -0.500 | 0.500 | -0.500 | 0.000 | 0.500 | -3.095 | -0.000 | -7.355 | -| -0.4 | -0.400 | 0.345 | 0.320 | -0.256 | 0.205 | -0.164 | 0.000 | 0.200 | -1.751 | 0.000 | -5.925 | -| -0.3 | -0.300 | 0.206 | 0.180 | -0.108 | 0.065 | -0.039 | 0.000 | 0.100 | -0.855 | -0.000 | -4.797 | -| -0.2 | -0.200 | 0.095 | 0.080 | -0.032 | 0.013 | -0.005 | 0.000 | 0.042 | -0.323 | 0.000 | -3.972 | -| -0.1 | -0.100 | 0.024 | 0.020 | -0.004 | 0.001 | -0.000 | 0.000 | 0.010 | -0.066 | -0.000 | -3.450 | -| -0.0 | -0.000 | -0.000 | 0.000 | -0.000 | 0.000 | -0.000 | 0.000 | 0.000 | -0.000 | 0.000 | 0.000 | -| 0.1 | 0.100 | 0.024 | 0.020 | 0.004 | 0.001 | 0.000 | 0.002 | 0.010 | -0.038 | 0.000 | -3.046 | -| 0.2 | 0.200 | 0.095 | 0.080 | 0.032 | 0.013 | 0.005 | 0.008 | 0.042 | -0.093 | -0.004 | -2.347 | -| 0.3 | 0.300 | 0.206 | 0.180 | 0.108 | 0.065 | 0.039 | 0.031 | 0.100 | -0.079 | 0.024 | -2.416 | -| 0.4 | 0.400 | 0.345 | 0.320 | 0.256 | 0.205 | 0.164 | 0.125 | 0.200 | 0.090 | -0.117 | 0.349 | -| 0.5 | 0.500 | 0.500 | 0.500 | 0.500 | 0.500 | 0.500 | 0.500 | 0.500 | 0.500 | 0.500 | 0.500 | -| 0.6 | 0.600 | 0.655 | 0.680 | 0.744 | 0.795 | 0.836 | 0.875 | 0.800 | 0.910 | 1.117 | 0.651 | -| 0.7 | 0.700 | 0.794 | 0.820 | 0.892 | 0.935 | 0.961 | 0.969 | 0.900 | 1.079 | 0.976 | 3.416 | -| 0.8 | 0.800 | 0.905 | 0.920 | 0.968 | 0.987 | 0.995 | 0.992 | 0.958 | 1.093 | 1.004 | 3.347 | -| 0.9 | 0.900 | 0.976 | 0.980 | 0.996 | 0.999 | 1.000 | 0.998 | 0.990 | 1.038 | 1.000 | 4.046 | -| 1.0 | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 | -| 1.1 | 1.100 | 0.976 | 0.980 | 1.004 | 0.999 | 1.000 | 1.000 | 0.990 | 1.066 | 1.000 | 4.450 | -| 1.2 | 1.200 | 0.905 | 0.920 | 1.032 | 0.987 | 1.005 | 1.000 | 0.958 | 1.323 | 1.000 | 4.972 | -| 1.3 | 1.300 | 0.794 | 0.820 | 1.108 | 0.935 | 1.039 | 1.000 | 0.900 | 1.855 | 1.000 | 5.797 | -| 1.4 | 1.400 | 0.655 | 0.680 | 1.256 | 0.795 | 1.164 | 1.000 | 0.800 | 2.751 | 1.000 | 6.925 | -| 1.5 | 1.500 | 0.500 | 0.500 | 1.500 | 0.500 | 1.500 | 1.000 | nan | 4.095 | 1.000 | 8.355 | +| -0.5 | -0.5000 | 0.5000 | 0.5000 | -0.5000 | 0.5000 | -0.5000 | 0.0000 | 0.5000 | -3.0949 | -0.0000 | -4.1250 | +| -0.4 | -0.4000 | 0.3455 | 0.3200 | -0.2560 | 0.2048 | -0.1638 | 0.0000 | 0.2000 | -1.7507 | 0.0000 | -2.6950 | +| -0.3 | -0.3000 | 0.2061 | 0.1800 | -0.1080 | 0.0648 | -0.0389 | 0.0000 | 0.1000 | -0.8553 | -0.0000 | -1.5675 | +| -0.2 | -0.2000 | 0.0955 | 0.0800 | -0.0320 | 0.0128 | -0.0051 | 0.0000 | 0.0417 | -0.3226 | 0.0000 | -0.7425 | +| -0.1 | -0.1000 | 0.0245 | 0.0200 | -0.0040 | 0.0008 | -0.0002 | 0.0001 | 0.0101 | -0.0663 | -0.0001 | -0.2200 | +| -0.0 | -0.0000 | -0.0000 | 0.0000 | -0.0000 | 0.0000 | -0.0000 | 0.0000 | 0.0000 | -0.0000 | 0.0000 | 0.0000 | +| 0.1 | 0.1000 | 0.0245 | 0.0200 | 0.0040 | 0.0008 | 0.0002 | 0.0020 | 0.0101 | -0.0375 | 0.0003 | 0.0300 | +| 0.2 | 0.2000 | 0.0955 | 0.0800 | 0.0320 | 0.0128 | 0.0051 | 0.0078 | 0.0417 | -0.0926 | -0.0039 | 0.1137 | +| 0.3 | 0.3000 | 0.2061 | 0.1800 | 0.1080 | 0.0648 | 0.0389 | 0.0313 | 0.1000 | -0.0788 | 0.0239 | 0.0450 | +| 0.4 | 0.4000 | 0.3455 | 0.3200 | 0.2560 | 0.2048 | 0.1638 | 0.1250 | 0.2000 | 0.0899 | -0.1175 | 0.3488 | +| 0.5 | 0.5000 | 0.5000 | 0.5000 | 0.5000 | 0.5000 | 0.5000 | 0.5000 | 0.5000 | 0.5000 | 0.5000 | 0.5000 | +| 0.6 | 0.6000 | 0.6545 | 0.6800 | 0.7440 | 0.7952 | 0.8362 | 0.8750 | 0.8000 | 0.9101 | 1.1175 | 0.6512 | +| 0.7 | 0.7000 | 0.7939 | 0.8200 | 0.8920 | 0.9352 | 0.9611 | 0.9688 | 0.9000 | 1.0788 | 0.9761 | 0.9550 | +| 0.8 | 0.8000 | 0.9045 | 0.9200 | 0.9680 | 0.9872 | 0.9949 | 0.9922 | 0.9583 | 1.0926 | 1.0039 | 0.8863 | +| 0.9 | 0.9000 | 0.9755 | 0.9800 | 0.9960 | 0.9992 | 0.9998 | 0.9980 | 0.9899 | 1.0375 | 0.9997 | 0.9700 | +| 1.0 | 1.0000 | 1.0000 | 1.0000 | 1.0000 | 1.0000 | 1.0000 | 1.0000 | 1.0000 | 1.0000 | 1.0000 | 1.0000 | +| 1.1 | 1.1000 | 0.9755 | 0.9800 | 1.0040 | 0.9992 | 1.0002 | 0.9999 | 0.9899 | 1.0663 | 1.0001 | 1.2200 | +| 1.2 | 1.2000 | 0.9045 | 0.9200 | 1.0320 | 0.9872 | 1.0051 | 1.0000 | 0.9583 | 1.3226 | 1.0000 | 1.7425 | +| 1.3 | 1.3000 | 0.7939 | 0.8200 | 1.1080 | 0.9352 | 1.0389 | 1.0000 | 0.9000 | 1.8553 | 1.0000 | 2.5675 | +| 1.4 | 1.4000 | 0.6545 | 0.6800 | 1.2560 | 0.7952 | 1.1638 | 1.0000 | 0.8000 | 2.7507 | 1.0000 | 3.6950 | +| 1.5 | 1.5000 | 0.5000 | 0.5000 | 1.5000 | 0.5000 | 1.5000 | 1.0000 | nan | 4.0949 | 1.0000 | 5.1250 | +------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+ diff --git a/vlib/v/slow_tests/inout/math_easing_tables.vv b/vlib/v/slow_tests/inout/math_easing_tables.vv index 07e6a2445..bd2847eac 100644 --- a/vlib/v/slow_tests/inout/math_easing_tables.vv +++ b/vlib/v/slow_tests/inout/math_easing_tables.vv @@ -19,51 +19,51 @@ fn main() { header('in_ functions, compared to the linear one') for x := min_x; x <= max_x; x += step_x { print('|${x:5.1f} |') - print('${easing.linear(x):8.3f} |') - print('${easing.in_sine(x):8.3f} |') - print('${easing.in_quad(x):8.3f} |') - print('${easing.in_cubic(x):8.3f} |') - print('${easing.in_quart(x):8.3f} |') - print('${easing.in_quint(x):8.3f} |') - print('${easing.in_expo(x):8.3f} |') - print('${easing.in_circ(x):8.3f} |') - print('${easing.in_back(x):8.3f} |') - print('${easing.in_elastic(x):8.3f} |') - print('${easing.in_bounce(x):8.3f} |') + print('${easing.linear(x):8.4f} |') + print('${easing.in_sine(x):8.4f} |') + print('${easing.in_quad(x):8.4f} |') + print('${easing.in_cubic(x):8.4f} |') + print('${easing.in_quart(x):8.4f} |') + print('${easing.in_quint(x):8.4f} |') + print('${easing.in_expo(x):8.4f} |') + print('${easing.in_circ(x):8.4f} |') + print('${easing.in_back(x):8.4f} |') + print('${easing.in_elastic(x):8.4f} |') + print('${easing.in_bounce(x):8.4f} |') println('') } hline() header('out_ functions, compared to the linear one') for x := min_x; x <= max_x; x += step_x { print('|${x:5.1f} |') - print('${easing.linear(x):8.3f} |') - print('${easing.out_sine(x):8.3f} |') - print('${easing.out_quad(x):8.3f} |') - print('${easing.out_cubic(x):8.3f} |') - print('${easing.out_quart(x):8.3f} |') - print('${easing.out_quint(x):8.3f} |') - print('${easing.out_expo(x):8.3f} |') - print('${easing.out_circ(x):8.3f} |') - print('${easing.out_back(x):8.3f} |') - print('${easing.out_elastic(x):8.3f} |') - print('${easing.out_bounce(x):8.3f} |') + print('${easing.linear(x):8.4f} |') + print('${easing.out_sine(x):8.4f} |') + print('${easing.out_quad(x):8.4f} |') + print('${easing.out_cubic(x):8.4f} |') + print('${easing.out_quart(x):8.4f} |') + print('${easing.out_quint(x):8.4f} |') + print('${easing.out_expo(x):8.4f} |') + print('${easing.out_circ(x):8.4f} |') + print('${easing.out_back(x):8.4f} |') + print('${easing.out_elastic(x):8.4f} |') + print('${easing.out_bounce(x):8.4f} |') println('') } hline() header('in_out_ functions, compared to the linear one') for x := min_x; x <= max_x; x += step_x { print('|${x:5.1f} |') - print('${easing.linear(x):8.3f} |') - print('${easing.in_out_sine(x):8.3f} |') - print('${easing.in_out_quad(x):8.3f} |') - print('${easing.in_out_cubic(x):8.3f} |') - print('${easing.in_out_quart(x):8.3f} |') - print('${easing.in_out_quint(x):8.3f} |') - print('${easing.in_out_expo(x):8.3f} |') - print('${easing.in_out_circ(x):8.3f} |') - print('${easing.in_out_back(x):8.3f} |') - print('${easing.in_out_elastic(x):8.3f} |') - print('${easing.in_out_bounce(x):8.3f} |') + print('${easing.linear(x):8.4f} |') + print('${easing.in_out_sine(x):8.4f} |') + print('${easing.in_out_quad(x):8.4f} |') + print('${easing.in_out_cubic(x):8.4f} |') + print('${easing.in_out_quart(x):8.4f} |') + print('${easing.in_out_quint(x):8.4f} |') + print('${easing.in_out_expo(x):8.4f} |') + print('${easing.in_out_circ(x):8.4f} |') + print('${easing.in_out_back(x):8.4f} |') + print('${easing.in_out_elastic(x):8.4f} |') + print('${easing.in_out_bounce(x):8.4f} |') println('') } hline() -- 2.39.5