Function pixels_graphics_lib::setup

source ·
pub fn setup(
    canvas_size: (usize, usize),
    options: &Options,
    title: &str,
    event_loop: &EventLoop<()>
) -> Result<(Window, Pixels), GraphicsError>
Expand description

Creates the window and pixels wrapper

The inner size mentioned in the arguments refers to the size of the area available to draw in, it doesn’t include the window frame, etc

This uses logical pixels, where on a low DPI screen each library pixel is one display pixel but on higher DPI screens (and if scale != None) then a library pixel will be represented by multiple display pixels

Arguments

  • canvas_size - Inner width and height of window in logical pixels
  • scale - Type of scaling the window should use, see WindowScaling
  • title - Title for window
  • event_loop - Provided by EventLoop::new(), this allows the window to receive events from the OS

Example

This creates a 160x160 window:

let (mut window, graphics) = setup(160, 160, "Example", true, &event_loop)?;

Returns

A result with a pair of Window and PixelsWrapper

Errors

  • WindowInit - If the window can not be created