### Define NullImageRenderer Struct Source: https://docs.rs/anyrender/0.8.0/anyrender/struct.NullImageRenderer.html This struct serves as a no-operation implementation for image rendering. It requires no setup and can be used directly. ```rust pub struct NullImageRenderer; ``` -------------------------------- ### Blanket Implementations for RenderCommand Source: https://docs.rs/anyrender/0.8.0/anyrender/recording/enum.RenderCommand.html Details on blanket implementations for RenderCommand, such as Any, Borrow, CloneToUninit, etc. ```APIDOC ### Blanket Implementations #### impl Any for T where T: 'static + ?Sized, #### fn type_id(&self) -> TypeId Gets the `TypeId` of `self`. #### impl Borrow for T where T: ?Sized, #### fn borrow(&self) -> &T Immutably borrows from an owned value. #### impl BorrowMut for T where T: ?Sized, #### fn borrow_mut(&mut self) -> &mut T Mutably borrows from an owned value. #### impl CloneToUninit for T where T: Clone, #### unsafe fn clone_to_uninit(&self, dest: *mut u8) Performs copy-assignment from `self` to `dest`. #### impl From for T #### fn from(t: T) -> T Returns the argument unchanged. #### impl Into for T where U: From, #### fn into(self) -> U Calls `U::from(self)`. #### impl ToOwned for T where T: Clone, #### type Owned = T #### fn to_owned(&self) -> T Creates owned data from borrowed data, usually by cloning. #### fn clone_into(&self, target: &mut T) Uses borrowed data to replace owned data, usually by cloning. #### impl TryFrom for T where U: Into, #### type Error = Infallible #### fn try_from(value: U) -> Result>::Error> Performs the conversion. #### impl TryInto for T where U: TryFrom, #### type Error = >::Error ``` -------------------------------- ### Implement PartialEq for ClipCommand Source: https://docs.rs/anyrender/0.8.0/anyrender/recording/struct.ClipCommand.html Allows comparison of ClipCommand instances for equality. The eq() method tests for equality, and ne() tests for inequality. ```rust fn eq(&self, other: &ClipCommand) -> bool ``` ```rust fn ne(&self, other: &Rhs) -> bool ``` -------------------------------- ### NullWindowRenderer::new() Source: https://docs.rs/anyrender/0.8.0/anyrender/struct.NullWindowRenderer.html Constructor for creating a new instance of NullWindowRenderer. ```APIDOC ## impl NullWindowRenderer ### pub fn new() -> Self Creates a new instance of `NullWindowRenderer`. ``` -------------------------------- ### Implement CloneToUninit for T (Nightly) Source: https://docs.rs/anyrender/0.8.0/anyrender/recording/struct.LayerCommand.html Nightly-only experimental API for performing copy-assignment to uninitialized memory. ```rust unsafe fn clone_to_uninit(&self, dest: *mut u8) ``` -------------------------------- ### Implement Clone for ClipCommand Source: https://docs.rs/anyrender/0.8.0/anyrender/recording/struct.ClipCommand.html Provides methods for cloning ClipCommand instances. Use clone() for a duplicate and clone_from() for copy-assignment. ```rust fn clone(&self) -> ClipCommand ``` ```rust fn clone_from(&mut self, source: &Self) ``` -------------------------------- ### Implement From for T Source: https://docs.rs/anyrender/0.8.0/anyrender/recording/struct.LayerCommand.html A simple conversion that returns the argument unchanged. ```rust fn from(t: T) -> T ``` -------------------------------- ### Copy Implementation for NullWindowRenderer Source: https://docs.rs/anyrender/0.8.0/anyrender/struct.NullWindowRenderer.html Indicates that NullWindowRenderer can be copied. ```APIDOC ### impl Copy for NullWindowRenderer ``` -------------------------------- ### Implement Any for T Source: https://docs.rs/anyrender/0.8.0/anyrender/recording/struct.LayerCommand.html Provides runtime type information for any type T that is 'static. ```rust fn type_id(&self) -> TypeId ``` -------------------------------- ### WindowRenderer Trait Methods Source: https://docs.rs/anyrender/0.8.0/anyrender/trait.WindowRenderer.html Detailed documentation for the methods required to implement the WindowRenderer trait. ```APIDOC ## Trait: WindowRenderer ### Description Abstraction for rendering a scene to a window. Note: This trait is not dyn compatible. ### Associated Types - **ScenePainter<'a>** (PaintScene) - The painter type associated with the renderer. ### Methods - **resume(&mut self, window: Arc, width: u32, height: u32)**: Resumes the renderer with the provided window handle and dimensions. - **suspend(&mut self)**: Suspends the renderer. - **is_active(&self) -> bool**: Returns true if the renderer is currently active. - **set_size(&mut self, width: u32, height: u32)**: Updates the renderer dimensions. - **render)>(&mut self, draw_fn: F)**: Executes the provided draw function using the scene painter. ``` -------------------------------- ### NullScenePainter Methods Source: https://docs.rs/anyrender/0.8.0/anyrender/struct.NullScenePainter.html Provides details on the constructor and methods available for the NullScenePainter. ```APIDOC ## Implementations for NullScenePainter ### `new()` Creates a new instance of `NullScenePainter`. ```rust pub fn new() -> Self ``` ### `PaintScene` Trait Methods All methods from the `PaintScene` trait are implemented as no-operations. - **`reset()`**: Removes all content from the scene (no-op). - **`push_layer(_blend, _alpha, _transform, _clip)`**: Pushes a new layer (no-op). - **`push_clip_layer(_transform, _clip)`**: Pushes a new clip layer (no-op). - **`pop_layer()`**: Pops the current layer (no-op). - **`stroke(_style, _transform, _brush, _brush_transform, _shape)`**: Strokes a shape (no-op). - **`fill(_style, _transform, _brush, _brush_transform, _shape)`**: Fills a shape (no-op). - **`draw_glyphs(...)`**: Draws a run of glyphs (no-op). - **`draw_box_shadow(...)`**: Draws a box shadow (no-op). - **`append_scene(scene, scene_transform)`**: Appends a recorded scene fragment (no-op). - **`draw_image(image, transform)`**: Draws an image (no-op). ``` -------------------------------- ### Implement Clone for StrokeCommand Source: https://docs.rs/anyrender/0.8.0/anyrender/recording/struct.StrokeCommand.html Provides the `clone` and `clone_from` methods for StrokeCommand, allowing for duplication of stroke command data. Requires the Image type to be Clone. ```rust fn clone(&self) -> StrokeCommand Returns a duplicate of the value. Read more ``` ```rust fn clone_from(&mut self, source: &Self) Performs copy-assignment from `source`. Read more ``` -------------------------------- ### reset Method Source: https://docs.rs/anyrender/0.8.0/anyrender/trait.PaintScene.html Removes all content from the scene. Call this to clear the scene before drawing new content. ```rust fn reset(&mut self); ``` -------------------------------- ### Implement PartialEq for StrokeCommand Source: https://docs.rs/anyrender/0.8.0/anyrender/recording/struct.StrokeCommand.html Allows for equality comparison between StrokeCommand instances. Requires the Image type to implement PartialEq. ```rust fn eq(&self, other: &StrokeCommand) -> bool Tests for `self` and `other` values to be equal, and is used by `==`. ``` ```rust fn ne(&self, other: &Rhs) -> bool Tests for `!=`. The default implementation is almost always sufficient, and should not be overridden without very good reason. ``` -------------------------------- ### Clone Implementation for NullWindowRenderer Source: https://docs.rs/anyrender/0.8.0/anyrender/struct.NullWindowRenderer.html Provides methods for cloning NullWindowRenderer instances. ```APIDOC ### impl Clone for NullWindowRenderer #### fn clone(&self) -> NullWindowRenderer Returns a duplicate of the value. #### fn clone_from(&mut self, source: &Self) Performs copy-assignment from `source`. ``` -------------------------------- ### Implement CloneToUninit trait (Nightly) Source: https://docs.rs/anyrender/0.8.0/anyrender/struct.NullImageRenderer.html This experimental nightly-only API allows cloning a value into uninitialized memory. It requires the type to implement Clone. Use with caution. ```rust unsafe fn clone_to_uninit(&self, dest: *mut u8) { let src = self as *const _; core::ptr::copy_nonoverlapping(src as *const u8, dest, core::mem::size_of::()); } } ``` -------------------------------- ### Render Scene to Buffer Source: https://docs.rs/anyrender/0.8.0/anyrender/fn.render_to_buffer.html Use this function to draw a scene to a buffer using an `ImageRenderer`. It takes a drawing function, width, and height as input. ```rust pub fn render_to_buffer)>(draw_fn: F, width: u32, height: u32) -> Vec ⓘ ``` -------------------------------- ### Ownership and Cloning Source: https://docs.rs/anyrender/0.8.0/anyrender/recording/struct.Scene.html Methods for managing data ownership and creating owned copies from borrowed data. ```APIDOC ## Owned Type ### Description The resulting type after obtaining ownership. ### Type Alias `Owned = T` ``` ```APIDOC ## `to_owned` Method ### Description Creates owned data from borrowed data, usually by cloning. ### Method `to_owned(&self) -> T` ``` ```APIDOC ## `clone_into` Method ### Description Uses borrowed data to replace owned data, usually by cloning. ### Method `clone_into(&self, target: &mut T)` ``` -------------------------------- ### fill Method Source: https://docs.rs/anyrender/0.8.0/anyrender/trait.PaintScene.html Fills a shape using the specified style and brush. Requires a shape, fill style, and brush definition. ```rust fn fill<'a>( &mut self, style: Fill, transform: Affine, brush: impl Into>, brush_transform: Option, shape: &impl Shape, ); ``` -------------------------------- ### PartialEq Implementation for StrokeCommand Source: https://docs.rs/anyrender/0.8.0/anyrender/recording/struct.StrokeCommand.html Provides functionality to compare StrokeCommand instances for equality. ```APIDOC ### impl PartialEq for StrokeCommand #### fn eq(&self, other: &StrokeCommand) -> bool Tests for `self` and `other` values to be equal, and is used by `==`. #### fn ne(&self, other: &Rhs) -> bool Tests for `!=`. ``` -------------------------------- ### StructuralPartialEq Implementation for StrokeCommand Source: https://docs.rs/anyrender/0.8.0/anyrender/recording/struct.StrokeCommand.html Provides structural partial equality comparison for StrokeCommand instances. ```APIDOC ### impl StructuralPartialEq for StrokeCommand ``` -------------------------------- ### TryInto Conversion Function Source: https://docs.rs/anyrender/0.8.0/anyrender/struct.NullScenePainter.html Provides a function to attempt conversion between types, returning a Result. ```APIDOC ## fn try_into(self) -> Result>::Error> ### Description Performs the conversion. ### Source ```rust fn try_into(self) -> Result>::Error>; ``` ``` -------------------------------- ### PaintScene Trait Methods Source: https://docs.rs/anyrender/0.8.0/anyrender/trait.PaintScene.html Overview of the required and provided methods for the PaintScene trait used to construct 2D scenes. ```APIDOC ## PaintScene Trait ### Description Abstraction for drawing a 2D scene. This trait is not dyn compatible. ### Required Methods - **reset()**: Removes all content from the scene. - **push_layer(blend, alpha, transform, clip)**: Pushes a new layer clipped by the specified shape and composed with previous layers. - **push_clip_layer(transform, clip)**: Pushes a new clip layer clipped by the specified shape. - **pop_layer()**: Pops the current layer. - **stroke(style, transform, brush, brush_transform, shape)**: Strokes a shape using the specified style and brush. - **fill(style, transform, brush, brush_transform, shape)**: Fills a shape using the specified style and brush. - **draw_glyphs(font, font_size, hint, normalized_coords, style, brush, brush_alpha, transform, glyph_transform, glyphs)**: Draws a run of glyphs. - **draw_box_shadow(transform, rect, brush, radius, std_dev)**: Draw a rounded rectangle blurred with a gaussian filter. ### Provided Methods - **append_scene(scene, scene_transform)**: Append a recorded Scene Fragment to the current scene. - **draw_image(image, transform)**: Utility method to draw an image at its natural size. ``` -------------------------------- ### Clone Implementation for CustomPaint Source: https://docs.rs/anyrender/0.8.0/anyrender/types/struct.CustomPaint.html Provides methods to duplicate CustomPaint instances. ```rust fn clone(&self) -> CustomPaint ``` ```rust fn clone_from(&mut self, source: &Self) ``` -------------------------------- ### Implement PartialEq for LayerCommand Source: https://docs.rs/anyrender/0.8.0/anyrender/recording/struct.LayerCommand.html Allows for equality comparison between LayerCommand instances. ```rust fn eq(&self, other: &LayerCommand) -> bool ``` ```rust fn ne(&self, other: &Rhs) -> bool ``` -------------------------------- ### StructuralPartialEq Trait Implementation for RenderCommand Source: https://docs.rs/anyrender/0.8.0/anyrender/recording/enum.RenderCommand.html Implementation of the StructuralPartialEq trait for RenderCommand. ```APIDOC ### impl StructuralPartialEq for RenderCommand ``` -------------------------------- ### Auto Trait Implementations for RenderCommand Source: https://docs.rs/anyrender/0.8.0/anyrender/recording/enum.RenderCommand.html Details on auto-implemented traits for RenderCommand, including Send, Sync, Unpin, etc. ```APIDOC ### Auto Trait Implementations #### impl Freeze for RenderCommand where Font: Freeze, Image: Freeze, #### impl RefUnwindSafe for RenderCommand where Font: RefUnwindSafe, Image: RefUnwindSafe, #### impl Send for RenderCommand where Font: Send, Image: Send, #### impl Sync for RenderCommand where Font: Sync, Image: Sync, #### impl Unpin for RenderCommand where Font: Unpin, Image: Unpin, #### impl UnsafeUnpin for RenderCommand where Font: UnsafeUnpin, Image: UnsafeUnpin, #### impl UnwindSafe for RenderCommand where Font: UnwindSafe, Image: UnwindSafe, ``` -------------------------------- ### PartialEq Trait Implementation for RenderCommand Source: https://docs.rs/anyrender/0.8.0/anyrender/recording/enum.RenderCommand.html Implementation of the PartialEq trait for RenderCommand, allowing for equality comparisons. ```APIDOC ### impl PartialEq for RenderCommand #### fn eq(&self, other: &RenderCommand) -> bool Tests for `self` and `other` values to be equal. #### fn ne(&self, other: &Rhs) -> bool Tests for `!=`. ``` -------------------------------- ### Perform Conversion Source: https://docs.rs/anyrender/0.8.0/anyrender/struct.NullScenePainter.html Executes the conversion and returns a Result containing the target type or the conversion error. ```rust fn try_into(self) -> Result>::Error> ``` -------------------------------- ### Default Implementation for NullWindowRenderer Source: https://docs.rs/anyrender/0.8.0/anyrender/struct.NullWindowRenderer.html Provides a default value for NullWindowRenderer. ```APIDOC ### impl Default for NullWindowRenderer #### fn default() -> NullWindowRenderer Returns the “default value” for a type. ``` -------------------------------- ### draw_box_shadow Method Source: https://docs.rs/anyrender/0.8.0/anyrender/trait.PaintScene.html Draws a rounded rectangle with a Gaussian blur effect. Requires transform, rectangle bounds, color, radius, and standard deviation for the blur. ```rust fn draw_box_shadow( &mut self, transform: Affine, rect: Rect, brush: Color, radius: f64, std_dev: f64, ); ``` -------------------------------- ### PaintScene Trait Implementations for Scene Source: https://docs.rs/anyrender/0.8.0/anyrender/recording/struct.Scene.html Methods for painting and manipulating the scene. ```APIDOC ## impl PaintScene for Scene ### Methods #### `reset()` - **Description**: Removes all content from the scene. - **Signature**: `fn reset(&mut self)` #### `push_layer(blend: impl Into, alpha: f32, transform: Affine, clip: &impl Shape)` - **Description**: Pushes a new layer clipped by the specified shape and composed with previous layers using the specified blend mode. - **Signature**: `fn push_layer(&mut self, blend: impl Into, alpha: f32, transform: Affine, clip: &impl Shape)` #### `push_clip_layer(transform: Affine, clip: &impl Shape)` - **Description**: Pushes a new clip layer clipped by the specified shape. - **Signature**: `fn push_clip_layer(&mut self, transform: Affine, clip: &impl Shape)` #### `pop_layer()` - **Description**: Pops the current layer. - **Signature**: `fn pop_layer(&mut self)` #### `stroke<'a>(style: &Stroke, transform: Affine, paint_ref: impl Into>, brush_transform: Option, shape: &impl Shape)` - **Description**: Strokes a shape using the specified style and brush. - **Signature**: `fn stroke<'a>(&mut self, style: &Stroke, transform: Affine, paint_ref: impl Into>, brush_transform: Option, shape: &impl Shape)` #### `fill<'a>(style: Fill, transform: Affine, paint: impl Into>, brush_transform: Option, shape: &impl Shape)` - **Description**: Fills a shape using the specified style and brush. - **Signature**: `fn fill<'a>(&mut self, style: Fill, transform: Affine, paint: impl Into>, brush_transform: Option, shape: &impl Shape)` #### `draw_glyphs<'a, 's: 'a>(font: &'a FontData, font_size: f32, hint: bool, normalized_coords: &'a [NormalizedCoord], style: impl Into>, paint_ref: impl Into>, brush_alpha: f32, transform: Affine, glyph_transform: Option, glyphs: impl Iterator)` - **Description**: Draws a run of glyphs. - **Signature**: `fn draw_glyphs<'a, 's: 'a>(&'a mut self, font: &'a FontData, font_size: f32, hint: bool, normalized_coords: &'a [NormalizedCoord], style: impl Into>, paint_ref: impl Into>, brush_alpha: f32, transform: Affine, glyph_transform: Option, glyphs: impl Iterator)` #### `draw_box_shadow(transform: Affine, rect: Rect, brush: Color, radius: f64, std_dev: f64)` - **Description**: Draws a rounded rectangle blurred with a gaussian filter. - **Signature**: `fn draw_box_shadow(&mut self, transform: Affine, rect: Rect, brush: Color, radius: f64, std_dev: f64)` #### `append_scene(scene: Scene, scene_transform: Affine)` - **Description**: Appends a recorded Scene Fragment to the current scene. - **Signature**: `fn append_scene(&mut self, scene: Scene, scene_transform: Affine)` #### `draw_image(image: ImageBrushRef<'_>, transform: Affine)` - **Description**: Utility method to draw an image at its natural size. For more advanced image drawing use the `fill` method. - **Signature**: `fn draw_image(&mut self, image: ImageBrushRef<'_>, transform: Affine)` ``` -------------------------------- ### TryFrom Trait Source: https://docs.rs/anyrender/0.8.0/anyrender/recording/struct.Scene.html Provides a fallible conversion from one type to another. ```APIDOC ## `TryFrom` Trait ### Description Provides a fallible conversion from one type to another. The conversion can fail, returning an error. ### Implementation `impl TryFrom for T where U: Into` ### Associated Types #### `Error` `type Error = Infallible` The type returned in the event of a conversion error. `Infallible` indicates that this conversion cannot fail. ### Methods #### `try_from` ```rust fn try_from(value: U) -> Result>::Error> ``` Performs the conversion. Returns `Ok(T)` on success or `Err(Error)` on failure. ``` -------------------------------- ### LayerCommand Struct Source: https://docs.rs/anyrender/0.8.0/anyrender/recording/struct.LayerCommand.html Represents a command to push a new layer with specific blending, alpha, transform, and clipping properties. ```APIDOC ## Struct LayerCommand ### Description Pushes a new layer clipped by the specified shape and composed with previous layers using the specified blend mode. Every drawing command after this call will be clipped by the shape until the layer is popped. However, the transforms are not saved or modified by the layer stack. ### Fields - **blend** (BlendMode) - Description of the blend mode to be used for the layer. - **alpha** (f32) - The alpha value for the layer, controlling its transparency. - **transform** (Affine) - The affine transformation to be applied to the layer. - **clip** (BezPath) - The BezPath defining the clipping region for the layer. ### Request Example ```json { "blend": "SourceOver", "alpha": 1.0, "transform": { "a": 1.0, "b": 0.0, "c": 0.0, "d": 1.0, "e": 0.0, "f": 0.0 }, "clip": { "segments": [] } } ``` ### Response Example ```json { "message": "LayerCommand processed successfully" } ``` ``` -------------------------------- ### Clone Trait Implementation for RenderCommand Source: https://docs.rs/anyrender/0.8.0/anyrender/recording/enum.RenderCommand.html Implementation of the Clone trait for RenderCommand, allowing for duplication of render commands. ```APIDOC ### impl Clone for RenderCommand #### fn clone(&self) -> RenderCommand Returns a duplicate of the value. #### fn clone_from(&mut self, source: &Self) Performs copy-assignment from `source`. ``` -------------------------------- ### Clone Implementation for StrokeCommand Source: https://docs.rs/anyrender/0.8.0/anyrender/recording/struct.StrokeCommand.html Provides functionality to clone StrokeCommand instances. ```APIDOC ### impl Clone for StrokeCommand #### fn clone(&self) -> StrokeCommand Returns a duplicate of the value. #### fn clone_from(&mut self, source: &Self) Performs copy-assignment from `source`. ``` -------------------------------- ### NullWindowRenderer Struct Source: https://docs.rs/anyrender/0.8.0/anyrender/struct.NullWindowRenderer.html Details about the NullWindowRenderer struct, which acts as a placeholder renderer. ```APIDOC ## Struct NullWindowRenderer ### Summary ```rust pub struct NullWindowRenderer { /* private fields */ } ``` ### Implementations This struct implements several traits, including Clone, Default, and WindowRenderer. ``` -------------------------------- ### Implement Clone for LayerCommand Source: https://docs.rs/anyrender/0.8.0/anyrender/recording/struct.LayerCommand.html Provides the ability to clone LayerCommand instances, allowing for duplication of layer commands. ```rust fn clone(&self) -> LayerCommand ``` ```rust fn clone_from(&mut self, source: &Self) ``` -------------------------------- ### Implement StructuralPartialEq for ClipCommand Source: https://docs.rs/anyrender/0.8.0/anyrender/recording/struct.ClipCommand.html Trait implementation for structural partial equality comparison. -------------------------------- ### WindowRenderer Implementation for NullWindowRenderer Source: https://docs.rs/anyrender/0.8.0/anyrender/struct.NullWindowRenderer.html Implements the WindowRenderer trait for NullWindowRenderer, providing rendering-related methods. ```APIDOC ### impl WindowRenderer for NullWindowRenderer #### type ScenePainter<'a> = NullScenePainter where Self: 'a #### fn resume(&mut self, _window: Arc, _width: u32, _height: u32) #### fn suspend(&mut self) #### fn is_active(&self) -> bool #### fn set_size(&mut self, _width: u32, _height: u32) #### fn render)>(&mut self, _draw_fn: F) ``` -------------------------------- ### Implement Debug for LayerCommand Source: https://docs.rs/anyrender/0.8.0/anyrender/recording/struct.LayerCommand.html Enables debugging output for LayerCommand instances, allowing them to be formatted for inspection. ```rust fn fmt(&self, f: &mut Formatter<'_>) -> Result ``` -------------------------------- ### Type Conversion Source: https://docs.rs/anyrender/0.8.0/anyrender/recording/enum.RenderCommand.html Provides details on the `try_into` method for performing conversions between types. ```APIDOC ## fn try_into(self) -> Result>::Error> ### Description Performs the conversion. ### Method N/A (Method within an implementation block) ### Endpoint N/A (Not an API endpoint) ### Parameters N/A ### Request Body N/A ### Response N/A ### Error Handling Returns a `Result` which can be an error if the conversion fails. ``` -------------------------------- ### Implement TryInto for T Source: https://docs.rs/anyrender/0.8.0/anyrender/recording/struct.StrokeCommand.html Provides a fallible conversion from type `T` to type `U`. Requires `U: TryFrom`. ```rust type Error = >::Error ``` ```rust fn try_into(self) -> Result>::Error> Performs the conversion. ``` -------------------------------- ### Structs in Recording Module Source: https://docs.rs/anyrender/0.8.0/anyrender/recording/index.html Details about the structures available in the recording module for defining drawing operations. ```APIDOC ## Structs ### BoxShadowCommand Draw a box shadow around a box. ### ClipCommand Pushes a new clip layer clipped by the specified shape. Every drawing command after this call will be clipped by the shape until the layer is popped. However, the transforms are not saved or modified by the layer stack. ### FillCommand Fills a shape using the specified style and brush. ### GlyphRunCommand Draws a run of glyphs. ### LayerCommand Pushes a new layer clipped by the specified shape and composed with previous layers using the specified blend mode. Every drawing command after this call will be clipped by the shape until the layer is popped. However, the transforms are not saved or modified by the layer stack. ### Scene A recording of a Scene or Scene Fragment stored as plain data types that can be stored and passed around. ### StrokeCommand Strokes a shape using the specified style and brush. ``` -------------------------------- ### draw_image Method Source: https://docs.rs/anyrender/0.8.0/anyrender/trait.PaintScene.html Utility method to draw an image at its natural size using the provided brush and transform. For more advanced image drawing, use the `fill` method. ```rust fn draw_image(&mut self, image: ImageBrushRef<'_>, transform: Affine) { ... } ``` -------------------------------- ### Implement TryFrom for T Source: https://docs.rs/anyrender/0.8.0/anyrender/recording/struct.StrokeCommand.html Provides a fallible conversion from type `U` to type `T`. Requires `U: Into`. ```rust type Error = Infallible ``` ```rust fn try_from(value: U) -> Result>::Error> Performs the conversion. ``` -------------------------------- ### Implement Clone for NullScenePainter Source: https://docs.rs/anyrender/0.8.0/anyrender/struct.NullScenePainter.html Allows NullScenePainter instances to be cloned. Since it's a unit struct, cloning is a simple copy. ```rust fn clone(&self) -> NullScenePainter ``` ```rust fn clone_from(&mut self, source: &Self) ``` -------------------------------- ### Trait Implementations for NullScenePainter Source: https://docs.rs/anyrender/0.8.0/anyrender/struct.NullScenePainter.html Details on the standard traits implemented by NullScenePainter, such as Clone, Default, and Copy. ```APIDOC ### `Clone` Trait - **`clone(&self) -> NullScenePainter`**: Returns a duplicate of the value. - **`clone_from(&mut self, source: &Self)`**: Performs copy-assignment from `source`. ### `Default` Trait - **`default() -> NullScenePainter`**: Returns the default value for `NullScenePainter`. ### `Copy` Trait `NullScenePainter` implements the `Copy` trait, meaning it can be copied implicitly. ``` -------------------------------- ### CustomPaint Trait Implementations Source: https://docs.rs/anyrender/0.8.0/anyrender/types/struct.CustomPaint.html Details the trait implementations available for the CustomPaint struct. ```APIDOC ## Trait Implementations for CustomPaint ### `impl Clone for CustomPaint` - `fn clone(&self) -> CustomPaint`: Returns a duplicate of the value. - `fn clone_from(&mut self, source: &Self)`: Performs copy-assignment from `source`. ### `impl Debug for CustomPaint` - `fn fmt(&self, f: &mut Formatter<'_>) -> Result`: Formats the value using the given formatter. ### `impl Copy for CustomPaint` ### Auto Trait Implementations - `impl Freeze for CustomPaint` - `impl RefUnwindSafe for CustomPaint` - `impl Send for CustomPaint` - `impl Sync for CustomPaint` - `impl Unpin for CustomPaint` - `impl UnsafeUnpin for CustomPaint` - `impl UnwindSafe for CustomPaint` ### Blanket Implementations - `impl Any for T` - `fn type_id(&self) -> TypeId`: Gets the `TypeId` of `self`. - `impl Borrow for T` - `fn borrow(&self) -> &T`: Immutably borrows from an owned value. - `impl BorrowMut for T` - `fn borrow_mut(&mut self) -> &mut T`: Mutably borrows from an owned value. - `impl CloneToUninit for T` (Nightly-only experimental API) - `unsafe fn clone_to_uninit(&self, dest: *mut u8)`: Performs copy-assignment from `self` to `dest`. - `impl From for T` - `fn from(t: T) -> T`: Returns the argument unchanged. - `impl Into for T` - `fn into(self) -> U`: Calls `U::from(self)`. - `impl ToOwned for T` - `type Owned = T` - `fn to_owned(&self) -> T`: Creates owned data from borrowed data, usually by cloning. - `fn clone_into(&self, target: &mut T)`: Uses borrowed data to replace owned data, usually by cloning. - `impl TryFrom for T` - `type Error = Infallible` - `fn try_from(value: U) -> Result>::Error>`: Performs the conversion. - `impl TryInto for T` - `type Error = >::Error` - `fn try_into(self) -> Result>::Error>`: Performs the conversion. - `impl WasmNotSend for T` - `impl WasmNotSendSync for T` - `impl WasmNotSync for T` ``` -------------------------------- ### ClipCommand Struct Source: https://docs.rs/anyrender/0.8.0/anyrender/recording/struct.ClipCommand.html Represents a command to push a new clip layer. All subsequent drawing commands are clipped by the specified shape until the layer is popped. ```APIDOC ## Struct ClipCommand ### Description Pushes a new clip layer clipped by the specified shape. Every drawing command after this call will be clipped by the shape until the layer is popped. However, the transforms are not saved or modified by the layer stack. ### Fields - **transform** (Affine) - Description of the transform. - **clip** (BezPath) - Description of the clipping path. ### Request Example ```json { "transform": { "matrix": [ 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0 ] }, "clip": { "segments": [ {"MoveTo": {"point": {"x": 10.0, "y": 10.0}}}, {"LineTo": {"point": {"x": 100.0, "y": 10.0}}}, {"LineTo": {"point": {"x": 100.0, "y": 100.0}}}, {"LineTo": {"point": {"x": 10.0, "y": 100.0}}}, {"ClosePath": null} ] } } ``` ### Response #### Success Response (200) This endpoint does not return a response body in the traditional sense, as it modifies the drawing state. #### Response Example (No response body) ``` -------------------------------- ### Function render_to_buffer Source: https://docs.rs/anyrender/0.8.0/anyrender/fn.render_to_buffer.html Draws a scene to a buffer using an ImageRenderer. This function takes a drawing function and dimensions, returning a Vec representing the rendered image. ```APIDOC ## Function render_to_buffer ### Description Draw a scene to a buffer using an `ImageRenderer`. ### Signature ```rust pub fn render_to_buffer)>(draw_fn: F, width: u32, height: u32) -> Vec ``` ### Parameters - **draw_fn** (F) - A closure that takes a mutable reference to the `ScenePainter` to perform drawing operations. - **width** (u32) - The desired width of the rendered image buffer. - **height** (u32) - The desired height of the rendered image buffer. ### Returns - **Vec** - A vector of bytes representing the rendered image buffer. ``` -------------------------------- ### draw_glyphs Method Source: https://docs.rs/anyrender/0.8.0/anyrender/trait.PaintScene.html Draws a run of glyphs using the specified font, size, and style. Supports normalization coordinates and brush transformations. ```rust fn draw_glyphs<'a, 's: 'a>( &'s mut self, font: &'a FontData, font_size: f32, hint: bool, normalized_coords: &'a [NormalizedCoord], style: impl Into>, brush: impl Into>, brush_alpha: f32, transform: Affine, glyph_transform: Option, glyphs: impl Iterator, ); ``` -------------------------------- ### Implement Debug for StrokeCommand Source: https://docs.rs/anyrender/0.8.0/anyrender/recording/struct.StrokeCommand.html Enables debugging output for StrokeCommand. Requires the Image type to implement Debug. ```rust fn fmt(&self, f: &mut Formatter<'_>) -> Result Formats the value using the given formatter. Read more ``` -------------------------------- ### BoxShadowCommand Struct Source: https://docs.rs/anyrender/0.8.0/anyrender/recording/struct.BoxShadowCommand.html Definition and fields for the BoxShadowCommand struct used for rendering box shadows. ```APIDOC ## Struct: BoxShadowCommand ### Description Draw a box shadow around a box. ### Fields - **transform** (Affine) - The transformation matrix applied to the shadow. - **rect** (Rect) - The rectangular area to apply the shadow to. - **brush** (Color) - The color of the shadow. - **radius** (f64) - The corner radius of the shadow. - **std_dev** (f64) - The standard deviation for the shadow blur effect. ``` -------------------------------- ### push_clip_layer Method Source: https://docs.rs/anyrender/0.8.0/anyrender/trait.PaintScene.html Pushes a new clip layer clipped by the specified shape. Drawing commands after this are clipped until the layer is popped. Transforms are not saved by the layer stack. ```rust fn push_clip_layer(&mut self, transform: Affine, clip: &impl Shape); ``` -------------------------------- ### Scene Struct Source: https://docs.rs/anyrender/0.8.0/anyrender/recording/struct.Scene.html Represents a recording of a Scene or Scene Fragment stored as plain data types. ```APIDOC ## Struct Scene ### Description A recording of a Scene or Scene Fragment stored as plain data types that can be stored and passed around. ### Fields - **tolerance** (f64) - The tolerance value for the scene. - **commands** (Vec) - A vector of render commands. ### Methods #### `new()` - **Description**: Creates a new empty Scene. - **Signature**: `pub fn new() -> Self` #### `with_tolerance(tolerance: f64)` - **Description**: Creates a new Scene with a specified tolerance. - **Signature**: `pub fn with_tolerance(tolerance: f64) -> Self` ``` -------------------------------- ### Debug Implementation for StrokeCommand Source: https://docs.rs/anyrender/0.8.0/anyrender/recording/struct.StrokeCommand.html Provides functionality to format StrokeCommand instances for debugging. ```APIDOC ### impl Debug for StrokeCommand #### fn fmt(&self, f: &mut Formatter<'_>) -> Result Formats the value using the given formatter. ``` -------------------------------- ### Enums in Recording Module Source: https://docs.rs/anyrender/0.8.0/anyrender/recording/index.html Details about the enumerations available in the recording module. ```APIDOC ## Enums ### RenderCommand ``` -------------------------------- ### push_layer Method Source: https://docs.rs/anyrender/0.8.0/anyrender/trait.PaintScene.html Pushes a new layer clipped by the specified shape and composed with previous layers using the specified blend mode. Drawing commands after this are clipped until the layer is popped. Transforms are not saved by the layer stack. ```rust fn push_layer( &mut self, blend: impl Into, alpha: f32, transform: Affine, clip: &impl Shape, ); ``` -------------------------------- ### append_scene Method Source: https://docs.rs/anyrender/0.8.0/anyrender/trait.PaintScene.html Appends a recorded Scene Fragment to the current scene with an optional transformation. ```rust fn append_scene(&mut self, scene: Scene, scene_transform: Affine) { ... } ``` -------------------------------- ### TryInto Trait Source: https://docs.rs/anyrender/0.8.0/anyrender/recording/struct.Scene.html Provides a fallible conversion into another type. ```APIDOC ## `TryInto` Trait ### Description Provides a fallible conversion into another type. This is the inverse of `TryFrom`. ### Implementation `impl TryInto for T where U: TryFrom` ### Associated Types #### `Error` `type Error = >::Error` The type returned in the event of a conversion error. This is the same error type as the corresponding `TryFrom` implementation. ### Methods #### `try_into` ```rust fn try_into(self) -> Result>::Error> ``` Performs the conversion. Returns `Ok(U)` on success or `Err(Error)` on failure. ``` -------------------------------- ### Implement TryInto for T Source: https://docs.rs/anyrender/0.8.0/anyrender/recording/struct.LayerCommand.html Attempts to convert a value of type T into a value of type U, returning a Result. ```rust type Error = >::Error ``` ```rust fn try_into(self) -> Result>::Error> ``` -------------------------------- ### Implement Default for NullScenePainter Source: https://docs.rs/anyrender/0.8.0/anyrender/struct.NullScenePainter.html Provides a default value for NullScenePainter, returning an instance of itself. This is useful for creating a default no-op painter. ```rust fn default() -> NullScenePainter ``` -------------------------------- ### Implement ImageRenderer for NullImageRenderer Source: https://docs.rs/anyrender/0.8.0/anyrender/struct.NullImageRenderer.html This implementation provides a no-op version of the ImageRenderer trait for NullImageRenderer. All methods are empty and do not perform any actions. This is useful for scenarios where rendering is not needed. ```rust impl ImageRenderer for NullImageRenderer { type ScenePainter<'a> = NullScenePainter where Self: 'a; fn new(_width: u32, _height: u32) -> Self { NullImageRenderer } fn resize(&mut self, _width: u32, _height: u32) { } fn reset(&mut self) { } fn render_to_vec)>( &mut self, _draw_fn: F, _vec: &mut Vec, ) { } fn render)>( &mut self, _draw_fn: F, _buffer: &mut [u8], ) { } } ``` -------------------------------- ### Debug Trait Implementation for RenderCommand Source: https://docs.rs/anyrender/0.8.0/anyrender/recording/enum.RenderCommand.html Implementation of the Debug trait for RenderCommand, enabling formatted output for debugging. ```APIDOC ### impl Debug for RenderCommand #### fn fmt(&self, f: &mut Formatter<'_>) -> Result Formats the value using the given formatter. ``` -------------------------------- ### Define BoxShadowCommand struct Source: https://docs.rs/anyrender/0.8.0/anyrender/recording/struct.BoxShadowCommand.html The structure definition for BoxShadowCommand, specifying the geometric and visual properties for shadow rendering. ```rust pub struct BoxShadowCommand { pub transform: Affine, pub rect: Rect, pub brush: Color, pub radius: f64, pub std_dev: f64, } ``` -------------------------------- ### GlyphRunCommand Struct Source: https://docs.rs/anyrender/0.8.0/anyrender/recording/struct.GlyphRunCommand.html Definition of the GlyphRunCommand struct used for rendering glyph runs. ```APIDOC ## GlyphRunCommand ### Description Represents a command to draw a run of glyphs with specific font, style, and transformation properties. ### Fields - **font_data** (Font) - The font data used for rendering. - **font_size** (f32) - The size of the font. - **hint** (bool) - Whether to use font hinting. - **normalized_coords** (Vec) - Normalized coordinates for the glyphs. - **style** (Style) - The style applied to the glyphs. - **brush** (Brush>) - The brush used for filling or stroking. - **brush_alpha** (f32) - The alpha transparency of the brush. - **transform** (Affine) - The transformation matrix for the glyph run. - **glyph_transform** (Option) - Optional transformation applied to individual glyphs. - **glyphs** (Vec) - The list of glyphs to be rendered. ``` -------------------------------- ### Implement TryFrom for T Source: https://docs.rs/anyrender/0.8.0/anyrender/recording/struct.LayerCommand.html Attempts to convert a value of type U into a value of type T, returning a Result. ```rust type Error = Infallible ``` ```rust fn try_from(value: U) -> Result>::Error> ``` -------------------------------- ### ImageRenderer Trait Methods Source: https://docs.rs/anyrender/0.8.0/anyrender/trait.ImageRenderer.html API documentation for the methods defined in the ImageRenderer trait for scene rendering. ```APIDOC ## Trait: ImageRenderer ### Description Abstraction for rendering a scene to an image buffer. ### Methods - **new(width: u32, height: u32) -> Self** - Creates a new instance of the renderer with the specified dimensions. - **resize(&mut self, width: u32, height: u32)** - Resizes the renderer to the new width and height. - **reset(&mut self)** - Resets the renderer state. - **render_to_vec)>(draw_fn: F, vec: &mut Vec)** - Renders the scene using the provided draw function into a vector. - **render)>(draw_fn: F, buffer: &mut [u8])** - Renders the scene using the provided draw function into a pre-allocated buffer. ### Associated Types - **ScenePainter<'a>: PaintScene** - The painter type used for drawing the scene. ``` -------------------------------- ### Implement Clone for NullImageRenderer Source: https://docs.rs/anyrender/0.8.0/anyrender/struct.NullImageRenderer.html Allows NullImageRenderer instances to be duplicated. This is a standard implementation for types that can be copied. ```rust impl Clone for NullImageRenderer { fn clone(&self) -> NullImageRenderer { NullImageRenderer } } ``` -------------------------------- ### CustomPaint Struct Source: https://docs.rs/anyrender/0.8.0/anyrender/types/struct.CustomPaint.html Defines a custom paint object with source ID, dimensions, and scale. ```APIDOC ## Struct CustomPaint ### Summary ```rust pub struct CustomPaint { pub source_id: u64, pub width: u32, pub height: u32, pub scale: f64, } ``` ### Fields - `source_id` (u64) - `width` (u32) - `height` (u32) - `scale` (f64) ``` -------------------------------- ### Define CustomPaint Struct Source: https://docs.rs/anyrender/0.8.0/anyrender/types/struct.CustomPaint.html Defines the structure for custom paint operations, including source ID, dimensions, and scale. ```rust pub struct CustomPaint { pub source_id: u64, pub width: u32, pub height: u32, pub scale: f64, } ``` -------------------------------- ### GlyphRunCommand Struct Definition Source: https://docs.rs/anyrender/0.8.0/anyrender/recording/struct.GlyphRunCommand.html The structure definition for GlyphRunCommand, which holds font, style, and transformation data for glyph rendering. ```rust pub struct GlyphRunCommand { pub font_data: Font, pub font_size: f32, pub hint: bool, pub normalized_coords: Vec, pub style: Style, pub brush: Brush>, pub brush_alpha: f32, pub transform: Affine, pub glyph_transform: Option, pub glyphs: Vec, } ``` -------------------------------- ### FillCommand Struct Source: https://docs.rs/anyrender/0.8.0/anyrender/recording/struct.FillCommand.html The FillCommand struct is used to represent a command that fills a shape using a specified style and brush. ```APIDOC ## FillCommand ### Description Fills a shape using the specified style and brush. ### Fields - **fill** (Fill) - The fill style to apply. - **transform** (Affine) - The transformation matrix applied to the fill. - **brush** (Brush>) - The brush used for filling, supporting image-based brushes. - **brush_transform** (Option) - An optional transformation matrix for the brush. - **shape** (BezPath) - The path defining the shape to be filled. ``` -------------------------------- ### RenderCommand Enum Definition Source: https://docs.rs/anyrender/0.8.0/anyrender/recording/enum.RenderCommand.html The core enum structure defining available rendering commands with generic parameters for font and image data. ```rust pub enum RenderCommand { PushLayer(LayerCommand), PushClipLayer(ClipCommand), PopLayer, Stroke(StrokeCommand), Fill(FillCommand), GlyphRun(GlyphRunCommand), BoxShadow(BoxShadowCommand), } ``` -------------------------------- ### Define FillCommand struct Source: https://docs.rs/anyrender/0.8.0/anyrender/recording/struct.FillCommand.html The structure used to represent a fill operation in anyrender, containing the shape, brush, and transformation data. ```rust pub struct FillCommand { pub fill: Fill, pub transform: Affine, pub brush: Brush>, pub brush_transform: Option, pub shape: BezPath, } ``` -------------------------------- ### stroke Method Source: https://docs.rs/anyrender/0.8.0/anyrender/trait.PaintScene.html Strokes a shape using the specified style and brush. Requires a shape, stroke style, and brush definition. ```rust fn stroke<'a>( &mut self, style: &Stroke, transform: Affine, brush: impl Into>, brush_transform: Option, shape: &impl Shape, ); ``` -------------------------------- ### StrokeCommand Struct Source: https://docs.rs/anyrender/0.8.0/anyrender/recording/struct.StrokeCommand.html Defines a command for stroking a shape with a specified style, transform, and brush. ```APIDOC ## Struct StrokeCommand ### Description Strokes a shape using the specified style and brush. ### Fields - **style** (Stroke) - Description of the stroke style. - **transform** (Affine) - The transformation to apply to the shape. - **brush** (Brush>) - The brush used for stroking. - **brush_transform** (Option) - Optional transformation for the brush. - **shape** (BezPath) - The shape to be stroked. ### Example Usage (Conceptual) ```rust use anyrender::recording::{StrokeCommand, Stroke, Brush, ImageData}; use nalgebra::Affine2 as Affine; use kurbo::BezPath; let stroke_command = StrokeCommand { style: Stroke::default(), // Assuming Stroke has a default transform: Affine::identity(), // Assuming Affine has an identity brush: Brush::Image(ImageBrush::new(ImageData::default())), // Assuming ImageData and ImageBrush have defaults brush_transform: None, shape: BezPath::new(), // Assuming BezPath can be created empty }; ``` ```