Implemented StrokeRectangle
This commit is contained in:
parent
ec24eb7b4f
commit
b52696025a
@ -3,6 +3,8 @@ package artist
|
||||
import "image"
|
||||
import "git.tebibyte.media/sashakoshka/tomo"
|
||||
|
||||
// Line draws a line from one point to another with the specified weight and
|
||||
// pattern.
|
||||
func Line (
|
||||
destination tomo.Canvas,
|
||||
source Pattern,
|
||||
|
@ -50,3 +50,44 @@ func FillRectangle (
|
||||
}}
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
// StrokeRectangle draws the outline of a rectangle with the specified line
|
||||
// weight and pattern.
|
||||
func StrokeRectangle (
|
||||
destination tomo.Canvas,
|
||||
source Pattern,
|
||||
weight int,
|
||||
bounds image.Rectangle,
|
||||
) {
|
||||
bounds = bounds.Canon()
|
||||
insetBounds := bounds.Inset(weight)
|
||||
if insetBounds.Empty() {
|
||||
FillRectangle(destination, source, bounds)
|
||||
return
|
||||
}
|
||||
|
||||
// top
|
||||
FillRectangle (destination, source, image.Rect (
|
||||
bounds.Min.X, bounds.Min.Y,
|
||||
insetBounds.Max.X, insetBounds.Min.Y))
|
||||
|
||||
// bottom
|
||||
FillRectangle (destination, source, image.Rect (
|
||||
bounds.Min.X, insetBounds.Max.Y,
|
||||
insetBounds.Max.X, bounds.Max.Y))
|
||||
|
||||
// left
|
||||
FillRectangle (destination, source, image.Rect (
|
||||
bounds.Min.X, insetBounds.Min.Y,
|
||||
insetBounds.Min.X, insetBounds.Max.Y))
|
||||
|
||||
// right
|
||||
FillRectangle (destination, source, image.Rect (
|
||||
insetBounds.Max.X, insetBounds.Min.Y,
|
||||
bounds.Max.X, insetBounds.Max.Y))
|
||||
}
|
||||
|
||||
// TODO: FillEllipse
|
||||
|
||||
// TODO: StrokeEllipse
|
||||
|
@ -107,7 +107,8 @@ func (drawer *TextDrawer) Draw (
|
||||
}
|
||||
|
||||
if !drawer.layoutClean { drawer.recalculate() }
|
||||
// TODO: reimplement a version of draw mask that takes in a pattern
|
||||
// TODO: reimplement a version of draw mask that takes in a pattern and
|
||||
// only draws to a tomo.Canvas.
|
||||
for _, word := range drawer.layout {
|
||||
for _, character := range word.text {
|
||||
destinationRectangle,
|
||||
|
Reference in New Issue
Block a user