Skip to content

Commit

Permalink
Fix plot fill for one-sided plots (#361)
Browse files Browse the repository at this point in the history
If all plot points are far negative, the plot widget draws its surface up to invThreshold even if that value is outside of the plot bounds. The problem started to become apparent with the change to the shared drawing context.
  • Loading branch information
FD- authored Aug 29, 2022
1 parent 06d47df commit d202cf4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions render/plot.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,13 +224,13 @@ func (p Plot) Paint(dc *gg.Context, bounds image.Rectangle, frameIdx int) {
}
if y > p.invThreshold {
dc.SetColor(fillColInv)
for ; y != p.invThreshold; y-- {
for ; y != p.invThreshold && y >= 0; y-- {
tx, ty := dc.TransformPoint(float64(x), float64(y))
dc.SetPixel(int(tx), int(ty))
}
} else {
dc.SetColor(fillCol)
for ; y <= p.invThreshold; y++ {
for ; y <= p.invThreshold && y <= p.Height; y++ {
tx, ty := dc.TransformPoint(float64(x), float64(y))
dc.SetPixel(int(tx), int(ty))
}
Expand Down

0 comments on commit d202cf4

Please sign in to comment.