// jumpPath adds to the path the points from p (included) to q (excluded)
// corresponding to a jump (possibly diagonal+straight) from q to p.
jumpPath adds to the path the points from p (included) to q (excluded)
corresponding to a jump (possibly diagonal+straight) from q to p.
// jumpPath adds to the path the points from p ( included ) to q ( excluded ) // corresponding to a jump ( possibly diagonal + straight ) from q to p .
func (pr *PathRange) jumpPath(path []gruid.Point, p, q gruid.Point) []gruid.Point {
	dir := q.Sub(p)
	dx := abs(dir.X)
	dy := abs(dir.Y)
	dir = gruid.Point{sign(dir.X), sign(dir.Y)}
	switch {
	case dx > dy:
		for i := 0; i < dx-dy; i++ {
			path = append(path, p)
			p = p.Add(gruid.Point{dir.X, 0})
		}
	case dx < dy:
		for i := 0; i < dy-dx; i++ {
			path = append(path, p)
			p = p.Add(gruid.Point{0, dir.Y})
		}
	}
	for ; p != q; p = p.Add(dir) {
		path = append(path, p)
		if !pr.diags {
			if dir.X != 0 && dir.Y != 0 {
				if px := p.Add(gruid.Point{dir.X, 0}); pr.pass(px) {
					path = append(path, px)
				} else if py := p.Add(gruid.Point{0, dir.Y}); pr.pass(py) {
					path = append(path, py)
				}
			}
		}
	}
	return path
}
func ( pr * PathRange ) jumpPath ( path [ ] gruid . Point , p , q gruid . Point ) [ ] gruid . Point { dir := q . Sub ( p ) dx := abs ( dir . X ) dy := abs ( dir . Y ) dir = gruid . Point { sign ( dir . X ) , sign ( dir . Y ) } switch { case dx > dy : for i := 0 ; i < dx - dy ; i ++ { path = append ( path , p ) p = p . Add ( gruid . Point { dir . X , 0 } ) } case dx < dy : for i := 0 ; i < dy - dx ; i ++ { path = append ( path , p ) p = p . Add ( gruid . Point { 0 , dir . Y } ) } } for ; p != q ; p = p . Add ( dir ) { path = append ( path , p ) if ! pr . diags { if dir . X != 0 && dir . Y != 0 { if px := p . Add ( gruid . Point { dir . X , 0 } ) ; pr . pass ( px ) { path = append ( path , px ) } else if py := p . Add ( gruid . Point { 0 , dir . Y } ) ; pr . pass ( py ) { path = append ( path , py ) } } } } return path }
jumpPath adds to the path the points from p (included) to q (excluded)
corresponding to a jump (possibly diagonal+straight) from q to p.
jumpPath adds to the path the points from p ( included ) to q ( excluded ) corresponding to a jump ( possibly diagonal + straight ) from q to p .