@@ -249,7 +249,7 @@ extern bool bar_reversed;
249
249
250
250
// Polygon indicator
251
251
extern int polygon_sides ;
252
- extern double polygon_offset ;
252
+ extern double polygon_rotation ;
253
253
extern int polygon_highlight ;
254
254
255
255
static cairo_font_face_t * font_faces [6 ] = {
@@ -523,11 +523,21 @@ static void draw_bar(cairo_t *ctx, double bar_x, double bar_y, double bar_width,
523
523
cairo_restore (ctx );
524
524
}
525
525
526
- void draw_polygon (cairo_t * ctx , double center_x , double center_y , double radius , int points , int start , int end , double offset ) {
526
+ /* Draw some number of edges of a polygon
527
+ * center_x/center_y: The center of the polygon
528
+ * radius: The distance from the center to the vertices
529
+ * points: The number of verticies
530
+ * start/end: The index of the edges to draw. Settings start to 0 and end to
531
+ * points will draw the entire polygon. Edges are indexed counter
532
+ * clockwise around the polygon.
533
+ * angle_offset: How far offset clockwise the first vertex is from the positive
534
+ * x axis (radians).
535
+ */
536
+ void draw_polygon (cairo_t * ctx , double center_x , double center_y , double radius , int points , int start , int end , double angle_offset ) {
527
537
int count = end - start ;
528
538
529
539
for (int v = 0 ; v < count + 1 ; v ++ ) {
530
- double theta = (start + v ) * ((M_PI * 2 ) / points ) + offset ;
540
+ double theta = (start + v ) * ((M_PI * 2 ) / points ) + angle_offset ;
531
541
532
542
int x = radius * cos (theta );
533
543
int y = radius * sin (theta );
@@ -545,7 +555,7 @@ static void draw_indic(cairo_t *ctx, double ind_x, double ind_y) {
545
555
/* Draw a (centered) circle with transparent background. */
546
556
cairo_set_line_width (ctx , RING_WIDTH );
547
557
if (polygon_sides > 0 )
548
- draw_polygon (ctx , ind_x , ind_y , BUTTON_RADIUS , polygon_sides , 0 , polygon_sides , polygon_offset );
558
+ draw_polygon (ctx , ind_x , ind_y , BUTTON_RADIUS , polygon_sides , 0 , polygon_sides , polygon_rotation );
549
559
else
550
560
cairo_arc (ctx , ind_x , ind_y , BUTTON_RADIUS , 0 , 2 * M_PI );
551
561
@@ -618,7 +628,7 @@ static void draw_indic(cairo_t *ctx, double ind_x, double ind_y) {
618
628
cairo_set_source_rgba (ctx , line16 .red , line16 .green , line16 .blue , line16 .alpha );
619
629
cairo_set_line_width (ctx , 2.0 );
620
630
if (polygon_sides > 0 )
621
- draw_polygon (ctx , ind_x , ind_y , BUTTON_RADIUS - 5 , polygon_sides , 0 , polygon_sides , polygon_offset );
631
+ draw_polygon (ctx , ind_x , ind_y , BUTTON_RADIUS - 5 , polygon_sides , 0 , polygon_sides , polygon_rotation );
622
632
else
623
633
cairo_arc (ctx , ind_x , ind_y , BUTTON_RADIUS - 5 , 0 , 2 * M_PI );
624
634
cairo_stroke (ctx );
@@ -643,7 +653,7 @@ static void draw_indic(cairo_t *ctx, double ind_x, double ind_y) {
643
653
highlight_start = input_position % polygon_sides ;
644
654
else if (polygon_highlight == 2 )
645
655
highlight_start = - input_position % polygon_sides ;
646
- draw_polygon (ctx , ind_x , ind_y , BUTTON_RADIUS , polygon_sides , highlight_start , highlight_start + 1 , polygon_offset );
656
+ draw_polygon (ctx , ind_x , ind_y , BUTTON_RADIUS , polygon_sides , highlight_start , highlight_start + 1 , polygon_rotation );
647
657
cairo_stroke (ctx );
648
658
return ;
649
659
}
0 commit comments