Line no longer segfaults
This commit is contained in:
parent
e740f5385c
commit
4d609f6fa1
@ -52,6 +52,7 @@ func lineLow (
|
|||||||
width, height int,
|
width, height int,
|
||||||
) {
|
) {
|
||||||
data, stride := destination.Buffer()
|
data, stride := destination.Buffer()
|
||||||
|
bounds := destination.Bounds()
|
||||||
|
|
||||||
deltaX := max.X - min.X
|
deltaX := max.X - min.X
|
||||||
deltaY := max.Y - min.Y
|
deltaY := max.Y - min.Y
|
||||||
@ -66,6 +67,7 @@ func lineLow (
|
|||||||
y := min.Y
|
y := min.Y
|
||||||
|
|
||||||
for x := min.X; x < max.X; x ++ {
|
for x := min.X; x < max.X; x ++ {
|
||||||
|
if !(image.Point { x, y }).In(bounds) { break }
|
||||||
data[x + y * stride] = source.AtWhen(x, y, width, height)
|
data[x + y * stride] = source.AtWhen(x, y, width, height)
|
||||||
if D > 0 {
|
if D > 0 {
|
||||||
y += yi
|
y += yi
|
||||||
@ -85,6 +87,7 @@ func lineHigh (
|
|||||||
width, height int,
|
width, height int,
|
||||||
) {
|
) {
|
||||||
data, stride := destination.Buffer()
|
data, stride := destination.Buffer()
|
||||||
|
bounds := destination.Bounds()
|
||||||
|
|
||||||
deltaX := max.X - min.X
|
deltaX := max.X - min.X
|
||||||
deltaY := max.Y - min.Y
|
deltaY := max.Y - min.Y
|
||||||
@ -99,6 +102,7 @@ func lineHigh (
|
|||||||
x := min.X
|
x := min.X
|
||||||
|
|
||||||
for y := min.Y; y < max.Y; y ++ {
|
for y := min.Y; y < max.Y; y ++ {
|
||||||
|
if !(image.Point { x, y }).In(bounds) { break }
|
||||||
data[x + y * stride] = source.AtWhen(x, y, width, height)
|
data[x + y * stride] = source.AtWhen(x, y, width, height)
|
||||||
if D > 0 {
|
if D > 0 {
|
||||||
x += xi
|
x += xi
|
||||||
|
Reference in New Issue
Block a user