diff --git a/allg5ui/renderer.go b/allg5ui/renderer.go index 8f035a2..6789b11 100644 --- a/allg5ui/renderer.go +++ b/allg5ui/renderer.go @@ -279,6 +279,10 @@ func (r *Renderer) FillRectangle(rect geom.RectangleF32, c color.Color) { allg5.DrawFilledRectangle(rect.Min.X, rect.Min.Y, rect.Max.X, rect.Max.Y, newColor(c)) } +func (r *Renderer) Line(p, q geom.PointF32, color color.Color, thickness float32) { + allg5.DrawLine(p.X, p.Y, q.X, q.Y, newColor(color), thickness) +} + func (r *Renderer) mustGetBitmap(t ui.Texture) *allg5.Bitmap { texture, ok := t.(*texture) if !ok { diff --git a/sdlui/renderer.go b/sdlui/renderer.go index 181c5e7..ab20896 100644 --- a/sdlui/renderer.go +++ b/sdlui/renderer.go @@ -361,6 +361,11 @@ func (r *Renderer) FillRectangle(rect geom.RectangleF32, c color.Color) { r.renderer.FillRect(SDLRectanglePtr(rect)) } +func (r *Renderer) Line(p, q geom.PointF32, color color.Color, thickness float32) { + r.SetDrawColorGo(color) + r.renderer.DrawLineF(p.X, p.Y, p.X, p.Y) +} + func (r *Renderer) Rectangle(rect geom.RectangleF32, c color.Color, thickness float32) { r.SetDrawColorGo(c) if rect.Dx() == 0 { // SDL doesn't draw a 1 px wide line when Dx() == 0 && thickness == 1 diff --git a/ui/renderer.go b/ui/renderer.go index 0c2c5ff..bc51bdf 100644 --- a/ui/renderer.go +++ b/ui/renderer.go @@ -29,6 +29,7 @@ type Renderer interface { DrawTexturePoint(t Texture, p geom.PointF32) DrawTexturePointOptions(t Texture, p geom.PointF32, opts DrawOptions) FillRectangle(r geom.RectangleF32, c color.Color) + Line(p, q geom.PointF32, color color.Color, thickness float32) Rectangle(r geom.RectangleF32, c color.Color, thickness float32) RenderTo(Texture) RenderToDisplay()