mirror of
https://github.com/fluencelabs/wasmer
synced 2025-04-25 10:22:19 +00:00
35 lines
9.1 KiB
HTML
35 lines
9.1 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 `rgb` crate."><meta name="keywords" content="rust, rustlang, rust-lang, rgb"><title>rgb - 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><noscript><link rel="stylesheet" href="../noscript.css"></noscript><link rel="shortcut icon" href="../favicon.ico"><style type="text/css">#crate-search{background-image:url("../down-arrow.svg");}</style></head><body class="rustdoc mod"><!--[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><a href='../rgb/index.html'><div class='logo-container'><img src='https://kornel.ski/rgb-logo.png' alt='logo'></div></a><p class='location'>Crate rgb</p><div class="sidebar-elems"><a id='all-types' href='all.html'><p>See all rgb's items</p></a><div class="block items"><ul><li><a href="#modules">Modules</a></li><li><a href="#structs">Structs</a></li><li><a href="#traits">Traits</a></li><li><a href="#types">Type Definitions</a></li></ul></div><p class='location'></p><script>window.sidebarCurrent = {name: 'rgb', ty: 'mod', relpath: '../'};</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"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"></div><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='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/rgb/lib.rs.html#1-205' title='goto source code'>[src]</a></span><span class='in-band'>Crate <a class="mod" href=''>rgb</a></span></h1><div class='docblock'><p>Basic struct for <code>RGB</code> and <code>RGBA</code> pixels. Packed, with red first, alpha last.</p>
|
||
<p>This crate is intended to be the lowest common denominator for sharing <code>RGB</code>/<code>RGBA</code> bitmaps between other crates.</p>
|
||
<p>The crate includes convenience functions for converting between the struct and bytes,
|
||
and overloaded operators that work on all channels at once.</p>
|
||
<p>This crate intentionally doesn't implement color management (due to complexity of the problem),
|
||
but the structs can be parametrized to implement this if necessary. Other colorspaces are out of scope.</p>
|
||
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
<span class="kw">let</span> <span class="ident">pixel</span> <span class="op">=</span> <span class="ident">RGB8</span> {<span class="ident">r</span>:<span class="number">0</span>, <span class="ident">g</span>:<span class="number">100</span>, <span class="ident">b</span>:<span class="number">255</span>};
|
||
|
||
<span class="kw">let</span> <span class="ident">pixel_rgba</span> <span class="op">=</span> <span class="ident">pixel</span>.<span class="ident">alpha</span>(<span class="number">255</span>);
|
||
<span class="kw">let</span> <span class="ident">pixel</span> <span class="op">=</span> <span class="ident">pixel_rgba</span>.<span class="ident">rgb</span>();
|
||
|
||
<span class="kw">let</span> <span class="ident">pixels</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[<span class="ident">pixel</span>; <span class="number">100</span>];
|
||
<span class="kw">let</span> <span class="ident">bytes</span> <span class="op">=</span> <span class="ident">pixels</span>.<span class="ident">as_bytes</span>();
|
||
|
||
<span class="kw">let</span> <span class="ident">half_bright</span> <span class="op">=</span> <span class="ident">pixel</span>.<span class="ident">map</span>(<span class="op">|</span><span class="ident">channel</span><span class="op">|</span> <span class="ident">channel</span> <span class="op">/</span> <span class="number">2</span>);
|
||
<span class="kw">let</span> <span class="ident">doubled</span> <span class="op">=</span> <span class="ident">half_bright</span> <span class="op">*</span> <span class="number">2</span>;</pre></div>
|
||
</div><h2 id='modules' class='section-header'><a href="#modules">Modules</a></h2>
|
||
<table><tr class='module-item'><td><a class="mod" href="alt/index.html" title='rgb::alt mod'>alt</a></td><td class='docblock-short'><p>BGR/BGRA alernative layouts & grayscale</p>
|
||
</td></tr></table><h2 id='structs' class='section-header'><a href="#structs">Structs</a></h2>
|
||
<table><tr class='module-item'><td><a class="struct" href="struct.RGB.html" title='rgb::RGB struct'>RGB</a></td><td class='docblock-short'><p>The RGB pixel</p>
|
||
</td></tr><tr class='module-item'><td><a class="struct" href="struct.RGBA.html" title='rgb::RGBA struct'>RGBA</a></td><td class='docblock-short'><p>The RGBA pixel</p>
|
||
</td></tr></table><h2 id='traits' class='section-header'><a href="#traits">Traits</a></h2>
|
||
<table><tr class='module-item'><td><a class="trait" href="trait.AsPixels.html" title='rgb::AsPixels trait'>AsPixels</a></td><td class='docblock-short'><p>Casts a slice of bytes into a slice of pixels, e.g. <code>[u8]</code> to <code>[RGB8]</code>.</p>
|
||
</td></tr><tr class='module-item'><td><a class="trait" href="trait.ComponentBytes.html" title='rgb::ComponentBytes trait'>ComponentBytes</a></td><td class='docblock-short'><p>Casting a slice of <code>RGB/A</code> values to a slice of <code>u8</code></p>
|
||
</td></tr><tr class='module-item'><td><a class="trait" href="trait.ComponentMap.html" title='rgb::ComponentMap trait'>ComponentMap</a></td><td class='docblock-short'><p>Applying operation to every component</p>
|
||
</td></tr><tr class='module-item'><td><a class="trait" href="trait.ComponentSlice.html" title='rgb::ComponentSlice trait'>ComponentSlice</a></td><td class='docblock-short'><p>Casting the struct to slices of its components</p>
|
||
</td></tr><tr class='module-item'><td><a class="trait" href="trait.FromSlice.html" title='rgb::FromSlice trait'>FromSlice</a></td><td class='docblock-short'><p>Cast a slice of component values (bytes) as a slice of RGB/RGBA pixels</p>
|
||
</td></tr></table><h2 id='types' class='section-header'><a href="#types">Type Definitions</a></h2>
|
||
<table><tr class='module-item'><td><a class="type" href="type.RGB8.html" title='rgb::RGB8 type'>RGB8</a></td><td class='docblock-short'><p>8-bit RGB</p>
|
||
</td></tr><tr class='module-item'><td><a class="type" href="type.RGB16.html" title='rgb::RGB16 type'>RGB16</a></td><td class='docblock-short'><p>16-bit RGB in machine's native endian</p>
|
||
</td></tr><tr class='module-item'><td><a class="type" href="type.RGBA8.html" title='rgb::RGBA8 type'>RGBA8</a></td><td class='docblock-short'><p>8-bit RGBA, alpha is last. 0 = transparent, 255 = opaque.</p>
|
||
</td></tr><tr class='module-item'><td><a class="type" href="type.RGBA16.html" title='rgb::RGBA16 type'>RGBA16</a></td><td class='docblock-short'><p>16-bit RGB in machine's native endian. 0 = transparent, 65535 = opaque.</p>
|
||
</td></tr></table></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 = "rgb";</script><script src="../aliases.js"></script><script src="../main.js"></script><script defer src="../search-index.js"></script></body></html> |