@@ -425,6 +425,13 @@ public void DrawRectangle(Color color, int x, int y, int width, int height)
425
425
var right = x + width - 1 ;
426
426
var bottom = y + height - 1 ;
427
427
428
+ if ( width == 1 || height == 1 )
429
+ {
430
+ // width or height of 1 is just a single line
431
+ DrawLine ( color , x , y , right , bottom ) ;
432
+ return ;
433
+ }
434
+
428
435
// top left to top right
429
436
DrawLine ( color , x , y , right , y ) ;
430
437
// top right (and 1 pixel down) to bottom right
@@ -517,29 +524,33 @@ public void DrawLine(Color color, int x1, int y1, int x2, int y2)
517
524
var p1 = new Vector2 ( x1 , y1 ) ;
518
525
var p2 = new Vector2 ( x2 , y2 ) ;
519
526
527
+ // imgui seems to have behavior which necessitate the rightmost and bottommost ends be extended to correctly draw the line (some subpixel jitter?)
528
+
520
529
if ( p1 . X > p2 . X )
521
530
{
522
- p1 . X += 0.5f ;
531
+ // right to left drawing, extend the beginning by 1 pixel rightwards
532
+ p1 . X ++ ;
523
533
}
524
534
else
525
535
{
526
- p2 . X += 0.5f ;
536
+ // left to right drawing, extend the end by 1 pixel rightwards
537
+ p2 . X ++ ;
527
538
}
528
539
529
540
if ( p1 . Y > p2 . Y )
530
541
{
531
- p1 . Y += 0.5f ;
542
+ // down to up drawing, extend the beginning by 1 pixel downwards
543
+ p1 . Y ++ ;
532
544
}
533
545
else
534
546
{
535
- p2 . Y += 0.5f ;
547
+ // up to down drawing, extend the end by 1 pixel downwards
548
+ p2 . Y ++ ;
536
549
}
537
550
538
- _imGuiDrawList . AddLine (
539
- p1 : p1 ,
540
- p2 : p2 ,
541
- col : ( uint ) color . ToArgb ( ) ,
542
- thickness : RenderThickness ) ;
551
+ _imGuiDrawList . PathLineTo ( p1 ) ;
552
+ _imGuiDrawList . PathLineTo ( p2 ) ;
553
+ _imGuiDrawList . PathStroke ( ( uint ) color . ToArgb ( ) , 0 , RenderThickness ) ;
543
554
}
544
555
545
556
public void DrawPie ( Color color , int x , int y , int width , int height , int startAngle , int sweepAngle )
0 commit comments