551 lines
40 KiB
HTML
551 lines
40 KiB
HTML
<!DOCTYPE html>
|
|
|
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
<head>
|
|
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
<title>Image Manipulators — Ren'Py Documentation</title>
|
|
<link rel="stylesheet" href="_static/renpydoc.css" type="text/css" />
|
|
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
|
|
<link rel="stylesheet" type="text/css" href="_static/bootstrap-3.3.6/css/bootstrap.min.css" />
|
|
<link rel="stylesheet" type="text/css" href="_static/bootstrap-3.3.6/css/bootstrap-theme.min.css" />
|
|
<link rel="stylesheet" type="text/css" href="_static/bootstrap-sphinx.css" />
|
|
<script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></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>
|
|
<script type="text/javascript" src="_static/language_data.js"></script>
|
|
<script type="text/javascript" src="_static/js/jquery-1.11.0.min.js"></script>
|
|
<script type="text/javascript" src="_static/js/jquery-fix.js"></script>
|
|
<script type="text/javascript" src="_static/bootstrap-3.3.6/js/bootstrap.min.js"></script>
|
|
<script type="text/javascript" src="_static/bootstrap-sphinx.js"></script>
|
|
<link rel="index" title="Index" href="genindex.html" />
|
|
<link rel="search" title="Search" href="search.html" />
|
|
<meta charset='utf-8'>
|
|
<meta http-equiv='X-UA-Compatible' content='IE=edge,chrome=1'>
|
|
<meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=1'>
|
|
<meta name="apple-mobile-web-app-capable" content="yes">
|
|
|
|
</head><body>
|
|
|
|
<div id="navbar" class="navbar navbar-default navbar-fixed-top">
|
|
<div class="container">
|
|
<div class="navbar-header">
|
|
<!-- .btn-navbar is used as the toggle for collapsed navbar content -->
|
|
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".nav-collapse">
|
|
<span class="icon-bar"></span>
|
|
<span class="icon-bar"></span>
|
|
<span class="icon-bar"></span>
|
|
</button>
|
|
<a class="navbar-brand" href="index.html">
|
|
Ren'Py Documentation</a>
|
|
<span class="navbar-text navbar-version pull-left"><b>7.5.3</b></span>
|
|
</div>
|
|
|
|
<div class="collapse navbar-collapse nav-collapse">
|
|
<ul class="nav navbar-nav">
|
|
|
|
<li><a href="https://www.renpy.org">Home Page</a></li>
|
|
<li><a href="https://www.renpy.org/doc/html/">Online Documentation</a></li>
|
|
|
|
|
|
<li class="dropdown globaltoc-container">
|
|
<a role="button"
|
|
id="dLabelGlobalToc"
|
|
data-toggle="dropdown"
|
|
data-target="#"
|
|
href="index.html">Site <b class="caret"></b></a>
|
|
<ul class="dropdown-menu globaltoc"
|
|
role="menu"
|
|
aria-labelledby="dLabelGlobalToc"><ul>
|
|
<li class="toctree-l1"><a class="reference internal" href="quickstart.html">Quickstart</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="gui.html">GUI Customization Guide</a></li>
|
|
</ul>
|
|
<ul>
|
|
<li class="toctree-l1"><a class="reference internal" href="language_basics.html">Language Basics</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="label.html">Labels & Control Flow</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="dialogue.html">Dialogue and Narration</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="displaying_images.html">Displaying Images</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="menus.html">In-Game Menus</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="python.html">Python Statements</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="conditional.html">Conditional Statements</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="audio.html">Audio</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="movie.html">Movie</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="voice.html">Voice</a></li>
|
|
</ul>
|
|
<ul>
|
|
<li class="toctree-l1"><a class="reference internal" href="text.html">Text</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="translation.html">Translation</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="displayables.html">Displayables</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="transforms.html">Transforms</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="transitions.html">Transitions</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="atl.html">Animation and Transformation Language</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="matrixcolor.html">Matrixcolor</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="layeredimage.html">Layered Images</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="3dstage.html">3D Stage</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="live2d.html">Live2D Cubism</a></li>
|
|
</ul>
|
|
<ul>
|
|
<li class="toctree-l1"><a class="reference internal" href="style.html">Styles</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="style_properties.html">Style Properties</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="screens.html">Screens and Screen Language</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="screen_actions.html">Screen Actions, Values, and Functions</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="screen_special.html">Special Screen Names</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="screen_optimization.html">Screen Language Optimization</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="config.html">Configuration Variables</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="preferences.html">Preference Variables</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="store_variables.html">Store Variables</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="mouse.html">Custom Mouse Cursors</a></li>
|
|
</ul>
|
|
<ul>
|
|
<li class="toctree-l1"><a class="reference internal" href="launcher.html">Launcher</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="developer_tools.html">Developer Tools</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="director.html">Interactive Director</a></li>
|
|
</ul>
|
|
<ul>
|
|
<li class="toctree-l1"><a class="reference internal" href="nvl_mode.html">NVL-Mode Tutorial</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="input.html">Text Input</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="side_image.html">Side Images</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="rooms.html">Image Gallery, Music Room, and Replay Actions</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="drag_drop.html">Drag and Drop</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="sprites.html">Sprites</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="keymap.html">Customizing the Keymap</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="achievement.html">Achievements</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="history.html">Dialogue History</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="multiple.html">Multiple Character Dialogue</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="splashscreen_presplash.html">Splashscreen and Presplash</a></li>
|
|
</ul>
|
|
<ul>
|
|
<li class="toctree-l1"><a class="reference internal" href="statement_equivalents.html">Statement Equivalents</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="save_load_rollback.html">Saving, Loading, and Rollback</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="persistent.html">Persistent Data</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="trans_trans_python.html">Transforms and Transitions in Python</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="gui_advanced.html">Advanced GUI</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="screen_python.html">Screens and Python</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="modes.html">Modes</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cdd.html">Creator-Defined Displayables</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="cds.html">Creator-Defined Statements</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="custom_text_tags.html">Custom Text Tags</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="character_callbacks.html">Character Callbacks</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="file_python.html">File Access</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="color_class.html">Color Class</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="matrix.html">Matrix</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="model.html">Model-Based Rendering</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="other.html">Other Functions and Variables</a></li>
|
|
</ul>
|
|
<ul>
|
|
<li class="toctree-l1"><a class="reference internal" href="build.html">Building Distributions</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="updater.html">Web Updater</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="android.html">Android</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="chromeos.html">Chrome OS/Chromebook</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="ios.html">iOS</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="iap.html">In-App Purchasing</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="gesture.html">Gestures</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="raspi.html">Raspberry Pi</a></li>
|
|
</ul>
|
|
<ul>
|
|
<li class="toctree-l1"><a class="reference internal" href="security.html">Security</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="problems.html">Dealing with Problems</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="environment_variables.html">Environment Variables</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="self_voicing.html">Self-Voicing</a></li>
|
|
</ul>
|
|
<ul>
|
|
<li class="toctree-l1"><a class="reference internal" href="editor.html">Text Editor Integration</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="skins.html">Skins</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="translating_renpy.html">Translating Ren'Py</a></li>
|
|
</ul>
|
|
<ul>
|
|
<li class="toctree-l1"><a class="reference internal" href="changelog.html">Changelog (Ren'Py 7.x-)</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="changelog6.html">Changelog (Ren'Py 6.11 - 6.99)</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="incompatible.html">Incompatible Changes</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="distributor.html">Distributor Notes</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="license.html">License</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="credits.html">Credits</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="sponsors.html">Ren'Py Development Sponsors</a></li>
|
|
</ul>
|
|
<ul>
|
|
<li class="toctree-l1"><a class="reference internal" href="thequestion.html">Script of The Question</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="thequestion_nvl.html">NVL-mode script for The Question</a></li>
|
|
</ul>
|
|
</ul>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
<form class="navbar-form navbar-right" action="search.html" method="get">
|
|
<div class="form-group">
|
|
<input type="text" name="q" class="form-control" placeholder="Search" />
|
|
</div>
|
|
<input type="hidden" name="check_keywords" value="yes" />
|
|
<input type="hidden" name="area" value="default" />
|
|
</form>
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="container">
|
|
<div class="row">
|
|
<div class="col-md-3">
|
|
<div id="sidebar" class="bs-sidenav" role="complementary"><ul>
|
|
<li><a class="reference internal" href="#">Image Manipulators</a><ul>
|
|
<li><a class="reference internal" href="#im-matrixcolor">im.MatrixColor</a></li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
|
|
</div>
|
|
</div>
|
|
<div class="col-md-9 content">
|
|
|
|
<div class="section" id="image-manipulators">
|
|
<span id="image-manipulator"></span><h1>Image Manipulators<a class="headerlink" href="#image-manipulators" title="Permalink to this headline"> link</a></h1>
|
|
<p>An image manipulator is a displayable that takes an image or image
|
|
manipulator, and either loads it or performs an operation on it.
|
|
Image manipulators can only take images or other
|
|
image manipulators as input.</p>
|
|
<p>An image manipulator can be used any place a displayable can, but not
|
|
vice-versa. An <a class="reference internal" href="displayables.html#Image" title="Image"><code class="xref py py-func docutils literal notranslate"><span class="pre">Image()</span></code></a> is a kind of image manipulator, so an
|
|
Image can be used whenever an image manipulator is required.</p>
|
|
<p>With the few exceptions listed below, the use of image manipulators is
|
|
historic. A number of image manipulators that had been documented in the
|
|
past should no longer be used, as they suffer from inherent problems.
|
|
In any case except for <cite>im.Data</cite>, the <a class="reference internal" href="trans_trans_python.html#Transform" title="Transform"><code class="xref py py-func docutils literal notranslate"><span class="pre">Transform()</span></code></a> displayable provides
|
|
similar functionality in a more general manner, while fixing the problems,
|
|
although it sometimes requires gl2 to be enabled.</p>
|
|
<dl class="function">
|
|
<dt id="im.AlphaMask">
|
|
<code class="descclassname">im.</code><code class="descname">AlphaMask</code><span class="sig-paren">(</span><em>base</em>, <em>mask</em>, <em>**properties</em><span class="sig-paren">)</span><a class="headerlink" href="#im.AlphaMask" title="Permalink to this definition"> link</a></dt>
|
|
<dd><p>An image manipulator that takes two image manipulators, <cite>base</cite> and
|
|
<cite>mask</cite>, as arguments. It replaces the alpha channel of <cite>base</cite> with
|
|
the red channel of <cite>mask</cite>.</p>
|
|
<p>This is used to provide an image's alpha channel in a second
|
|
image, like having one jpeg for color data, and a second one
|
|
for alpha. In some cases, two jpegs can be smaller than a
|
|
single png file.</p>
|
|
<p>Note that this takes different arguments from <a class="reference internal" href="displayables.html#AlphaMask" title="AlphaMask"><code class="xref py py-func docutils literal notranslate"><span class="pre">AlphaMask()</span></code></a>,
|
|
which uses the mask's alpha channel.</p>
|
|
</dd></dl>
|
|
|
|
<dl class="function">
|
|
<dt id="im.Blur">
|
|
<code class="descclassname">im.</code><code class="descname">Blur</code><span class="sig-paren">(</span><em>im</em>, <em>xrad</em>, <em>yrad=None</em>, <em>**properties</em><span class="sig-paren">)</span><a class="headerlink" href="#im.Blur" title="Permalink to this definition"> link</a></dt>
|
|
<dd><p>An image manipulator that blurs the image manipulator <cite>im</cite> using
|
|
an elliptical kernel described by <cite>xrad</cite> and optionally <cite>yrad</cite>.</p>
|
|
<p>If <cite>yrad</cite> is None, it will take the value of <cite>xrad</cite> resulting in
|
|
a circular kernel being used.</p>
|
|
<div class="highlight-renpy notranslate"><div class="highlight"><pre><span></span><span class="k">image</span> <span class="n">logo</span> <span class="n">blurred</span> <span class="o">=</span> <span class="n">im</span><span class="o">.</span><span class="n">Blur</span><span class="p">(</span><span class="s2">"logo.png"</span><span class="p">,</span> <span class="mf">1.5</span><span class="p">)</span>
|
|
</pre></div>
|
|
</div>
|
|
<p>The same effect can now be achieved with the <a class="reference internal" href="atl.html#transform-property-blur"><code class="xref std std-tpref docutils literal notranslate"><span class="pre">blur</span></code></a> transform property.</p>
|
|
</dd></dl>
|
|
|
|
<dl class="function">
|
|
<dt id="im.Crop">
|
|
<code class="descclassname">im.</code><code class="descname">Crop</code><span class="sig-paren">(</span><em>im</em>, <em>rect</em><span class="sig-paren">)</span><a class="headerlink" href="#im.Crop" title="Permalink to this definition"> link</a></dt>
|
|
<dd><p>An image manipulator that crops <cite>rect</cite>, a (x, y, width, height) tuple,
|
|
out of <cite>im</cite>, an image manipulator.</p>
|
|
<div class="highlight-renpy notranslate"><div class="highlight"><pre><span></span><span class="k">image</span> <span class="n">logo</span> <span class="na">crop</span> <span class="o">=</span> <span class="n">im</span><span class="o">.</span><span class="n">Crop</span><span class="p">(</span><span class="s2">"logo.png"</span><span class="p">,</span> <span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">100</span><span class="p">,</span> <span class="mi">307</span><span class="p">))</span>
|
|
</pre></div>
|
|
</div>
|
|
<p>The same effect can now be achieved by setting the <a class="reference internal" href="atl.html#transform-property-crop"><code class="xref std std-tpref docutils literal notranslate"><span class="pre">crop</span></code></a> transform property.</p>
|
|
</dd></dl>
|
|
|
|
<dl class="function">
|
|
<dt id="im.Data">
|
|
<code class="descclassname">im.</code><code class="descname">Data</code><span class="sig-paren">(</span><em>data</em>, <em>filename</em>, <em>**properties</em><span class="sig-paren">)</span><a class="headerlink" href="#im.Data" title="Permalink to this definition"> link</a></dt>
|
|
<dd><p>This image manipulator loads an image from binary data.</p>
|
|
<dl class="docutils">
|
|
<dt><cite>data</cite></dt>
|
|
<dd>A string of bytes, giving the compressed image data in a standard
|
|
file format.</dd>
|
|
<dt><cite>filename</cite></dt>
|
|
<dd>A "filename" associated with the image. This is used to provide a
|
|
hint to Ren'Py about the format of <cite>data</cite>. (It's not actually
|
|
loaded from disk.)</dd>
|
|
</dl>
|
|
</dd></dl>
|
|
|
|
<dl class="function">
|
|
<dt id="im.FactorScale">
|
|
<code class="descclassname">im.</code><code class="descname">FactorScale</code><span class="sig-paren">(</span><em>im</em>, <em>width</em>, <em>height=None</em>, <em>bilinear=True</em>, <em>**properties</em><span class="sig-paren">)</span><a class="headerlink" href="#im.FactorScale" title="Permalink to this definition"> link</a></dt>
|
|
<dd><p>An image manipulator that scales <cite>im</cite> (a second image manipulator)
|
|
to <cite>width</cite> times its original <cite>width</cite>, and <cite>height</cite> times its
|
|
original height. If <cite>height</cite> is omitted, it defaults to <cite>width</cite>.</p>
|
|
<p>If <cite>bilinear</cite> is true, then bilinear interpolation is used for
|
|
the scaling. Otherwise, nearest neighbor interpolation is used.</p>
|
|
<div class="highlight-renpy notranslate"><div class="highlight"><pre><span></span><span class="k">image</span> <span class="n">logo</span> <span class="n">doubled</span> <span class="o">=</span> <span class="n">im</span><span class="o">.</span><span class="n">FactorScale</span><span class="p">(</span><span class="s2">"logo.png"</span><span class="p">,</span> <span class="mf">1.5</span><span class="p">)</span>
|
|
</pre></div>
|
|
</div>
|
|
<p>The same effect can now be achieved with the <a class="reference internal" href="atl.html#transform-property-zoom"><code class="xref std std-tpref docutils literal notranslate"><span class="pre">zoom</span></code></a> or the
|
|
<a class="reference internal" href="atl.html#transform-property-xzoom"><code class="xref std std-tpref docutils literal notranslate"><span class="pre">xzoom</span></code></a> and <a class="reference internal" href="atl.html#transform-property-yzoom"><code class="xref std std-tpref docutils literal notranslate"><span class="pre">yzoom</span></code></a> transform properties.</p>
|
|
</dd></dl>
|
|
|
|
<dl class="function">
|
|
<dt id="im.Flip">
|
|
<code class="descclassname">im.</code><code class="descname">Flip</code><span class="sig-paren">(</span><em>im</em>, <em>horizontal=False</em>, <em>vertical=False</em>, <em>**properties</em><span class="sig-paren">)</span><a class="headerlink" href="#im.Flip" title="Permalink to this definition"> link</a></dt>
|
|
<dd><p>An image manipulator that flips <cite>im</cite> (an image manipulator)
|
|
vertically or horizontally. <cite>vertical</cite> and <cite>horizontal</cite> control
|
|
the directions in which the image is flipped.</p>
|
|
<div class="highlight-renpy notranslate"><div class="highlight"><pre><span></span><span class="k">image</span> <span class="n">eileen</span> <span class="n">flip</span> <span class="o">=</span> <span class="n">im</span><span class="o">.</span><span class="n">Flip</span><span class="p">(</span><span class="s2">"eileen_happy.png"</span><span class="p">,</span> <span class="na">vertical</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
|
|
</pre></div>
|
|
</div>
|
|
<p>The same effect can now be achieved by setting
|
|
<a class="reference internal" href="atl.html#transform-property-xzoom"><code class="xref std std-tpref docutils literal notranslate"><span class="pre">xzoom</span></code></a> (for horizontal flip)
|
|
or <a class="reference internal" href="atl.html#transform-property-yzoom"><code class="xref std std-tpref docutils literal notranslate"><span class="pre">yzoom</span></code></a> (for vertical flip) to a negative value.</p>
|
|
</dd></dl>
|
|
|
|
<dl class="function">
|
|
<dt id="im.Grayscale">
|
|
<code class="descclassname">im.</code><code class="descname">Grayscale</code><span class="sig-paren">(</span><em>im</em>, <em>**properties</em><span class="sig-paren">)</span><a class="headerlink" href="#im.Grayscale" title="Permalink to this definition"> link</a></dt>
|
|
<dd><p>An image manipulator that creates a desaturated version of the image
|
|
manipulator <cite>im</cite>.</p>
|
|
<p>The same effect can now be achieved by supplying SaturationMatrix(0)
|
|
to the <a class="reference internal" href="atl.html#transform-property-matrixcolor"><code class="xref std std-tpref docutils literal notranslate"><span class="pre">matrixcolor</span></code></a> transform property.</p>
|
|
</dd></dl>
|
|
|
|
<dl class="function">
|
|
<dt id="im.Sepia">
|
|
<code class="descclassname">im.</code><code class="descname">Sepia</code><span class="sig-paren">(</span><em>im</em>, <em>**properties</em><span class="sig-paren">)</span><a class="headerlink" href="#im.Sepia" title="Permalink to this definition"> link</a></dt>
|
|
<dd><p>An image manipulator that creates a sepia-toned version of the image
|
|
manipulator <cite>im</cite>.</p>
|
|
<p>The same effect can now be achieved by supplying SepiaMatrix()
|
|
to the <a class="reference internal" href="atl.html#transform-property-matrixcolor"><code class="xref std std-tpref docutils literal notranslate"><span class="pre">matrixcolor</span></code></a> transform property.</p>
|
|
</dd></dl>
|
|
|
|
<dl class="function">
|
|
<dt id="im.Tile">
|
|
<code class="descclassname">im.</code><code class="descname">Tile</code><span class="sig-paren">(</span><em>im</em>, <em>size=None</em>, <em>**properties</em><span class="sig-paren">)</span><a class="headerlink" href="#im.Tile" title="Permalink to this definition"> link</a></dt>
|
|
<dd><p>An image manipulator that tiles the image manipulator <cite>im</cite>, until
|
|
it is <cite>size</cite>.</p>
|
|
<dl class="docutils">
|
|
<dt><cite>size</cite></dt>
|
|
<dd>If not None, a (width, height) tuple. If None, this defaults to
|
|
(<a class="reference internal" href="config.html#var-config.screen_width"><code class="xref std std-var docutils literal notranslate"><span class="pre">config.screen_width</span></code></a>, <a class="reference internal" href="config.html#var-config.screen_height"><code class="xref std std-var docutils literal notranslate"><span class="pre">config.screen_height</span></code></a>).</dd>
|
|
</dl>
|
|
<p>The same effect can now be achieved using the <a class="reference internal" href="displayables.html#Tile" title="Tile"><code class="xref py py-func docutils literal notranslate"><span class="pre">Tile()</span></code></a>
|
|
displayable, with <code class="docutils literal notranslate"><span class="pre">Tile(im,</span> <span class="pre">size=size)</span></code>.</p>
|
|
</dd></dl>
|
|
|
|
<div class="section" id="im-matrixcolor">
|
|
<h2>im.MatrixColor<a class="headerlink" href="#im-matrixcolor" title="Permalink to this headline"> link</a></h2>
|
|
<p>The im.MatrixColor image manipulator is an image manipulator that uses
|
|
a matrix to control how the colors of an image are transformed. The
|
|
matrix used can be an im.matrix object, which encodes a 5x5 matrix in
|
|
an object that supports matrix multiplication, and is returned by a
|
|
series of functions. im.matrix objects may be multiplied together to
|
|
yield a second object that performs both operations. For example:</p>
|
|
<div class="highlight-renpy notranslate"><div class="highlight"><pre><span></span><span class="k">image</span> <span class="n">city</span> <span class="n">blue</span> <span class="o">=</span> <span class="n">im</span><span class="o">.</span><span class="n">MatrixColor</span><span class="p">(</span>
|
|
<span class="s2">"city.jpg"</span><span class="p">,</span>
|
|
<span class="n">im</span><span class="o">.</span><span class="n">matrix</span><span class="o">.</span><span class="n">desaturate</span><span class="p">()</span> <span class="o">*</span> <span class="n">im</span><span class="o">.</span><span class="n">matrix</span><span class="o">.</span><span class="n">tint</span><span class="p">(</span><span class="mf">0.9</span><span class="p">,</span> <span class="mf">0.9</span><span class="p">,</span> <span class="mf">1.0</span><span class="p">))</span>
|
|
</pre></div>
|
|
</div>
|
|
<p>first desaturates the image, and then tints it blue. When the
|
|
intermediate image is not needed, multiplying matrices is far
|
|
more efficient, in both time and image cache space, than using
|
|
two im.MatrixColors.</p>
|
|
<p>The im.MatrixColor image manipulator has been replaced by Transforms
|
|
and ATL transforms that specify the matrixcolor property. Each <cite>im.matrix</cite>
|
|
generator has been given a new <cite>Matrix</cite> equivalent, which can be found
|
|
in the <a class="reference internal" href="matrixcolor.html"><span class="doc">matrixcolor documentation</span></a>.</p>
|
|
<div class="admonition warning">
|
|
<p class="first admonition-title">Warning</p>
|
|
<p class="last">The new Matrix objects multiply in the opposite order as the im.Matrixcolor
|
|
ones. With X being the Matrix corresponding to im.Matrixcolor.x,
|
|
<code class="docutils literal notranslate"><span class="pre">C*B*A</span></code> will be the Matrix corresponding to <code class="docutils literal notranslate"><span class="pre">im.a*im.b*im.c</span></code>.</p>
|
|
</div>
|
|
<dl class="function">
|
|
<dt id="im.MatrixColor">
|
|
<code class="descclassname">im.</code><code class="descname">MatrixColor</code><span class="sig-paren">(</span><em>im</em>, <em>matrix</em>, <em>**properties</em><span class="sig-paren">)</span><a class="headerlink" href="#im.MatrixColor" title="Permalink to this definition"> link</a></dt>
|
|
<dd><p>An image operator that uses <cite>matrix</cite> to linearly transform the
|
|
image manipulator <cite>im</cite>.</p>
|
|
<p><cite>Matrix</cite> should be a list, tuple, or <a class="reference internal" href="#im.matrix" title="im.matrix"><code class="xref py py-func docutils literal notranslate"><span class="pre">im.matrix()</span></code></a> that is 20
|
|
or 25 elements long. If the object has 25 elements, then elements
|
|
past the 20th are ignored.</p>
|
|
<p>When the four components of the source color are R, G, B, and A,
|
|
which range from 0.0 to 1.0; the four components of the transformed
|
|
color are R', G', B', and A', with the same range; and the elements
|
|
of the matrix are named:</p>
|
|
<div class="highlight-renpy notranslate"><div class="highlight"><pre><span></span><span class="p">[</span> <span class="n">a</span><span class="p">,</span> <span class="n">b</span><span class="p">,</span> <span class="n">c</span><span class="p">,</span> <span class="n">d</span><span class="p">,</span> <span class="n">e</span><span class="p">,</span>
|
|
<span class="n">f</span><span class="p">,</span> <span class="n">g</span><span class="p">,</span> <span class="n">h</span><span class="p">,</span> <span class="n">i</span><span class="p">,</span> <span class="n">j</span><span class="p">,</span>
|
|
<span class="n">k</span><span class="p">,</span> <span class="n">l</span><span class="p">,</span> <span class="n">m</span><span class="p">,</span> <span class="n">n</span><span class="p">,</span> <span class="n">o</span><span class="p">,</span>
|
|
<span class="n">p</span><span class="p">,</span> <span class="n">q</span><span class="p">,</span> <span class="n">r</span><span class="p">,</span> <span class="n">s</span><span class="p">,</span> <span class="n">t</span> <span class="p">]</span>
|
|
</pre></div>
|
|
</div>
|
|
<p>the transformed colors can be computed with the formula:</p>
|
|
<div class="highlight-renpy notranslate"><div class="highlight"><pre><span></span><span class="sa">R</span><span class="s1">' = (a * R) + (b * G) + (c * B) + (d * A) + e</span>
|
|
<span class="n">G</span><span class="s1">' = (f * R) + (g * G) + (h * B) + (i * A) + j</span>
|
|
<span class="sa">B</span><span class="s1">' = (k * R) + (l * G) + (m * B) + (n * A) + o</span>
|
|
<span class="n">A</span><span class="s1">' = (p * R) + (q * G) + (r * B) + (s * A) + t</span>
|
|
</pre></div>
|
|
</div>
|
|
<p>The components of the transformed color are clamped to the
|
|
range [0.0, 1.0].</p>
|
|
</dd></dl>
|
|
|
|
<dl class="function">
|
|
<dt id="im.matrix">
|
|
<code class="descclassname">im.</code><code class="descname">matrix</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#im.matrix" title="Permalink to this definition"> link</a></dt>
|
|
<dd><p>Constructs an im.matrix object from <cite>matrix</cite>. im.matrix objects
|
|
support The operations supported are matrix multiplication, scalar
|
|
multiplication, element-wise addition, and element-wise
|
|
subtraction. These operations are invoked using the standard
|
|
mathematical operators (*, *, +, and -, respectively). If two
|
|
im.matrix objects are multiplied, matrix multiplication is
|
|
performed, otherwise scalar multiplication is used.</p>
|
|
<p><cite>matrix</cite> is a 20 or 25 element list or tuple. If it is 20 elements
|
|
long, it is padded with (0, 0, 0, 0, 1) to make a 5x5 matrix,
|
|
suitable for multiplication.</p>
|
|
</dd></dl>
|
|
|
|
<dl class="function">
|
|
<dt id="im.matrix.brightness">
|
|
<code class="descclassname">im.matrix.</code><code class="descname">brightness</code><span class="sig-paren">(</span><em>b</em><span class="sig-paren">)</span><a class="headerlink" href="#im.matrix.brightness" title="Permalink to this definition"> link</a></dt>
|
|
<dd><p>Returns an im.matrix that alters the brightness of an image.</p>
|
|
<dl class="docutils">
|
|
<dt><cite>b</cite></dt>
|
|
<dd>The amount of change in image brightness. This should be
|
|
a number between -1 and 1, with -1 the darkest possible
|
|
image and 1 the brightest.</dd>
|
|
</dl>
|
|
<p>A suitable equivalent for the <a class="reference internal" href="atl.html#transform-property-matrixcolor"><code class="xref std std-tpref docutils literal notranslate"><span class="pre">matrixcolor</span></code></a> transform property
|
|
is BrightnessMatrix(b).</p>
|
|
</dd></dl>
|
|
|
|
<dl class="function">
|
|
<dt id="im.matrix.colorize">
|
|
<code class="descclassname">im.matrix.</code><code class="descname">colorize</code><span class="sig-paren">(</span><em>black_color</em>, <em>white_color</em><span class="sig-paren">)</span><a class="headerlink" href="#im.matrix.colorize" title="Permalink to this definition"> link</a></dt>
|
|
<dd><p>Returns an im.matrix that colorizes a black and white image.
|
|
<cite>black_color</cite> and <cite>white_color</cite> are Ren'Py style colors, so
|
|
they may be specified as strings or tuples of (0-255) color
|
|
values.</p>
|
|
<div class="highlight-renpy notranslate"><div class="highlight"><pre><span></span><span class="c1"># This makes black colors red, and white colors blue.</span>
|
|
<span class="k">image</span> <span class="n">logo</span> <span class="n">colored</span> <span class="o">=</span> <span class="n">im</span><span class="o">.</span><span class="n">MatrixColor</span><span class="p">(</span>
|
|
<span class="s2">"bwlogo.png"</span><span class="p">,</span>
|
|
<span class="n">im</span><span class="o">.</span><span class="n">matrix</span><span class="o">.</span><span class="n">colorize</span><span class="p">(</span><span class="s2">"#f00"</span><span class="p">,</span> <span class="s2">"#00f"</span><span class="p">))</span>
|
|
</pre></div>
|
|
</div>
|
|
<p>A suitable equivalent for the <a class="reference internal" href="atl.html#transform-property-matrixcolor"><code class="xref std std-tpref docutils literal notranslate"><span class="pre">matrixcolor</span></code></a> transform property
|
|
is ColorizeMatrix(black_color, white_color).</p>
|
|
</dd></dl>
|
|
|
|
<dl class="function">
|
|
<dt id="im.matrix.contrast">
|
|
<code class="descclassname">im.matrix.</code><code class="descname">contrast</code><span class="sig-paren">(</span><em>c</em><span class="sig-paren">)</span><a class="headerlink" href="#im.matrix.contrast" title="Permalink to this definition"> link</a></dt>
|
|
<dd><p>Returns an im.matrix that alters the contrast of an image. <cite>c</cite> should
|
|
be greater than 0.0, with values between 0.0 and 1.0 decreasing contrast, and
|
|
values greater than 1.0 increasing contrast.</p>
|
|
<p>A suitable equivalent for the <a class="reference internal" href="atl.html#transform-property-matrixcolor"><code class="xref std std-tpref docutils literal notranslate"><span class="pre">matrixcolor</span></code></a> transform property
|
|
is ContrastMatrix(c).</p>
|
|
</dd></dl>
|
|
|
|
<dl class="function">
|
|
<dt id="im.matrix.desaturate">
|
|
<code class="descclassname">im.matrix.</code><code class="descname">desaturate</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#im.matrix.desaturate" title="Permalink to this definition"> link</a></dt>
|
|
<dd><p>Returns an im.matrix that desaturates the image (makes it
|
|
grayscale). This is equivalent to calling
|
|
im.matrix.saturation(0).</p>
|
|
<p>A suitable equivalent for the <a class="reference internal" href="atl.html#transform-property-matrixcolor"><code class="xref std std-tpref docutils literal notranslate"><span class="pre">matrixcolor</span></code></a> transform property
|
|
is SaturationMatrix(0).</p>
|
|
</dd></dl>
|
|
|
|
<dl class="function">
|
|
<dt id="im.matrix.hue">
|
|
<code class="descclassname">im.matrix.</code><code class="descname">hue</code><span class="sig-paren">(</span><em>h</em><span class="sig-paren">)</span><a class="headerlink" href="#im.matrix.hue" title="Permalink to this definition"> link</a></dt>
|
|
<dd><p>Returns an im.matrix that rotates the hue by <cite>h</cite> degrees, while
|
|
preserving luminosity.</p>
|
|
<p>A suitable equivalent for the <a class="reference internal" href="atl.html#transform-property-matrixcolor"><code class="xref std std-tpref docutils literal notranslate"><span class="pre">matrixcolor</span></code></a> transform property
|
|
is HueMatrix(h).</p>
|
|
</dd></dl>
|
|
|
|
<dl class="function">
|
|
<dt id="im.matrix.identity">
|
|
<code class="descclassname">im.matrix.</code><code class="descname">identity</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#im.matrix.identity" title="Permalink to this definition"> link</a></dt>
|
|
<dd><p>Returns an identity matrix, one that does not change color or
|
|
alpha.</p>
|
|
<p>A suitable equivalent for the <a class="reference internal" href="atl.html#transform-property-matrixcolor"><code class="xref std std-tpref docutils literal notranslate"><span class="pre">matrixcolor</span></code></a> transform property
|
|
is IdentityMatrix().</p>
|
|
</dd></dl>
|
|
|
|
<dl class="function">
|
|
<dt id="im.matrix.invert">
|
|
<code class="descclassname">im.matrix.</code><code class="descname">invert</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#im.matrix.invert" title="Permalink to this definition"> link</a></dt>
|
|
<dd><p>Returns an im.matrix that inverts the red, green, and blue
|
|
channels of the image without changing the alpha channel.</p>
|
|
<p>A suitable equivalent for the <a class="reference internal" href="atl.html#transform-property-matrixcolor"><code class="xref std std-tpref docutils literal notranslate"><span class="pre">matrixcolor</span></code></a> transform property
|
|
is InvertMatrix(1.0).</p>
|
|
</dd></dl>
|
|
|
|
<dl class="function">
|
|
<dt id="im.matrix.opacity">
|
|
<code class="descclassname">im.matrix.</code><code class="descname">opacity</code><span class="sig-paren">(</span><em>o</em><span class="sig-paren">)</span><a class="headerlink" href="#im.matrix.opacity" title="Permalink to this definition"> link</a></dt>
|
|
<dd><p>Returns an im.matrix that alters the opacity of an image. An
|
|
<cite>o</cite> of 0.0 is fully transparent, while 1.0 is fully opaque.</p>
|
|
<p>A suitable equivalent for the <a class="reference internal" href="atl.html#transform-property-matrixcolor"><code class="xref std std-tpref docutils literal notranslate"><span class="pre">matrixcolor</span></code></a> transform property
|
|
is OpacityMatrix(o).</p>
|
|
</dd></dl>
|
|
|
|
<dl class="function">
|
|
<dt id="im.matrix.saturation">
|
|
<code class="descclassname">im.matrix.</code><code class="descname">saturation</code><span class="sig-paren">(</span><em>level</em>, <em>desat=(0.2126</em>, <em>0.7152</em>, <em>0.0722)</em><span class="sig-paren">)</span><a class="headerlink" href="#im.matrix.saturation" title="Permalink to this definition"> link</a></dt>
|
|
<dd><p>Returns an im.matrix that alters the saturation of an
|
|
image. The alpha channel is untouched.</p>
|
|
<dl class="docutils">
|
|
<dt><cite>level</cite></dt>
|
|
<dd>The amount of saturation in the resulting image. 1.0 is
|
|
the unaltered image, while 0.0 is grayscale.</dd>
|
|
<dt><cite>desat</cite></dt>
|
|
<dd>This is a 3-element tuple that controls how much of the
|
|
red, green, and blue channels will be placed into all
|
|
three channels of a fully desaturated image. The default
|
|
is based on the constants used for the luminance channel
|
|
of an NTSC television signal. Since the human eye is
|
|
mostly sensitive to green, more of the green channel is
|
|
kept then the other two channels.</dd>
|
|
</dl>
|
|
<p>A suitable equivalent for the <a class="reference internal" href="atl.html#transform-property-matrixcolor"><code class="xref std std-tpref docutils literal notranslate"><span class="pre">matrixcolor</span></code></a> transform property
|
|
is SaturationMatrix(value, desat).</p>
|
|
</dd></dl>
|
|
|
|
<dl class="function">
|
|
<dt id="im.matrix.tint">
|
|
<code class="descclassname">im.matrix.</code><code class="descname">tint</code><span class="sig-paren">(</span><em>r</em>, <em>g</em>, <em>b</em><span class="sig-paren">)</span><a class="headerlink" href="#im.matrix.tint" title="Permalink to this definition"> link</a></dt>
|
|
<dd><p>Returns an im.matrix that tints an image, without changing
|
|
the alpha channel. <cite>r</cite>, <cite>g</cite>, and <cite>b</cite> should be numbers between
|
|
0 and 1, and control what fraction of the given channel is
|
|
placed into the final image. (For example, if <cite>r</cite> is .5, and
|
|
the value of the red channel is 100, the transformed color
|
|
will have a red value of 50.)</p>
|
|
<p>A suitable equivalent for the <a class="reference internal" href="atl.html#transform-property-matrixcolor"><code class="xref std std-tpref docutils literal notranslate"><span class="pre">matrixcolor</span></code></a> transform property
|
|
is TintMatrix(Color((r, g, b))).</p>
|
|
</dd></dl>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
<footer class="footer">
|
|
<div class="container">
|
|
<p class="pull-right">
|
|
<a href="#">Back to top</a>
|
|
|
|
</p>
|
|
<p>
|
|
© Copyright 2012-2022, Tom Rothamel.<br/>
|
|
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.8.6.<br/>
|
|
</p>
|
|
</div>
|
|
</footer>
|
|
</body>
|
|
</html> |