[][src]Crate canvas

Canvas

An image canvas compatible with transmuting its byte content.

Usage

use canvas::Canvas;
let mut canvas = Canvas::with_width_and_height(400, 400);

// Draw a bright red line.
for i in 0..400 {
    // Assign color as u8-RGBA
    canvas[(i, i)] = [0xFF, 0x00, 0x00, 0xFF];
}

// Encode to network endian.
let mut encoded = canvas.transmute::<u32>();
encoded
    .as_mut_slice()
    .iter_mut()
    .for_each(|p| *p = p.to_be());

// Send the raw bytes
send_over_network(encoded.as_bytes());

Modules

pixels

Constants for predefined pixel types.

Structs

Canvas

A 2d matrix of pixels.

CanvasReuseError

Error representation for a failed buffer reuse for a canvas.

Layout

Describes the memory region used for the image.

Pixel

Marker struct to denote a pixel type.

Rec

A reinterpretable vector for an array of pixels.

ReuseError

Error representation for a failed buffer reuse.

Traits

AsPixel

Describes a type which can represent a Pixel.