File: sdl2ext_algorithms.rst

package info (click to toggle)
pysdl2 0.9.7%2Bdfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 2,824 kB
  • sloc: python: 17,244; makefile: 195; sh: 32
file content (42 lines) | stat: -rw-r--r-- 1,671 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
.. currentmodule:: sdl2.ext

Common algorithms
=================

.. function:: 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)``.

.. function:: 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)``.

.. function:: 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.

.. function:: point_on_line(p1 : iterable, p2 : iterable, point : iterable) -> bool

   Checks, if *point*, a two-value tuple, is on the line segment defined by *p1*
   and *p2*.