mirror of
https://git.wetfence.xyz/RandyTheSilly/Trigalarm.git
synced 2026-10-27 03:09:58 -04:00
Dynamically determine minimum length of longest side
This commit is contained in:
1 parent
685f2b5aaf
commit
815018427f
1 file changed
+4
-5
+4
-5
@@ -79,11 +79,10 @@ TriangleLayer *triangle_layer_create(GRect frame, GColor color) {
|
||||
if (sin_C > max_sin)
|
||||
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));
|
||||
// longest side randomly chosen
|
||||
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);
|
||||
|
||||
Reference in new issue
Block a user