diff --git a/artist/ellipse.go b/artist/ellipse.go index 069dc2c..837bd30 100644 --- a/artist/ellipse.go +++ b/artist/ellipse.go @@ -23,8 +23,8 @@ func FillEllipse ( width, height := bounds.Dx(), bounds.Dy() for y := 0; y < height; y ++ { for x := 0; x < width; x ++ { - xf := float64(x) / float64(realWidth) - 0.5 - yf := float64(y) / float64(realHeight) - 0.5 + xf := (float64(x) + 0.5) / float64(realWidth) - 0.5 + yf := (float64(y) + 0.5) / float64(realHeight) - 0.5 if math.Sqrt(xf * xf + yf * yf) <= 0.5 { data[x + bounds.Min.X + (y + bounds.Min.Y) * stride] = source.AtWhen(x, y, realWidth, realHeight) @@ -44,11 +44,7 @@ func StrokeEllipse ( if weight < 1 { return } data, stride := destination.Buffer() - bounds = bounds.Canon().Inset(weight) - radii := image.Pt ( - bounds.Dx() / 2, - bounds.Dy() / 2) - center := bounds.Min.Add(radii) + bounds = bounds.Canon().Inset(weight - 1) width, height := bounds.Dx(), bounds.Dy() context := ellipsePlottingContext { @@ -60,6 +56,14 @@ func StrokeEllipse ( weight: weight, bounds: bounds, } + + bounds.Max.X -= 1 + bounds.Max.Y -= 1 + + radii := image.Pt ( + bounds.Dx() / 2, + bounds.Dy() / 2) + center := bounds.Min.Add(radii) x := float64(0) y := float64(radii.Y) diff --git a/elements/testing/artist.go b/elements/testing/artist.go index 4c47c50..e948efc 100644 --- a/elements/testing/artist.go +++ b/elements/testing/artist.go @@ -87,10 +87,16 @@ func (element *Artist) Resize (width, height int) { } // 0, 3 + artist.StrokeRectangle ( + element,uhex(0x888888FF), 1, + element.cellAt(0, 3)) artist.FillEllipse(element, uhex(0x00FF00FF), element.cellAt(0, 3)) - // 1, 3 + // 1, 3 - 3, 3 for x := 1; x < 4; x ++ { + artist.StrokeRectangle ( + element,uhex(0x888888FF), 1, + element.cellAt(x, 3)) artist.StrokeEllipse ( element, []artist.Pattern {