Added Line to Renderer.

This commit is contained in:
Sander Schobers 2021-03-23 12:31:31 +01:00
parent 7aa88e2dc6
commit 72138bb8e3
3 changed files with 10 additions and 0 deletions

View File

@ -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 {

View File

@ -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

View File

@ -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()