added rect function

This commit is contained in:
Thomas Friedel 2018-04-04 16:01:26 +02:00
parent 7be3a4383c
commit d08eb63181

View file

@ -527,3 +527,12 @@ func (cv *Canvas) clip(path []pathPoint) {
cv.state.clip = make([]pathPoint, len(cv.polyPath)) cv.state.clip = make([]pathPoint, len(cv.polyPath))
copy(cv.state.clip, cv.polyPath) copy(cv.state.clip, cv.polyPath)
} }
// Rect creates a closed rectangle path for stroking or filling
func (cv *Canvas) Rect(x, y, w, h float64) {
cv.MoveTo(x, y)
cv.LineTo(x+w, y)
cv.LineTo(x+w, y+h)
cv.LineTo(x, y+h)
cv.ClosePath()
}