mirror of
https://github.com/neogeek23/rusty_snek_gaem.git
synced 2026-02-04 19:18:44 +00:00
124 lines
36 KiB
HTML
124 lines
36 KiB
HTML
<!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">☰</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'>−</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>(&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>(&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><F>(&mut self, draw_state: &<a class="struct" href="../graphics/draw_state/struct.DrawState.html" title="struct graphics::draw_state::DrawState">DrawState</a>, color: &<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> <span class="where">where<br> 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>(&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">&[</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><F>(<br> &mut self, <br> draw_state: &<a class="struct" href="../graphics/draw_state/struct.DrawState.html" title="struct graphics::draw_state::DrawState">DrawState</a>, <br> color: &<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> texture: &Self::<a class="type" href="../graphics/trait.Graphics.html#associatedtype.Texture" title="type graphics::Graphics::Texture">Texture</a>, <br> f: F<br> )<br> <span class="where">where<br> 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>(&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">&[</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">&[</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><R: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><<a class="type" href="../graphics/types/type.Rectangle.html" title="type graphics::types::Rectangle">Rectangle</a>>>(<br> &mut self, <br> r: &<a class="struct" href="../graphics/rectangle/struct.Rectangle.html" title="struct graphics::rectangle::Rectangle">Rectangle</a>, <br> rectangle: R, <br> draw_state: &<a class="struct" href="../graphics/draw_state/struct.DrawState.html" title="struct graphics::draw_state::DrawState">DrawState</a>, <br> transform: <a class="type" href="../graphics/math/type.Matrix2d.html" title="type graphics::math::Matrix2d">Matrix2d</a><br> ) { ... }
|
||
<div class='item-spacer'></div> fn <a href='#method.polygon' class='fnname'>polygon</a>(<br> &mut self, <br> p: &<a class="struct" href="../graphics/polygon/struct.Polygon.html" title="struct graphics::polygon::Polygon">Polygon</a>, <br> polygon: <a class="type" href="../graphics/types/type.Polygon.html" title="type graphics::types::Polygon">Polygon</a>, <br> draw_state: &<a class="struct" href="../graphics/draw_state/struct.DrawState.html" title="struct graphics::draw_state::DrawState">DrawState</a>, <br> transform: <a class="type" href="../graphics/math/type.Matrix2d.html" title="type graphics::math::Matrix2d">Matrix2d</a><br> ) { ... }
|
||
<div class='item-spacer'></div> fn <a href='#method.polygon_tween_lerp' class='fnname'>polygon_tween_lerp</a>(<br> &mut self, <br> p: &<a class="struct" href="../graphics/polygon/struct.Polygon.html" title="struct graphics::polygon::Polygon">Polygon</a>, <br> polygons: <a class="type" href="../graphics/types/type.Polygons.html" title="type graphics::types::Polygons">Polygons</a>, <br> tween_factor: <a class="type" href="../graphics/math/type.Scalar.html" title="type graphics::math::Scalar">Scalar</a>, <br> draw_state: &<a class="struct" href="../graphics/draw_state/struct.DrawState.html" title="struct graphics::draw_state::DrawState">DrawState</a>, <br> transform: <a class="type" href="../graphics/math/type.Matrix2d.html" title="type graphics::math::Matrix2d">Matrix2d</a><br> ) { ... }
|
||
<div class='item-spacer'></div> fn <a href='#method.image' class='fnname'>image</a>(<br> &mut self, <br> image: &<a class="struct" href="../graphics/image/struct.Image.html" title="struct graphics::image::Image">Image</a>, <br> texture: &Self::<a class="type" href="../graphics/trait.Graphics.html#associatedtype.Texture" title="type graphics::Graphics::Texture">Texture</a>, <br> draw_state: &<a class="struct" href="../graphics/draw_state/struct.DrawState.html" title="struct graphics::draw_state::DrawState">DrawState</a>, <br> transform: <a class="type" href="../graphics/math/type.Matrix2d.html" title="type graphics::math::Matrix2d">Matrix2d</a><br> ) { ... }
|
||
<div class='item-spacer'></div> fn <a href='#method.ellipse' class='fnname'>ellipse</a><R: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><<a class="type" href="../graphics/types/type.Rectangle.html" title="type graphics::types::Rectangle">Rectangle</a>>>(<br> &mut self, <br> e: &<a class="struct" href="../graphics/ellipse/struct.Ellipse.html" title="struct graphics::ellipse::Ellipse">Ellipse</a>, <br> rectangle: R, <br> draw_state: &<a class="struct" href="../graphics/draw_state/struct.DrawState.html" title="struct graphics::draw_state::DrawState">DrawState</a>, <br> transform: <a class="type" href="../graphics/math/type.Matrix2d.html" title="type graphics::math::Matrix2d">Matrix2d</a><br> ) { ... }
|
||
<div class='item-spacer'></div> fn <a href='#method.line' class='fnname'>line</a><L: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><<a class="type" href="../graphics/types/type.Line.html" title="type graphics::types::Line">Line</a>>>(<br> &mut self, <br> l: &<a class="struct" href="../graphics/line/struct.Line.html" title="struct graphics::line::Line">Line</a>, <br> line: L, <br> draw_state: &<a class="struct" href="../graphics/draw_state/struct.DrawState.html" title="struct graphics::draw_state::DrawState">DrawState</a>, <br> transform: <a class="type" href="../graphics/math/type.Matrix2d.html" title="type graphics::math::Matrix2d">Matrix2d</a><br> ) { ... }
|
||
<div class='item-spacer'></div> fn <a href='#method.circle_arc' class='fnname'>circle_arc</a><R: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><<a class="type" href="../graphics/types/type.Rectangle.html" title="type graphics::types::Rectangle">Rectangle</a>>>(<br> &mut self, <br> c: &<a class="struct" href="../graphics/circle_arc/struct.CircleArc.html" title="struct graphics::circle_arc::CircleArc">CircleArc</a>, <br> rectangle: R, <br> draw_state: &<a class="struct" href="../graphics/draw_state/struct.DrawState.html" title="struct graphics::draw_state::DrawState">DrawState</a>, <br> transform: <a class="type" href="../graphics/math/type.Matrix2d.html" title="type graphics::math::Matrix2d">Matrix2d</a><br> ) { ... }
|
||
<div class='item-spacer'></div> fn <a href='#method.deform_image' class='fnname'>deform_image</a>(<br> &mut self, <br> d: &<a class="struct" href="../graphics/deform/struct.DeformGrid.html" title="struct graphics::deform::DeformGrid">DeformGrid</a>, <br> texture: &Self::<a class="type" href="../graphics/trait.Graphics.html#associatedtype.Texture" title="type graphics::Graphics::Texture">Texture</a>, <br> draw_state: &<a class="struct" href="../graphics/draw_state/struct.DrawState.html" title="struct graphics::draw_state::DrawState">DrawState</a>, <br> transform: <a class="type" href="../graphics/math/type.Matrix2d.html" title="type graphics::math::Matrix2d">Matrix2d</a><br> ) { ... }
|
||
}</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"><</span><span class="ident">G</span>: <span class="ident">Graphics</span><span class="op">></span>(<span class="ident">c</span>: <span class="kw-2">&</span><span class="ident">Context</span>, <span class="ident">g</span>: <span class="kw-2">&</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"><</span><span class="ident">G</span>, <span class="ident">T</span><span class="op">></span>(<span class="ident">c</span>: <span class="kw-2">&</span><span class="ident">Context</span>, <span class="ident">g</span>: <span class="kw-2">&</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"><</span><span class="ident">Texture</span> <span class="op">=</span> <span class="ident">T</span><span class="op">></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>(&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>(&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><F>(&mut self, draw_state: &<a class="struct" href="../graphics/draw_state/struct.DrawState.html" title="struct graphics::draw_state::DrawState">DrawState</a>, color: &<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> 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>(&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">&[</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></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><F>(<br> &mut self, <br> draw_state: &<a class="struct" href="../graphics/draw_state/struct.DrawState.html" title="struct graphics::draw_state::DrawState">DrawState</a>, <br> color: &<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> texture: &Self::<a class="type" href="../graphics/trait.Graphics.html#associatedtype.Texture" title="type graphics::Graphics::Texture">Texture</a>, <br> f: F<br>) <span class="where fmt-newline">where<br> 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>(&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">&[</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">&[</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></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: &[f32], texture_coords: &[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><R: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><<a class="type" href="../graphics/types/type.Rectangle.html" title="type graphics::types::Rectangle">Rectangle</a>>>(<br> &mut self, <br> r: &<a class="struct" href="../graphics/rectangle/struct.Rectangle.html" title="struct graphics::rectangle::Rectangle">Rectangle</a>, <br> rectangle: R, <br> draw_state: &<a class="struct" href="../graphics/draw_state/struct.DrawState.html" title="struct graphics::draw_state::DrawState">DrawState</a>, <br> 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> &mut self, <br> p: &<a class="struct" href="../graphics/polygon/struct.Polygon.html" title="struct graphics::polygon::Polygon">Polygon</a>, <br> polygon: <a class="type" href="../graphics/types/type.Polygon.html" title="type graphics::types::Polygon">Polygon</a>, <br> draw_state: &<a class="struct" href="../graphics/draw_state/struct.DrawState.html" title="struct graphics::draw_state::DrawState">DrawState</a>, <br> 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> &mut self, <br> p: &<a class="struct" href="../graphics/polygon/struct.Polygon.html" title="struct graphics::polygon::Polygon">Polygon</a>, <br> polygons: <a class="type" href="../graphics/types/type.Polygons.html" title="type graphics::types::Polygons">Polygons</a>, <br> tween_factor: <a class="type" href="../graphics/math/type.Scalar.html" title="type graphics::math::Scalar">Scalar</a>, <br> draw_state: &<a class="struct" href="../graphics/draw_state/struct.DrawState.html" title="struct graphics::draw_state::DrawState">DrawState</a>, <br> 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> &mut self, <br> image: &<a class="struct" href="../graphics/image/struct.Image.html" title="struct graphics::image::Image">Image</a>, <br> texture: &Self::<a class="type" href="../graphics/trait.Graphics.html#associatedtype.Texture" title="type graphics::Graphics::Texture">Texture</a>, <br> draw_state: &<a class="struct" href="../graphics/draw_state/struct.DrawState.html" title="struct graphics::draw_state::DrawState">DrawState</a>, <br> 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><R: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><<a class="type" href="../graphics/types/type.Rectangle.html" title="type graphics::types::Rectangle">Rectangle</a>>>(<br> &mut self, <br> e: &<a class="struct" href="../graphics/ellipse/struct.Ellipse.html" title="struct graphics::ellipse::Ellipse">Ellipse</a>, <br> rectangle: R, <br> draw_state: &<a class="struct" href="../graphics/draw_state/struct.DrawState.html" title="struct graphics::draw_state::DrawState">DrawState</a>, <br> 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><L: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><<a class="type" href="../graphics/types/type.Line.html" title="type graphics::types::Line">Line</a>>>(<br> &mut self, <br> l: &<a class="struct" href="../graphics/line/struct.Line.html" title="struct graphics::line::Line">Line</a>, <br> line: L, <br> draw_state: &<a class="struct" href="../graphics/draw_state/struct.DrawState.html" title="struct graphics::draw_state::DrawState">DrawState</a>, <br> 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><R: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><<a class="type" href="../graphics/types/type.Rectangle.html" title="type graphics::types::Rectangle">Rectangle</a>>>(<br> &mut self, <br> c: &<a class="struct" href="../graphics/circle_arc/struct.CircleArc.html" title="struct graphics::circle_arc::CircleArc">CircleArc</a>, <br> rectangle: R, <br> draw_state: &<a class="struct" href="../graphics/draw_state/struct.DrawState.html" title="struct graphics::draw_state::DrawState">DrawState</a>, <br> 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> &mut self, <br> d: &<a class="struct" href="../graphics/deform/struct.DeformGrid.html" title="struct graphics::deform::DeformGrid">DeformGrid</a>, <br> texture: &Self::<a class="type" href="../graphics/trait.Graphics.html#associatedtype.Texture" title="type graphics::Graphics::Texture">Texture</a>, <br> draw_state: &<a class="struct" href="../graphics/draw_state/struct.DrawState.html" title="struct graphics::draw_state::DrawState">DrawState</a>, <br> 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>⏎</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> |