Fix stretched shapes
This commit is contained in:
parent
70a8567646
commit
85b71a91a3
2
plot.go
2
plot.go
@ -23,7 +23,7 @@ func (context plottingContext[T]) plot (center image.Point) {
|
||||
square := context.square(center)
|
||||
for y := square.Min.Y; y < square.Max.Y; y ++ {
|
||||
for x := square.Min.X; x < square.Max.X; x ++ {
|
||||
index := (y * context.stride + x) * context.width + context.offset
|
||||
index := y * context.stride + x * context.width + context.offset
|
||||
context.data[index] = context.color
|
||||
}}
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ func (this Image[T]) FillPolygon (fill []T, points ...image.Point) {
|
||||
for offset, part := range fill {
|
||||
for x := left; x < right; x ++ {
|
||||
index :=
|
||||
(y * this.Stride + x) *
|
||||
y * this.Stride + x *
|
||||
this.Width + offset
|
||||
this.Pix[index] = part
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ func (this Image[T]) FillRectangle (fill []T, rectangle image.Rectangle) {
|
||||
for pos.Y = rectangle.Min.Y; pos.Y < rectangle.Max.Y; pos.Y ++ {
|
||||
for offset, part := range fill {
|
||||
for pos.X = rectangle.Min.X; pos.X < rectangle.Max.X; pos.X ++ {
|
||||
index := (pos.Y * this.Stride + pos.X) * this.Width + offset
|
||||
index := pos.Y * this.Stride + pos.X * this.Width + offset
|
||||
this.Pix[index] = part
|
||||
}}}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user