Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent panic if BHEIGHT <= 0 #13

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,16 @@ func main() {
for y := 0; y < b.Max.Y; y++ {
for x := 0; x < b.Max.X; x++ {
// Every BHEIGHT lines in average a new distorted block begins
if seededRand.Intn(BHEIGHT*b.Max.X) == 0 {
if BHEIGHT <= 0 {
line_off = offset(BOFFSET)
stride = seededRand.NormFloat64() * STRIDE_MAG
yset = y
} else if seededRand.Intn(BHEIGHT*b.Max.X) == 0 {
line_off = offset(BOFFSET)
stride = seededRand.NormFloat64() * STRIDE_MAG
yset = y
}

// at the line where the block has begun, we don't want to offset the image
// so stride_off is 0 on the block's line
stride_off := int(stride * float64(y-yset))
Expand Down