Ellipses now draw properly
This commit is contained in:
parent
39ce5f9ee2
commit
a273178a8e
@ -23,8 +23,8 @@ func FillEllipse (
|
|||||||
width, height := bounds.Dx(), bounds.Dy()
|
width, height := bounds.Dx(), bounds.Dy()
|
||||||
for y := 0; y < height; y ++ {
|
for y := 0; y < height; y ++ {
|
||||||
for x := 0; x < width; x ++ {
|
for x := 0; x < width; x ++ {
|
||||||
xf := float64(x) / float64(realWidth) - 0.5
|
xf := (float64(x) + 0.5) / float64(realWidth) - 0.5
|
||||||
yf := float64(y) / float64(realHeight) - 0.5
|
yf := (float64(y) + 0.5) / float64(realHeight) - 0.5
|
||||||
if math.Sqrt(xf * xf + yf * yf) <= 0.5 {
|
if math.Sqrt(xf * xf + yf * yf) <= 0.5 {
|
||||||
data[x + bounds.Min.X + (y + bounds.Min.Y) * stride] =
|
data[x + bounds.Min.X + (y + bounds.Min.Y) * stride] =
|
||||||
source.AtWhen(x, y, realWidth, realHeight)
|
source.AtWhen(x, y, realWidth, realHeight)
|
||||||
@ -44,11 +44,7 @@ func StrokeEllipse (
|
|||||||
if weight < 1 { return }
|
if weight < 1 { return }
|
||||||
|
|
||||||
data, stride := destination.Buffer()
|
data, stride := destination.Buffer()
|
||||||
bounds = bounds.Canon().Inset(weight)
|
bounds = bounds.Canon().Inset(weight - 1)
|
||||||
radii := image.Pt (
|
|
||||||
bounds.Dx() / 2,
|
|
||||||
bounds.Dy() / 2)
|
|
||||||
center := bounds.Min.Add(radii)
|
|
||||||
width, height := bounds.Dx(), bounds.Dy()
|
width, height := bounds.Dx(), bounds.Dy()
|
||||||
|
|
||||||
context := ellipsePlottingContext {
|
context := ellipsePlottingContext {
|
||||||
@ -60,6 +56,14 @@ func StrokeEllipse (
|
|||||||
weight: weight,
|
weight: weight,
|
||||||
bounds: bounds,
|
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)
|
x := float64(0)
|
||||||
y := float64(radii.Y)
|
y := float64(radii.Y)
|
||||||
|
@ -87,10 +87,16 @@ func (element *Artist) Resize (width, height int) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 0, 3
|
// 0, 3
|
||||||
|
artist.StrokeRectangle (
|
||||||
|
element,uhex(0x888888FF), 1,
|
||||||
|
element.cellAt(0, 3))
|
||||||
artist.FillEllipse(element, uhex(0x00FF00FF), 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 ++ {
|
for x := 1; x < 4; x ++ {
|
||||||
|
artist.StrokeRectangle (
|
||||||
|
element,uhex(0x888888FF), 1,
|
||||||
|
element.cellAt(x, 3))
|
||||||
artist.StrokeEllipse (
|
artist.StrokeEllipse (
|
||||||
element,
|
element,
|
||||||
[]artist.Pattern {
|
[]artist.Pattern {
|
||||||
|
Reference in New Issue
Block a user