VectorGraphicsInterface

Trait VectorGraphicsInterface 

Source
pub trait VectorGraphicsInterface: Debug + 'static {
    type Error: Error;
    type Scene: Scene;
    type Config: Debug + Default + Clone;

    // Required methods
    fn new(config: Self::Config) -> Result<Self, Self::Error>
       where Self: Sized;
    fn init(
        &mut self,
        window: Arc<Window>,
        event_loop: &ActiveEventLoop,
    ) -> Result<(), Self::Error>;
    fn render(
        &mut self,
        window: Arc<Window>,
        event_loop: &ActiveEventLoop,
        scene: &Self::Scene,
        bg_color: Color,
    ) -> Result<(), Self::Error>;
    fn resize(
        &mut self,
        window: Arc<Window>,
        event_loop: &ActiveEventLoop,
        size: Vector2<u32>,
    ) -> Result<(), Self::Error>;
    fn uninit(
        &mut self,
        window: Arc<Window>,
        event_loop: &ActiveEventLoop,
    ) -> Result<(), Self::Error>;
    fn destroy(
        &mut self,
        window: Arc<Window>,
        event_loop: &ActiveEventLoop,
    ) -> Result<(), Self::Error>;
}
Expand description

A trait describing ways to render vector graphics.

This is a universal interface for 2D vector graphics rendering.

Required Associated Types§

Source

type Error: Error

The error used by most graphics operations.

Source

type Scene: Scene

A direct interface for drawing vector graphics using this interface.

Source

type Config: Debug + Default + Clone

A configuration struct for initializing the interface.

Required Methods§

Source

fn new(config: Self::Config) -> Result<Self, Self::Error>
where Self: Sized,

Creates a new vector graphics interface using the given configuration.

Returns an Err if the interface could not be created.

Source

fn init( &mut self, window: Arc<Window>, event_loop: &ActiveEventLoop, ) -> Result<(), Self::Error>

Initializes the interface.

This will be called on winit::event::Event::Resumed to initialize the graphics interface.

Returns an Err if the interface could not be initialized.

Source

fn render( &mut self, window: Arc<Window>, event_loop: &ActiveEventLoop, scene: &Self::Scene, bg_color: Color, ) -> Result<(), Self::Error>

Renders the scene to the window.

This method should render the scene on a window surface and present the surface too.

Returns an Err if the scene could not be rendered.

Source

fn resize( &mut self, window: Arc<Window>, event_loop: &ActiveEventLoop, size: Vector2<u32>, ) -> Result<(), Self::Error>

Resizes the window.

This method should resize the window surface to the given size.

NOTE: Do not resize the window itself. This is already done automatically.

Returns an Err if the window could not be resized.

Source

fn uninit( &mut self, window: Arc<Window>, event_loop: &ActiveEventLoop, ) -> Result<(), Self::Error>

Uninitializes the interface.

This will be called on winit::event::Event::Suspended to uninitialize the graphics interface.

Returns an Err if the interface could not be uninitialized.

Source

fn destroy( &mut self, window: Arc<Window>, event_loop: &ActiveEventLoop, ) -> Result<(), Self::Error>

Destroys the interface.

This will be called on winit::event::WindowEvent::Destroyed to destroy the graphics interface.

Returns an Err if the interface could not be destroyed.

Implementors§