### Navigation

- index
- modules |
- next |
- previous |
- PySDL2 0.9.0 documentation »
- API reference »
- sdl2.ext - Python extensions for SDL2 »

# Common algorithms

`sdl2.ext.``cohensutherland`(left : int, top : int, right : int, bottom : int, x1 : int, y1 : int, x2 : int, y2 : int) → int, int, int, int

  This implements the Cohen-Sutherland line clipping algorithm. left, top, right and bottom denote the clipping area, into which the line defined by x1, y1 (start point) and x2, y2 (end point) will be clipped.

  If the line does not intersect with the rectangular clipping area, four `None` values will be returned as tuple. Otherwise a tuple of the clipped line points will be returned in the form `(cx1, cy1, cx2, cy2)`.

`sdl2.ext.``liangbarsky`(left : int, top : int, right : int, bottom : int, x1 : int, y1 : int, x2 : int, y2 : int) → int, int, int, int

  This implements the Liang-Barsky line clipping algorithm. left, top, right and bottom denote the clipping area, into which the line defined by x1, y1 (start point) and x2, y2 (end point) will be clipped.

  If the line does not intersect with the rectangular clipping area, four `None` values will be returned as tuple. Otherwise a tuple of the clipped line points will be returned in the form `(cx1, cy1, cx2, cy2)`.

`sdl2.ext.``clipline`(left : int, top : int, right : int, bottom : int, x1 : int, y1 : int, x2 : int, y2 : int[, method=liangbarsky]) → int, int, int, int

  Clips a line to a rectangular area.

### Navigation

- index
- modules |
- next |
- previous |
- PySDL2 0.9.0 documentation »
- API reference »
- sdl2.ext - Python extensions for SDL2 »