Dynamically determine minimum length of longest side

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