From 1f91ae62d2199515382fac549d79d452d692f3a7 Mon Sep 17 00:00:00 2001 From: faiface <faiface@ksp.sk> Date: Tue, 28 Feb 2017 18:34:02 +0100 Subject: [PATCH] fix bug in PictureDataFromPicture --- data.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/data.go b/data.go index 105af4c..9ce26df 100644 --- a/data.go +++ b/data.go @@ -200,9 +200,12 @@ func PictureDataFromPicture(pic Picture) PictureData { pd := MakePictureData(bounds) if pic, ok := pic.(PictureColor); ok { - for y := bounds.Pos.Y(); y < bounds.Pos.Y()+bounds.Size.Y(); y++ { - for x := bounds.Pos.X(); x < bounds.Pos.X()+bounds.Size.X(); x++ { - at := V(x, y) + for y := math.Floor(bounds.Pos.Y()); y < bounds.Pos.Y()+bounds.Size.Y(); y++ { + for x := math.Floor(bounds.Pos.X()); x < bounds.Pos.X()+bounds.Size.X(); x++ { + at := V( + math.Max(x, bounds.Pos.X()), + math.Max(y, bounds.Pos.Y()), + ) pd.SetColor(at, pic.Color(at)) } } -- GitLab