Browse Source

Improved perfomance of price extrapolator

master
Patrick Gaskin 2 years ago
parent
commit
6d0a7756c1
Signed by: geek1011 GPG Key ID: A2FD79F68A2AB707
  1. 9
      graph/graph.go

9
graph/graph.go

@ -154,10 +154,15 @@ func getPriceExtrapolator(img image.Image, graphBounds image.Rectangle, maxPrice
// dashed line, so threshold is 0.4; the line is on bottom of plotted line, so subtract 1.
var maxY, minY int
for y := graphBounds.Min.Y; y < graphBounds.Max.Y; y++ {
if maxY == 0 && pctColor(img, maxColor, y, false) > 0.4 {
if pctColor(img, maxColor, y, false) > 0.4 {
maxY = y - 1
} else if minY == 0 && pctColor(img, minColor, y, false) > 0.4 {
break
}
}
for y := graphBounds.Max.Y; y > 0; y-- {
if pctColor(img, minColor, y, false) > 0.4 {
minY = y - 1
break
}
}
if minY < maxY {