Dynamically determine minimum length of longest side
This commit is contained in:
+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