Dynamically determine minimum length of longest side

This commit is contained in:
2026-08-07 18:52:10 -04:00
parent 685f2b5aaf
commit 815018427f
+3 -4
View File
@@ -80,10 +80,9 @@ TriangleLayer *triangle_layer_create(GRect frame, GColor color) {
max_sin = sin_C;
// longest side randomly chosen
#define MIN_SIDE 40
uint16_t max_side = (frame.size.w < frame.size.h) ? frame.size.w : frame.size.h;
max_side = max_side - 12; // basic margin
uint16_t largest_side = MIN_SIDE + (rand() % (max_side - MIN_SIDE + 1));
uint16_t min_length_of_longest_side = (frame.size.w < frame.size.h) ? frame.size.w / 2 : frame.size.h / 2;
uint16_t max_length_of_longest_side = (frame.size.w < frame.size.h) ? frame.size.w : frame.size.h;
uint16_t largest_side = min_length_of_longest_side + (rand() % (max_length_of_longest_side - min_length_of_longest_side + 1));
tri->side_a = (uint16_t)(((uint32_t)sin_A * largest_side) / (uint32_t)max_sin);
tri->side_b = (uint16_t)(((uint32_t)sin_B * largest_side) / (uint32_t)max_sin);