@@ -99,6 +99,7 @@ struct vector_display {
9999
100100 double initial_decay ;
101101 double thickness ;
102+ int custom_thickness ;
102103
103104 double offset_x , offset_y ;
104105 double scale ;
@@ -108,6 +109,15 @@ struct vector_display {
108109#define VERTEX_COLOR_INDEX (1)
109110#define VERTEX_TEXCOORD_INDEX (2)
110111
112+ static double effective_thickness (vector_display_t * self ) {
113+ if (self -> custom_thickness ) {
114+ return self -> thickness * self -> scale / 2 ;
115+ } else {
116+ // this makes thickness=16 at 2048x1536
117+ return (0.01 * (self -> width + self -> height ) / 2.0 ) * self -> scale / 2 ;
118+ }
119+ }
120+
111121static int vector_display_init (vector_display_t * self , double width , double height ) {
112122 self -> steps = VECTOR_DISPLAY_DEFAULT_DECAY_STEPS ;
113123 self -> buffers = (GLuint * )calloc (sizeof (GLuint ), self -> steps );
@@ -126,7 +136,6 @@ static int vector_display_init(vector_display_t *self, double width, double heig
126136 self -> glow_width = width / 3.0 ;
127137 self -> glow_height = height / 3.0 ;
128138 self -> initial_decay = VECTOR_DISPLAY_DEFAULT_INITIAL_DECAY ;
129- self -> thickness = VECTOR_DISPLAY_DEFAULT_THICKNESS ;
130139
131140 self -> offset_x = VECTOR_DISPLAY_DEFAULT_OFFSET_X ;
132141 self -> offset_y = VECTOR_DISPLAY_DEFAULT_OFFSET_Y ;
@@ -302,10 +311,16 @@ int vector_display_set_initial_decay(vector_display_t *self, double initial_deca
302311
303312int vector_display_set_thickness (vector_display_t * self , double thickness ) {
304313 if (thickness <= 0 ) return -1 ;
314+ self -> custom_thickness = 1 ;
305315 self -> thickness = thickness ;
306316 return 0 ;
307317}
308318
319+ int vector_display_set_default_thickness (vector_display_t * self ) {
320+ self -> custom_thickness = 0 ;
321+ return 0 ;
322+ }
323+
309324int vector_display_clear (vector_display_t * self ) {
310325 self -> npoints = 0 ;
311326 return 0 ;
@@ -448,7 +463,7 @@ void draw_fan(vector_display_t *self, float cx, float cy, float pa, float a, flo
448463
449464static void draw_lines (vector_display_t * self , line_t * lines , int nlines ) {
450465 int i ;
451- float t = self -> thickness * self -> scale / 2 ;
466+ float t = effective_thickness ( self ) ;
452467
453468 for (i = 0 ; i < nlines ; i ++ ) {
454469 line_t * line = & lines [i ], * pline = & lines [(nlines + i - 1 )%nlines ];
@@ -516,7 +531,7 @@ int vector_display_end_draw(vector_display_t *self) {
516531 return 0 ;
517532 }
518533
519- float t = self -> thickness * self -> scale / 2 ;
534+ float t = effective_thickness ( self ) ;
520535 int i ;
521536 int first_last_same = abs (self -> pending_points [0 ].x - self -> pending_points [self -> pending_npoints - 1 ].x ) < 0.1 &&
522537 abs (self -> pending_points [0 ].y - self -> pending_points [self -> pending_npoints - 1 ].y ) < 0.1 ;
0 commit comments