| 1 | module gg |
| 2 | |
| 3 | import math |
| 4 | |
| 5 | const rect_empty_bounds_tolerance = f32(0.001) |
| 6 | |
| 7 | fn rect_empty_bounds_match(a f32, b f32) bool { |
| 8 | return math.abs(a - b) <= rect_empty_bounds_tolerance |
| 9 | } |
| 10 | |
| 11 | fn test_rect_empty_screen_bounds_keep_the_top_left_corner_aligned() { |
| 12 | tleft_x, tleft_y, bright_x, bright_y := rect_empty_screen_bounds(1.0, 12, 34, 56, 78) |
| 13 | assert rect_empty_bounds_match(tleft_x, 12.1) |
| 14 | assert rect_empty_bounds_match(tleft_y, 34.1) |
| 15 | assert rect_empty_bounds_match(bright_x, 67.9) |
| 16 | assert rect_empty_bounds_match(bright_y, 111.9) |
| 17 | } |
| 18 | |
| 19 | fn test_rect_empty_screen_bounds_apply_scale_before_the_pixel_offsets() { |
| 20 | tleft_x, tleft_y, bright_x, bright_y := rect_empty_screen_bounds(2.0, 3, 4, 5, 6) |
| 21 | assert rect_empty_bounds_match(tleft_x, 6.1) |
| 22 | assert rect_empty_bounds_match(tleft_y, 8.1) |
| 23 | assert rect_empty_bounds_match(bright_x, 15.9) |
| 24 | assert rect_empty_bounds_match(bright_y, 19.9) |
| 25 | } |
| 26 | |