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§
Required Methods§
Sourcefn new(config: Self::Config) -> Result<Self, Self::Error>where
Self: Sized,
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.
Sourcefn init(
&mut self,
window: Arc<Window>,
event_loop: &ActiveEventLoop,
) -> Result<(), Self::Error>
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.
Sourcefn render(
&mut self,
window: Arc<Window>,
event_loop: &ActiveEventLoop,
scene: &Self::Scene,
bg_color: Color,
) -> Result<(), Self::Error>
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.
Sourcefn resize(
&mut self,
window: Arc<Window>,
event_loop: &ActiveEventLoop,
size: Vector2<u32>,
) -> Result<(), Self::Error>
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.
Sourcefn uninit(
&mut self,
window: Arc<Window>,
event_loop: &ActiveEventLoop,
) -> Result<(), Self::Error>
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.
Sourcefn destroy(
&mut self,
window: Arc<Window>,
event_loop: &ActiveEventLoop,
) -> Result<(), Self::Error>
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.