rusty_snek_gaem/target/doc/graphics/trait.Graphics.html
2018-10-28 21:14:05 -05:00

124 lines
36 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="API documentation for the Rust `Graphics` trait in crate `graphics`."><meta name="keywords" content="rust, rustlang, rust-lang, Graphics"><title>graphics::Graphics - Rust</title><link rel="stylesheet" type="text/css" href="../normalize.css"><link rel="stylesheet" type="text/css" href="../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../dark.css"><link rel="stylesheet" type="text/css" href="../light.css" id="themeStyle"><script src="../storage.js"></script></head><body class="rustdoc trait"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">&#9776;</div><p class='location'>Trait Graphics</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#associated-types">Associated Types</a><div class="sidebar-links"><a href="#associatedtype.Texture">Texture</a></div><a class="sidebar-title" href="#required-methods">Required Methods</a><div class="sidebar-links"><a href="#tymethod.clear_color">clear_color</a><a href="#tymethod.clear_stencil">clear_stencil</a><a href="#tymethod.tri_list">tri_list</a><a href="#tymethod.tri_list_uv">tri_list_uv</a></div><a class="sidebar-title" href="#provided-methods">Provided Methods</a><div class="sidebar-links"><a href="#method.rectangle">rectangle</a><a href="#method.polygon">polygon</a><a href="#method.polygon_tween_lerp">polygon_tween_lerp</a><a href="#method.image">image</a><a href="#method.ellipse">ellipse</a><a href="#method.line">line</a><a href="#method.circle_arc">circle_arc</a><a href="#method.deform_image">deform_image</a></div><a class="sidebar-title" href="#implementors">Implementors</a></div><p class='location'><a href='index.html'>graphics</a></p><script>window.sidebarCurrent = {name: 'Graphics', ty: 'trait', relpath: ''};</script><script defer src="sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!"><img src="../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices"></div></div><script src="../theme.js"></script><nav class="sub"><form class="search-form js-only"><div class="search-container"><input class="search-input" name="search" autocomplete="off" placeholder="Click or press S to search, ? for more options…" type="search"><a id="settings-menu" href="../settings.html"><img src="../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class='fqn'><span class='in-band'>Trait <a href='index.html'>graphics</a>::<wbr><a class="trait" href=''>Graphics</a></span><span class='out-of-band'><span id='render-detail'><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class='inner'>&#x2212;</span>]</a></span><a class='srclink' href='../src/graphics/graphics.rs.html#36-227' title='goto source code'>[src]</a></span></h1><div class="docblock type-decl"><pre class='rust trait'>pub trait Graphics: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> {
type <a href='#associatedtype.Texture' class="type">Texture</a>: <a class="trait" href="../graphics/trait.ImageSize.html" title="trait graphics::ImageSize">ImageSize</a>;
fn <a href='#tymethod.clear_color' class='fnname'>clear_color</a>(&amp;mut self, color: <a class="type" href="../graphics/types/type.Color.html" title="type graphics::types::Color">Color</a>);
<div class='item-spacer'></div> fn <a href='#tymethod.clear_stencil' class='fnname'>clear_stencil</a>(&amp;mut self, value: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>);
<div class='item-spacer'></div> fn <a href='#tymethod.tri_list' class='fnname'>tri_list</a>&lt;F&gt;(&amp;mut self, draw_state: &amp;<a class="struct" href="../graphics/draw_state/struct.DrawState.html" title="struct graphics::draw_state::DrawState">DrawState</a>, color: &amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.array.html">[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f32.html">f32</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.array.html">; 4]</a>, f: F)<br>&nbsp;&nbsp;&nbsp; <span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(&amp;mut <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.array.html">[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f32.html">f32</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.array.html">; 2]</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>))</span>;
<div class='item-spacer'></div> fn <a href='#tymethod.tri_list_uv' class='fnname'>tri_list_uv</a>&lt;F&gt;(<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&amp;mut self, <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;draw_state: &amp;<a class="struct" href="../graphics/draw_state/struct.DrawState.html" title="struct graphics::draw_state::DrawState">DrawState</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;color: &amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.array.html">[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f32.html">f32</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.array.html">; 4]</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;texture: &amp;Self::<a class="type" href="../graphics/trait.Graphics.html#associatedtype.Texture" title="type graphics::Graphics::Texture">Texture</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;f: F<br>&nbsp;&nbsp;&nbsp;&nbsp;)<br>&nbsp;&nbsp;&nbsp; <span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(&amp;mut <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.array.html">[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f32.html">f32</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.array.html">; 2]</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>, <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.array.html">[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f32.html">f32</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.array.html">; 2]</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>))</span>;
fn <a href='#method.rectangle' class='fnname'>rectangle</a>&lt;R:&nbsp;<a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a>&lt;<a class="type" href="../graphics/types/type.Rectangle.html" title="type graphics::types::Rectangle">Rectangle</a>&gt;&gt;(<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&amp;mut self, <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;r: &amp;<a class="struct" href="../graphics/rectangle/struct.Rectangle.html" title="struct graphics::rectangle::Rectangle">Rectangle</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rectangle: R, <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;draw_state: &amp;<a class="struct" href="../graphics/draw_state/struct.DrawState.html" title="struct graphics::draw_state::DrawState">DrawState</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;transform: <a class="type" href="../graphics/math/type.Matrix2d.html" title="type graphics::math::Matrix2d">Matrix2d</a><br>&nbsp;&nbsp;&nbsp;&nbsp;) { ... }
<div class='item-spacer'></div> fn <a href='#method.polygon' class='fnname'>polygon</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&amp;mut self, <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;p: &amp;<a class="struct" href="../graphics/polygon/struct.Polygon.html" title="struct graphics::polygon::Polygon">Polygon</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;polygon: <a class="type" href="../graphics/types/type.Polygon.html" title="type graphics::types::Polygon">Polygon</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;draw_state: &amp;<a class="struct" href="../graphics/draw_state/struct.DrawState.html" title="struct graphics::draw_state::DrawState">DrawState</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;transform: <a class="type" href="../graphics/math/type.Matrix2d.html" title="type graphics::math::Matrix2d">Matrix2d</a><br>&nbsp;&nbsp;&nbsp;&nbsp;) { ... }
<div class='item-spacer'></div> fn <a href='#method.polygon_tween_lerp' class='fnname'>polygon_tween_lerp</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&amp;mut self, <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;p: &amp;<a class="struct" href="../graphics/polygon/struct.Polygon.html" title="struct graphics::polygon::Polygon">Polygon</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;polygons: <a class="type" href="../graphics/types/type.Polygons.html" title="type graphics::types::Polygons">Polygons</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tween_factor: <a class="type" href="../graphics/math/type.Scalar.html" title="type graphics::math::Scalar">Scalar</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;draw_state: &amp;<a class="struct" href="../graphics/draw_state/struct.DrawState.html" title="struct graphics::draw_state::DrawState">DrawState</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;transform: <a class="type" href="../graphics/math/type.Matrix2d.html" title="type graphics::math::Matrix2d">Matrix2d</a><br>&nbsp;&nbsp;&nbsp;&nbsp;) { ... }
<div class='item-spacer'></div> fn <a href='#method.image' class='fnname'>image</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&amp;mut self, <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;image: &amp;<a class="struct" href="../graphics/image/struct.Image.html" title="struct graphics::image::Image">Image</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;texture: &amp;Self::<a class="type" href="../graphics/trait.Graphics.html#associatedtype.Texture" title="type graphics::Graphics::Texture">Texture</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;draw_state: &amp;<a class="struct" href="../graphics/draw_state/struct.DrawState.html" title="struct graphics::draw_state::DrawState">DrawState</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;transform: <a class="type" href="../graphics/math/type.Matrix2d.html" title="type graphics::math::Matrix2d">Matrix2d</a><br>&nbsp;&nbsp;&nbsp;&nbsp;) { ... }
<div class='item-spacer'></div> fn <a href='#method.ellipse' class='fnname'>ellipse</a>&lt;R:&nbsp;<a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a>&lt;<a class="type" href="../graphics/types/type.Rectangle.html" title="type graphics::types::Rectangle">Rectangle</a>&gt;&gt;(<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&amp;mut self, <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;e: &amp;<a class="struct" href="../graphics/ellipse/struct.Ellipse.html" title="struct graphics::ellipse::Ellipse">Ellipse</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rectangle: R, <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;draw_state: &amp;<a class="struct" href="../graphics/draw_state/struct.DrawState.html" title="struct graphics::draw_state::DrawState">DrawState</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;transform: <a class="type" href="../graphics/math/type.Matrix2d.html" title="type graphics::math::Matrix2d">Matrix2d</a><br>&nbsp;&nbsp;&nbsp;&nbsp;) { ... }
<div class='item-spacer'></div> fn <a href='#method.line' class='fnname'>line</a>&lt;L:&nbsp;<a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a>&lt;<a class="type" href="../graphics/types/type.Line.html" title="type graphics::types::Line">Line</a>&gt;&gt;(<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&amp;mut self, <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;l: &amp;<a class="struct" href="../graphics/line/struct.Line.html" title="struct graphics::line::Line">Line</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;line: L, <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;draw_state: &amp;<a class="struct" href="../graphics/draw_state/struct.DrawState.html" title="struct graphics::draw_state::DrawState">DrawState</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;transform: <a class="type" href="../graphics/math/type.Matrix2d.html" title="type graphics::math::Matrix2d">Matrix2d</a><br>&nbsp;&nbsp;&nbsp;&nbsp;) { ... }
<div class='item-spacer'></div> fn <a href='#method.circle_arc' class='fnname'>circle_arc</a>&lt;R:&nbsp;<a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a>&lt;<a class="type" href="../graphics/types/type.Rectangle.html" title="type graphics::types::Rectangle">Rectangle</a>&gt;&gt;(<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&amp;mut self, <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;c: &amp;<a class="struct" href="../graphics/circle_arc/struct.CircleArc.html" title="struct graphics::circle_arc::CircleArc">CircleArc</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rectangle: R, <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;draw_state: &amp;<a class="struct" href="../graphics/draw_state/struct.DrawState.html" title="struct graphics::draw_state::DrawState">DrawState</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;transform: <a class="type" href="../graphics/math/type.Matrix2d.html" title="type graphics::math::Matrix2d">Matrix2d</a><br>&nbsp;&nbsp;&nbsp;&nbsp;) { ... }
<div class='item-spacer'></div> fn <a href='#method.deform_image' class='fnname'>deform_image</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&amp;mut self, <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;d: &amp;<a class="struct" href="../graphics/deform/struct.DeformGrid.html" title="struct graphics::deform::DeformGrid">DeformGrid</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;texture: &amp;Self::<a class="type" href="../graphics/trait.Graphics.html#associatedtype.Texture" title="type graphics::Graphics::Texture">Texture</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;draw_state: &amp;<a class="struct" href="../graphics/draw_state/struct.DrawState.html" title="struct graphics::draw_state::DrawState">DrawState</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;transform: <a class="type" href="../graphics/math/type.Matrix2d.html" title="type graphics::math::Matrix2d">Matrix2d</a><br>&nbsp;&nbsp;&nbsp;&nbsp;) { ... }
}</pre></div><div class='docblock'><p>Implemented by all graphics back-ends.</p>
<p><a href="https://github.com/PistonDevelopers/opengl_graphics">An example back-end using raw OpenGL</a></p>
<p>By default, this design uses triangles as graphics primitives.
This is supported by all GPUs and easy to implement in shader languages.</p>
<p>Default trait methods can be overridden for better performance or higher
quality.</p>
<p>When drawing, use this trait as generic constraint:</p>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">graphics</span>::{<span class="ident">Graphics</span>, <span class="ident">Context</span>};
<span class="kw">fn</span> <span class="ident">draw</span><span class="op">&lt;</span><span class="ident">G</span>: <span class="ident">Graphics</span><span class="op">&gt;</span>(<span class="ident">c</span>: <span class="kw-2">&amp;</span><span class="ident">Context</span>, <span class="ident">g</span>: <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">G</span>) {
<span class="comment">//...</span>
}</pre>
<p>Color space is sRGB.</p>
<h3 id="notice-for-back-end-authors" class="section-header"><a href="#notice-for-back-end-authors">Notice for back-end authors</a></h3>
<p>When sRGB is enabled for a back-end shader, the gamma must be converted
to linear space when used as vertex color or uniform parameter.
To convert gamma, use <code>color::gamma_srgb_to_linear</code>.</p>
<p>For more information, see
https://github.com/PistonDevelopers/piston/issues/1014.</p>
</div>
<h2 id='associated-types' class='small-section-header'>
Associated Types<a href='#associated-types' class='anchor'></a>
</h2>
<div class='methods'>
<h3 id='associatedtype.Texture' class='method'><span id='Texture.t' class='invisible'><code>type <a href='#associatedtype.Texture' class="type">Texture</a>: <a class="trait" href="../graphics/trait.ImageSize.html" title="trait graphics::ImageSize">ImageSize</a></code></span></h3><div class='docblock'><p>The texture type associated with the back-end.</p>
<p>In generic code, this type is often unknown.
This might lead to more boilerplate code:</p>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">graphics</span>::{<span class="ident">Graphics</span>, <span class="ident">Context</span>, <span class="ident">ImageSize</span>};
<span class="kw">fn</span> <span class="ident">draw_texture</span><span class="op">&lt;</span><span class="ident">G</span>, <span class="ident">T</span><span class="op">&gt;</span>(<span class="ident">c</span>: <span class="kw-2">&amp;</span><span class="ident">Context</span>, <span class="ident">g</span>: <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">G</span>)
<span class="kw">where</span> <span class="ident">G</span>: <span class="ident">Graphics</span><span class="op">&lt;</span><span class="ident">Texture</span> <span class="op">=</span> <span class="ident">T</span><span class="op">&gt;</span>, <span class="ident">T</span>: <span class="ident">ImageSize</span> {
<span class="comment">//...</span>
}</pre>
<p>Code written specifically for one back-end can be easier to write.
Later, when the code is done, it can be refactored into generic code.</p>
</div></div>
<h2 id='required-methods' class='small-section-header'>
Required Methods<a href='#required-methods' class='anchor'></a>
</h2>
<div class='methods'>
<h3 id='tymethod.clear_color' class='method'><span id='clear_color.v' class='invisible'><code>fn <a href='#tymethod.clear_color' class='fnname'>clear_color</a>(&amp;mut self, color: <a class="type" href="../graphics/types/type.Color.html" title="type graphics::types::Color">Color</a>)</code></span></h3><div class='docblock'><p>Clears background with a color.</p>
<p>The color should replace the values in the buffer.</p>
<p>Color space is sRGB.</p>
</div><h3 id='tymethod.clear_stencil' class='method'><span id='clear_stencil.v' class='invisible'><code>fn <a href='#tymethod.clear_stencil' class='fnname'>clear_stencil</a>(&amp;mut self, value: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>)</code></span></h3><div class='docblock'><p>Clears stencil buffer with a value, usually 0.</p>
<p>A stencil buffer contains values that are not visible on the screen.
These values are used to test against the pixel to paint.</p>
<p>If you are drawing a shape for clipping and forgot to clear the
stencil buffer, then the clipping shape will carry over in next frame
and cause artifacts.</p>
</div><h3 id='tymethod.tri_list' class='method'><span id='tri_list.v' class='invisible'><code>fn <a href='#tymethod.tri_list' class='fnname'>tri_list</a>&lt;F&gt;(&amp;mut self, draw_state: &amp;<a class="struct" href="../graphics/draw_state/struct.DrawState.html" title="struct graphics::draw_state::DrawState">DrawState</a>, color: &amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.array.html">[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f32.html">f32</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.array.html">; 4]</a>, f: F) <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(&amp;mut <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.array.html">[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f32.html">f32</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.array.html">; 2]</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>)),&nbsp;</span></code></span></h3><div class='docblock'><p>Renders list of 2d triangles using a solid color.</p>
<p>All vertices share the same color.</p>
<p>The back-end calls the closure with a closure to receive vertices.
First, the back-end sets up shaders and such to prepare.
Then it calls the closure, which calls back with chunks of vertices.
The number of vertices per chunk never exceeds
<code>BACK_END_MAX_VERTEX_COUNT</code>.
Vertex positions are encoded <code>[[x0, y0], [x1, y1], ...]</code>.</p>
<p>Color space is sRGB.</p>
</div><h3 id='tymethod.tri_list_uv' class='method'><span id='tri_list_uv.v' class='invisible'><code>fn <a href='#tymethod.tri_list_uv' class='fnname'>tri_list_uv</a>&lt;F&gt;(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;mut self, <br>&nbsp;&nbsp;&nbsp;&nbsp;draw_state: &amp;<a class="struct" href="../graphics/draw_state/struct.DrawState.html" title="struct graphics::draw_state::DrawState">DrawState</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;color: &amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.array.html">[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f32.html">f32</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.array.html">; 4]</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;texture: &amp;Self::<a class="type" href="../graphics/trait.Graphics.html#associatedtype.Texture" title="type graphics::Graphics::Texture">Texture</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;f: F<br>) <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(&amp;mut <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.array.html">[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f32.html">f32</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.array.html">; 2]</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>, <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.array.html">[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f32.html">f32</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.array.html">; 2]</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>)),&nbsp;</span></code></span></h3><div class='docblock'><p>Renders list of 2d triangles using a color and a texture.</p>
<p>All vertices share the same color.</p>
<p>Tip: For objects of different colors, use grayscale textures.
The texture color gets multiplied with the color.</p>
<p>A texture coordinate is assigned per vertex (from [0, 0] to [1, 1]).</p>
<p>The back-end calls the closure with a closure to receive vertices.
First, the back-end sets up shaders and such to prepare.
Then it calls the closure, which calls back with chunks of vertices.
The number of vertices per chunk never exceeds
<code>BACK_END_MAX_VERTEX_COUNT</code>.
Vertex positions are encoded <code>[[x0, y0], [x1, y1], ...]</code>.
Texture coordinates are encoded <code>[[u0, v0], [u1, v1], ...]</code>.</p>
<p>Chunks uses separate buffer for vertex positions and texture coordinates.
Arguments are <code>|vertices: &amp;[f32], texture_coords: &amp;[f32]</code>.</p>
<p>Color space is sRGB.</p>
</div></div>
<h2 id='provided-methods' class='small-section-header'>
Provided Methods<a href='#provided-methods' class='anchor'></a>
</h2>
<div class='methods'>
<h3 id='method.rectangle' class='method'><span id='rectangle.v' class='invisible'><code>fn <a href='#method.rectangle' class='fnname'>rectangle</a>&lt;R:&nbsp;<a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a>&lt;<a class="type" href="../graphics/types/type.Rectangle.html" title="type graphics::types::Rectangle">Rectangle</a>&gt;&gt;(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;mut self, <br>&nbsp;&nbsp;&nbsp;&nbsp;r: &amp;<a class="struct" href="../graphics/rectangle/struct.Rectangle.html" title="struct graphics::rectangle::Rectangle">Rectangle</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;rectangle: R, <br>&nbsp;&nbsp;&nbsp;&nbsp;draw_state: &amp;<a class="struct" href="../graphics/draw_state/struct.DrawState.html" title="struct graphics::draw_state::DrawState">DrawState</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;transform: <a class="type" href="../graphics/math/type.Matrix2d.html" title="type graphics::math::Matrix2d">Matrix2d</a><br>)</code></span></h3><div class='docblock'><p>Draws a rectangle.</p>
<p>Can be overriden in the back-end for higher performance.</p>
<p>Instead of calling this directly, use <code>Rectangle::draw</code>.</p>
</div><h3 id='method.polygon' class='method'><span id='polygon.v' class='invisible'><code>fn <a href='#method.polygon' class='fnname'>polygon</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;mut self, <br>&nbsp;&nbsp;&nbsp;&nbsp;p: &amp;<a class="struct" href="../graphics/polygon/struct.Polygon.html" title="struct graphics::polygon::Polygon">Polygon</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;polygon: <a class="type" href="../graphics/types/type.Polygon.html" title="type graphics::types::Polygon">Polygon</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;draw_state: &amp;<a class="struct" href="../graphics/draw_state/struct.DrawState.html" title="struct graphics::draw_state::DrawState">DrawState</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;transform: <a class="type" href="../graphics/math/type.Matrix2d.html" title="type graphics::math::Matrix2d">Matrix2d</a><br>)</code></span></h3><div class='docblock'><p>Draws a polygon.</p>
<p>Can be overridden in the back-end for higher performance.</p>
<p>Instead of calling this directly, use <code>Polygon::draw</code>.</p>
</div><h3 id='method.polygon_tween_lerp' class='method'><span id='polygon_tween_lerp.v' class='invisible'><code>fn <a href='#method.polygon_tween_lerp' class='fnname'>polygon_tween_lerp</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;mut self, <br>&nbsp;&nbsp;&nbsp;&nbsp;p: &amp;<a class="struct" href="../graphics/polygon/struct.Polygon.html" title="struct graphics::polygon::Polygon">Polygon</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;polygons: <a class="type" href="../graphics/types/type.Polygons.html" title="type graphics::types::Polygons">Polygons</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;tween_factor: <a class="type" href="../graphics/math/type.Scalar.html" title="type graphics::math::Scalar">Scalar</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;draw_state: &amp;<a class="struct" href="../graphics/draw_state/struct.DrawState.html" title="struct graphics::draw_state::DrawState">DrawState</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;transform: <a class="type" href="../graphics/math/type.Matrix2d.html" title="type graphics::math::Matrix2d">Matrix2d</a><br>)</code></span></h3><div class='docblock'><p>Draws a tweened polygon using linear interpolation.</p>
<p>Can be overridden in the back-end for higher performance.</p>
<p>Instead of calling this directly, use <code>Polygon::draw_tween_lerp</code>.</p>
</div><h3 id='method.image' class='method'><span id='image.v' class='invisible'><code>fn <a href='#method.image' class='fnname'>image</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;mut self, <br>&nbsp;&nbsp;&nbsp;&nbsp;image: &amp;<a class="struct" href="../graphics/image/struct.Image.html" title="struct graphics::image::Image">Image</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;texture: &amp;Self::<a class="type" href="../graphics/trait.Graphics.html#associatedtype.Texture" title="type graphics::Graphics::Texture">Texture</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;draw_state: &amp;<a class="struct" href="../graphics/draw_state/struct.DrawState.html" title="struct graphics::draw_state::DrawState">DrawState</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;transform: <a class="type" href="../graphics/math/type.Matrix2d.html" title="type graphics::math::Matrix2d">Matrix2d</a><br>)</code></span></h3><div class='docblock'><p>Draws image.</p>
<p>Can be overridden in the back-end for higher performance.</p>
<p>Instead of calling this directly, use <code>Image::draw</code>.</p>
</div><h3 id='method.ellipse' class='method'><span id='ellipse.v' class='invisible'><code>fn <a href='#method.ellipse' class='fnname'>ellipse</a>&lt;R:&nbsp;<a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a>&lt;<a class="type" href="../graphics/types/type.Rectangle.html" title="type graphics::types::Rectangle">Rectangle</a>&gt;&gt;(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;mut self, <br>&nbsp;&nbsp;&nbsp;&nbsp;e: &amp;<a class="struct" href="../graphics/ellipse/struct.Ellipse.html" title="struct graphics::ellipse::Ellipse">Ellipse</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;rectangle: R, <br>&nbsp;&nbsp;&nbsp;&nbsp;draw_state: &amp;<a class="struct" href="../graphics/draw_state/struct.DrawState.html" title="struct graphics::draw_state::DrawState">DrawState</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;transform: <a class="type" href="../graphics/math/type.Matrix2d.html" title="type graphics::math::Matrix2d">Matrix2d</a><br>)</code></span></h3><div class='docblock'><p>Draws ellipse.</p>
<p>Can be overridden in the back-end for higher performance.</p>
<p>Instead of calling this directly, use <code>Ellipse::draw</code>.</p>
</div><h3 id='method.line' class='method'><span id='line.v' class='invisible'><code>fn <a href='#method.line' class='fnname'>line</a>&lt;L:&nbsp;<a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a>&lt;<a class="type" href="../graphics/types/type.Line.html" title="type graphics::types::Line">Line</a>&gt;&gt;(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;mut self, <br>&nbsp;&nbsp;&nbsp;&nbsp;l: &amp;<a class="struct" href="../graphics/line/struct.Line.html" title="struct graphics::line::Line">Line</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;line: L, <br>&nbsp;&nbsp;&nbsp;&nbsp;draw_state: &amp;<a class="struct" href="../graphics/draw_state/struct.DrawState.html" title="struct graphics::draw_state::DrawState">DrawState</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;transform: <a class="type" href="../graphics/math/type.Matrix2d.html" title="type graphics::math::Matrix2d">Matrix2d</a><br>)</code></span></h3><div class='docblock'><p>Draws line.</p>
<p>Can be overridden in the back-end for higher performance.</p>
<p>Instead of calling this directly, use <code>Line::draw</code>.</p>
</div><h3 id='method.circle_arc' class='method'><span id='circle_arc.v' class='invisible'><code>fn <a href='#method.circle_arc' class='fnname'>circle_arc</a>&lt;R:&nbsp;<a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a>&lt;<a class="type" href="../graphics/types/type.Rectangle.html" title="type graphics::types::Rectangle">Rectangle</a>&gt;&gt;(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;mut self, <br>&nbsp;&nbsp;&nbsp;&nbsp;c: &amp;<a class="struct" href="../graphics/circle_arc/struct.CircleArc.html" title="struct graphics::circle_arc::CircleArc">CircleArc</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;rectangle: R, <br>&nbsp;&nbsp;&nbsp;&nbsp;draw_state: &amp;<a class="struct" href="../graphics/draw_state/struct.DrawState.html" title="struct graphics::draw_state::DrawState">DrawState</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;transform: <a class="type" href="../graphics/math/type.Matrix2d.html" title="type graphics::math::Matrix2d">Matrix2d</a><br>)</code></span></h3><div class='docblock'><p>Draws circle arc.</p>
<p>Can be overriden in the back-end for higher performance.</p>
<p>Instead of calling this directly, use <code>CircleArc::draw</code>.</p>
</div><h3 id='method.deform_image' class='method'><span id='deform_image.v' class='invisible'><code>fn <a href='#method.deform_image' class='fnname'>deform_image</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;mut self, <br>&nbsp;&nbsp;&nbsp;&nbsp;d: &amp;<a class="struct" href="../graphics/deform/struct.DeformGrid.html" title="struct graphics::deform::DeformGrid">DeformGrid</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;texture: &amp;Self::<a class="type" href="../graphics/trait.Graphics.html#associatedtype.Texture" title="type graphics::Graphics::Texture">Texture</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;draw_state: &amp;<a class="struct" href="../graphics/draw_state/struct.DrawState.html" title="struct graphics::draw_state::DrawState">DrawState</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;transform: <a class="type" href="../graphics/math/type.Matrix2d.html" title="type graphics::math::Matrix2d">Matrix2d</a><br>)</code></span></h3><div class='docblock'><p>Draws deformed image.</p>
<p>Can be overriden in the back-end for higher performance.</p>
<p>Instead of calling this directly, use <code>DeformGrid::draw_image</code>.</p>
</div></div><h2 id='implementors' class='small-section-header'>Implementors<a href='#implementors' class='anchor'></a></h2><ul class='item-list' id='implementors-list'></ul><script type="text/javascript">window.inlined_types=new Set([]);</script><script type="text/javascript" async
src="../implementors/graphics/trait.Graphics.js">
</script></section><section id="search" class="content hidden"></section><section class="footer"></section><aside id="help" class="hidden"><div><h1 class="hidden">Help</h1><div class="shortcuts"><h2>Keyboard Shortcuts</h2><dl><dt><kbd>?</kbd></dt><dd>Show this help dialog</dd><dt><kbd>S</kbd></dt><dd>Focus the search field</dd><dt><kbd></kbd></dt><dd>Move up in search results</dd><dt><kbd></kbd></dt><dd>Move down in search results</dd><dt><kbd></kbd></dt><dd>Switch tab</dd><dt><kbd>&#9166;</kbd></dt><dd>Go to active search result</dd><dt><kbd>+</kbd></dt><dd>Expand all sections</dd><dt><kbd>-</kbd></dt><dd>Collapse all sections</dd></dl></div><div class="infos"><h2>Search Tricks</h2><p>Prefix searches with a type followed by a colon (e.g. <code>fn:</code>) to restrict the search to a given type.</p><p>Accepted types are: <code>fn</code>, <code>mod</code>, <code>struct</code>, <code>enum</code>, <code>trait</code>, <code>type</code>, <code>macro</code>, and <code>const</code>.</p><p>Search functions by type signature (e.g. <code>vec -> usize</code> or <code>* -> vec</code>)</p><p>Search multiple things at once by splitting your query with comma (e.g. <code>str,u8</code> or <code>String,struct:Vec,test</code>)</p></div></div></aside><script>window.rootPath = "../";window.currentCrate = "graphics";</script><script src="../aliases.js"></script><script src="../main.js"></script><script defer src="../search-index.js"></script></body></html>