159 lines
8.5 KiB
HTML
159 lines
8.5 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
|
|
|
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
|
|
<title>Common algorithms — PySDL2 0.9.5 documentation</title>
|
|
|
|
<link rel="stylesheet" href="../_static/classic.css" type="text/css" />
|
|
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
|
|
|
|
<script type="text/javascript">
|
|
var DOCUMENTATION_OPTIONS = {
|
|
URL_ROOT: '../',
|
|
VERSION: '0.9.5',
|
|
COLLAPSE_INDEX: false,
|
|
FILE_SUFFIX: '.html',
|
|
HAS_SOURCE: true
|
|
};
|
|
</script>
|
|
<script type="text/javascript" src="../_static/jquery.js"></script>
|
|
<script type="text/javascript" src="../_static/underscore.js"></script>
|
|
<script type="text/javascript" src="../_static/doctools.js"></script>
|
|
<link rel="top" title="PySDL2 0.9.5 documentation" href="../index.html" />
|
|
<link rel="up" title="sdl2.ext - Python extensions for SDL2" href="sdl2ext.html" />
|
|
<link rel="next" title="Converting sequences" href="sdl2ext_array.html" />
|
|
<link rel="prev" title="sdl2.ext - Python extensions for SDL2" href="sdl2ext.html" />
|
|
</head>
|
|
<body role="document">
|
|
<div class="related" role="navigation" aria-label="related navigation">
|
|
<h3>Navigation</h3>
|
|
<ul>
|
|
<li class="right" style="margin-right: 10px">
|
|
<a href="../genindex.html" title="General Index"
|
|
accesskey="I">index</a></li>
|
|
<li class="right" >
|
|
<a href="../py-modindex.html" title="Python Module Index"
|
|
>modules</a> |</li>
|
|
<li class="right" >
|
|
<a href="sdl2ext_array.html" title="Converting sequences"
|
|
accesskey="N">next</a> |</li>
|
|
<li class="right" >
|
|
<a href="sdl2ext.html" title="sdl2.ext - Python extensions for SDL2"
|
|
accesskey="P">previous</a> |</li>
|
|
<li class="nav-item nav-item-0"><a href="../index.html">PySDL2 0.9.5 documentation</a> »</li>
|
|
<li class="nav-item nav-item-1"><a href="index.html" >API reference</a> »</li>
|
|
<li class="nav-item nav-item-2"><a href="sdl2ext.html" accesskey="U">sdl2.ext - Python extensions for SDL2</a> »</li>
|
|
</ul>
|
|
</div>
|
|
|
|
<div class="document">
|
|
<div class="documentwrapper">
|
|
<div class="bodywrapper">
|
|
<div class="body" role="main">
|
|
|
|
<div class="section" id="common-algorithms">
|
|
<h1>Common algorithms<a class="headerlink" href="#common-algorithms" title="Permalink to this headline">¶</a></h1>
|
|
<dl class="function">
|
|
<dt id="sdl2.ext.cohensutherland">
|
|
<code class="descclassname">sdl2.ext.</code><code class="descname">cohensutherland</code><span class="sig-paren">(</span><em>left : int</em>, <em>top : int</em>, <em>right : int</em>, <em>bottom : int</em>, <em>x1 : int</em>, <em>y1 : int</em>, <em>x2 : int</em>, <em>y2 : int</em><span class="sig-paren">)</span> → int, int, int, int<a class="headerlink" href="#sdl2.ext.cohensutherland" title="Permalink to this definition">¶</a></dt>
|
|
<dd><p>This implements the Cohen-Sutherland line clipping
|
|
algorithm. <em>left</em>, <em>top</em>, <em>right</em> and <em>bottom</em> denote the
|
|
clipping area, into which the line defined by <em>x1</em>, <em>y1</em> (start
|
|
point) and <em>x2</em>, <em>y2</em> (end point) will be clipped.</p>
|
|
<p>If the line does not intersect with the rectangular clipping area,
|
|
four <code class="docutils literal"><span class="pre">None</span></code> values will be returned as tuple. Otherwise a tuple of
|
|
the clipped line points will be returned in the form <code class="docutils literal"><span class="pre">(cx1,</span> <span class="pre">cy1,</span>
|
|
<span class="pre">cx2,</span> <span class="pre">cy2)</span></code>.</p>
|
|
</dd></dl>
|
|
|
|
<dl class="function">
|
|
<dt id="sdl2.ext.liangbarsky">
|
|
<code class="descclassname">sdl2.ext.</code><code class="descname">liangbarsky</code><span class="sig-paren">(</span><em>left : int</em>, <em>top : int</em>, <em>right : int</em>, <em>bottom : int</em>, <em>x1 : int</em>, <em>y1 : int</em>, <em>x2 : int</em>, <em>y2 : int</em><span class="sig-paren">)</span> → int, int, int, int<a class="headerlink" href="#sdl2.ext.liangbarsky" title="Permalink to this definition">¶</a></dt>
|
|
<dd><p>This implements the Liang-Barsky line clipping algorithm. <em>left</em>,
|
|
<em>top</em>, <em>right</em> and <em>bottom</em> denote the clipping area, into
|
|
which the line defined by <em>x1</em>, <em>y1</em> (start point) and <em>x2</em>,
|
|
<em>y2</em> (end point) will be clipped.</p>
|
|
<p>If the line does not intersect with the rectangular clipping area,
|
|
four <code class="docutils literal"><span class="pre">None</span></code> values will be returned as tuple. Otherwise a tuple of
|
|
the clipped line points will be returned in the form <code class="docutils literal"><span class="pre">(cx1,</span> <span class="pre">cy1,</span>
|
|
<span class="pre">cx2,</span> <span class="pre">cy2)</span></code>.</p>
|
|
</dd></dl>
|
|
|
|
<dl class="function">
|
|
<dt id="sdl2.ext.clipline">
|
|
<code class="descclassname">sdl2.ext.</code><code class="descname">clipline</code><span class="sig-paren">(</span><em>left : int</em>, <em>top : int</em>, <em>right : int</em>, <em>bottom : int</em>, <em>x1 : int</em>, <em>y1 : int</em>, <em>x2 : int</em>, <em>y2 : int</em><span class="optional">[</span>, <em>method=liangbarsky</em><span class="optional">]</span><span class="sig-paren">)</span> → int, int, int, int<a class="headerlink" href="#sdl2.ext.clipline" title="Permalink to this definition">¶</a></dt>
|
|
<dd><p>Clips a line to a rectangular area.</p>
|
|
</dd></dl>
|
|
|
|
<dl class="function">
|
|
<dt id="sdl2.ext.point_on_line">
|
|
<code class="descclassname">sdl2.ext.</code><code class="descname">point_on_line</code><span class="sig-paren">(</span><em>p1 : iterable</em>, <em>p2 : iterable</em>, <em>point : iterable</em><span class="sig-paren">)</span> → bool<a class="headerlink" href="#sdl2.ext.point_on_line" title="Permalink to this definition">¶</a></dt>
|
|
<dd><p>Checks, if <em>point</em>, a two-value tuple, is on the line segment defined by <em>p1</em>
|
|
and <em>p2</em>.</p>
|
|
</dd></dl>
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
|
|
<div class="sphinxsidebarwrapper">
|
|
<h4>Previous topic</h4>
|
|
<p class="topless"><a href="sdl2ext.html"
|
|
title="previous chapter">sdl2.ext - Python extensions for SDL2</a></p>
|
|
<h4>Next topic</h4>
|
|
<p class="topless"><a href="sdl2ext_array.html"
|
|
title="next chapter">Converting sequences</a></p>
|
|
<div role="note" aria-label="source link">
|
|
<h3>This Page</h3>
|
|
<ul class="this-page-menu">
|
|
<li><a href="../_sources/modules/sdl2ext_algorithms.txt"
|
|
rel="nofollow">Show Source</a></li>
|
|
</ul>
|
|
</div>
|
|
<div id="searchbox" style="display: none" role="search">
|
|
<h3>Quick search</h3>
|
|
<form class="search" action="../search.html" method="get">
|
|
<div><input type="text" name="q" /></div>
|
|
<div><input type="submit" value="Go" /></div>
|
|
<input type="hidden" name="check_keywords" value="yes" />
|
|
<input type="hidden" name="area" value="default" />
|
|
</form>
|
|
</div>
|
|
<script type="text/javascript">$('#searchbox').show(0);</script>
|
|
</div>
|
|
</div>
|
|
<div class="clearer"></div>
|
|
</div>
|
|
<div class="related" role="navigation" aria-label="related navigation">
|
|
<h3>Navigation</h3>
|
|
<ul>
|
|
<li class="right" style="margin-right: 10px">
|
|
<a href="../genindex.html" title="General Index"
|
|
>index</a></li>
|
|
<li class="right" >
|
|
<a href="../py-modindex.html" title="Python Module Index"
|
|
>modules</a> |</li>
|
|
<li class="right" >
|
|
<a href="sdl2ext_array.html" title="Converting sequences"
|
|
>next</a> |</li>
|
|
<li class="right" >
|
|
<a href="sdl2ext.html" title="sdl2.ext - Python extensions for SDL2"
|
|
>previous</a> |</li>
|
|
<li class="nav-item nav-item-0"><a href="../index.html">PySDL2 0.9.5 documentation</a> »</li>
|
|
<li class="nav-item nav-item-1"><a href="index.html" >API reference</a> »</li>
|
|
<li class="nav-item nav-item-2"><a href="sdl2ext.html" >sdl2.ext - Python extensions for SDL2</a> »</li>
|
|
</ul>
|
|
</div>
|
|
<div class="footer" role="contentinfo">
|
|
© Copyright 2013-2016, Marcus von Appen.
|
|
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.4.6.
|
|
</div>
|
|
</body>
|
|
</html> |