package widgets

import (
	"image"
	"image/color"

	"gioui.org/f32"
	"gioui.org/op"
	"gioui.org/op/clip"
	"gioui.org/op/paint"
)

// DrawLine draws a line between two points.
func DrawLine(ops *op.Ops, start image.Point, end image.Point, width int, color color.NRGBA) {
	var path clip.Path
	min := f32.Pt(float32(start.X), float32(start.Y))
	max := f32.Pt(float32(end.X), float32(end.Y))
	path.Begin(ops)
	path.Move(min)
	path.Line(max)
	paint.FillShape(ops, color, clip.Stroke{
		Path:  path.End(),
		Width: float32(width),
	}.Op())
}
