pub struct Stage { /* private fields */ }Expand description
Entrypoint for staging data on the GPU and interacting with lighting.
§Design
The Stage struct serves as the central hub for managing and staging data on the GPU.
It provides a consistent API for creating resources, applying effects, and customizing parameters.
The Stage uses a combination of new_*, with_*, set_*, and getter functions to facilitate
resource management and customization.
Resources are managed internally, requiring no additional lifecycle work from the user. This design simplifies the process of resource management, allowing developers to focus on creating and rendering their scenes without worrying about the underlying GPU resource management.
§Resources
The Stage is responsible for creating various resources and staging them on the GPU.
It handles the setup and management of the following resources:
Camera: Manages the view and projection matrices for rendering scenes.Stage::new_cameracreates a newCamera.Stage::use_cameratells theStageto use a camera.
Transform: Represents the position, rotation, and scale of objects.Stage::new_transformcreates a newTransform.
NestedTransform: Allows for hierarchical transformations, useful for complex object hierarchies.Stage::new_nested_transformcreates a newNestedTransform
Vertices: Manages vertex data for rendering meshes.Indices: Manages index data for rendering meshes with indexed drawing.Primitive: Represents a drawable object in the scene.GltfDocument: Handles loading and managing GLTF assets.Stage::load_gltf_document_from_pathloads a new GLTF document from the local filesystem.Stage::load_gltf_document_from_bytesparses a new GLTF document from pre-loaded bytes.
Skin: Animation and rigging information.
§Lighting effects
The Stage also manages various lighting effects, which enhance the visual quality of the scene:
AnalyticalLight: Simulates a single light source, with three flavors:DirectionalLight: Represents sunlight or other distant light sources.PointLight: Represents a light source that emits light in all directions from a single point.SpotLight: Represents a light source that emits light in a cone shape.
Skybox: Provides image-based lighting (IBL) for realistic environmental reflections and ambient lighting.Bloom: Adds a glow effect to bright areas of the scene, enhancing visual appeal.ShadowMap: Manages shadow mapping for realistic shadow rendering.LightTiling: Optimizes lighting calculations by dividing the scene into tiles for efficient processing.
§Note
Clones of Stage all point to the same underlying data.
Implementations§
Source§impl Stage
GLTF functions
impl Stage
GLTF functions
pub fn load_gltf_document_from_path( &self, path: impl AsRef<Path>, ) -> Result<GltfDocument, StageError>
pub fn load_gltf_document_from_bytes( &self, bytes: impl AsRef<[u8]>, ) -> Result<GltfDocument, StageError>
Source§impl Stage
Geometry functions
impl Stage
Geometry functions
Sourcepub fn default_vertices(&self) -> &Vertices
pub fn default_vertices(&self) -> &Vertices
Returns the vertices of a white unit cube.
This is the mesh of every Primitive that has not had its vertices set.
Sourcepub fn new_camera(&self) -> Camera
pub fn new_camera(&self) -> Camera
Stage a new Camera on the GPU.
If no camera is currently in use on the Stage through
Stage::use_camera, this new camera will be used automatically.
Sourcepub fn use_camera(&self, camera: impl AsRef<Camera>)
pub fn use_camera(&self, camera: impl AsRef<Camera>)
Use the given camera when rendering.
Sourcepub fn used_camera_id(&self) -> Id<CameraDescriptor>
pub fn used_camera_id(&self) -> Id<CameraDescriptor>
Return the Id of the camera currently in use.
Sourcepub fn use_camera_id(&self, camera_id: Id<CameraDescriptor>)
pub fn use_camera_id(&self, camera_id: Id<CameraDescriptor>)
Set the default camera Id.
Sourcepub fn new_transform(&self) -> Transform
pub fn new_transform(&self) -> Transform
Stage a Transform on the GPU.
Sourcepub fn new_vertices(&self, data: impl IntoIterator<Item = Vertex>) -> Vertices
pub fn new_vertices(&self, data: impl IntoIterator<Item = Vertex>) -> Vertices
Stage some vertex geometry data.
Sourcepub fn new_indices(&self, data: impl IntoIterator<Item = u32>) -> Indices
pub fn new_indices(&self, data: impl IntoIterator<Item = u32>) -> Indices
Stage some vertex index data.
Sourcepub fn new_morph_targets(
&self,
data: impl IntoIterator<Item = Vec<MorphTarget>>,
) -> MorphTargets
pub fn new_morph_targets( &self, data: impl IntoIterator<Item = Vec<MorphTarget>>, ) -> MorphTargets
Stage new morph targets.
Sourcepub fn new_morph_target_weights(
&self,
data: impl IntoIterator<Item = f32>,
) -> MorphTargetWeights
pub fn new_morph_target_weights( &self, data: impl IntoIterator<Item = f32>, ) -> MorphTargetWeights
Stage new morph target weights.
Sourcepub fn new_skin(
&self,
joints: impl IntoIterator<Item = impl Into<SkinJoint>>,
inverse_bind_matrices: impl IntoIterator<Item = impl Into<Mat4>>,
) -> Skin
pub fn new_skin( &self, joints: impl IntoIterator<Item = impl Into<SkinJoint>>, inverse_bind_matrices: impl IntoIterator<Item = impl Into<Mat4>>, ) -> Skin
Stage a new skin.
Sourcepub fn new_primitive(&self) -> Primitive
pub fn new_primitive(&self) -> Primitive
Stage a new Primitive on the GPU.
The returned Primitive will automatically be added to this Stage.
The returned Primitive will have the stage’s default Vertices, which is an all-white
unit cube.
The returned Primitive uses the stage’s default Material, which is white and
does not participate in lighting. To change this, first create a Material with
Stage::new_material and then call Primitive::set_material with the new material.
Sourcepub fn geometry_descriptor(&self) -> &Hybrid<GeometryDescriptor>
pub fn geometry_descriptor(&self) -> &Hybrid<GeometryDescriptor>
Returns a reference to the descriptor stored at the root of the geometry slab.
Source§impl Stage
Materials methods.
impl Stage
Materials methods.
Sourcepub fn default_material(&self) -> &Material
pub fn default_material(&self) -> &Material
Returns the default Material.
The default is an all-white matte material.
Sourcepub fn new_material(&self) -> Material
pub fn new_material(&self) -> Material
Sourcepub fn set_atlas_size(&self, size: Extent3d) -> Result<(), StageError>
pub fn set_atlas_size(&self, size: Extent3d) -> Result<(), StageError>
Set the size of the atlas.
This will cause a repacking.
Sourcepub fn add_images(
&self,
images: impl IntoIterator<Item = impl Into<AtlasImage>>,
) -> Result<Vec<AtlasTexture>, StageError>
pub fn add_images( &self, images: impl IntoIterator<Item = impl Into<AtlasImage>>, ) -> Result<Vec<AtlasTexture>, StageError>
Add images to the set of atlas images.
This returns a vector of Hybrid<AtlasTexture>, which
is a descriptor of each image on the GPU. Dropping these entries
will invalidate those images and cause the atlas to be repacked, and any raw
GPU references to the underlying AtlasTexture will also be invalidated.
Adding an image can be quite expensive, as it requires creating a new texture array for the atlas and repacking all previous images. For that reason it is good to batch images to reduce the number of calls.
Sourcepub fn clear_images(&self) -> Result<(), StageError>
pub fn clear_images(&self) -> Result<(), StageError>
Sourcepub fn set_images(
&self,
images: impl IntoIterator<Item = impl Into<AtlasImage>>,
) -> Result<Vec<AtlasTexture>, StageError>
pub fn set_images( &self, images: impl IntoIterator<Item = impl Into<AtlasImage>>, ) -> Result<Vec<AtlasTexture>, StageError>
Set the images to use for the atlas.
Resets the atlas, packing it with the given images and returning a vector of the frames already staged.
§WARNING
This invalidates any previously staged AtlasTextures.
Source§impl Stage
Lighting methods.
impl Stage
Lighting methods.
Sourcepub fn new_directional_light(&self) -> AnalyticalLight<DirectionalLight>
pub fn new_directional_light(&self) -> AnalyticalLight<DirectionalLight>
Stage a new directional light.
Sourcepub fn new_point_light(&self) -> AnalyticalLight<PointLight>
pub fn new_point_light(&self) -> AnalyticalLight<PointLight>
Stage a new point light.
Sourcepub fn new_spot_light(&self) -> AnalyticalLight<SpotLight>
pub fn new_spot_light(&self) -> AnalyticalLight<SpotLight>
Stage a new spot light.
Sourcepub fn add_light<T>(&self, bundle: &AnalyticalLight<T>)
pub fn add_light<T>(&self, bundle: &AnalyticalLight<T>)
Add an AnalyticalLight to the internal list of lights.
This is called implicitly by Stage::new_*_light.
This can be used to add the light back to the scene after using
Stage::remove_light.
Sourcepub fn remove_light<T: IsLight>(&self, bundle: &AnalyticalLight<T>)
pub fn remove_light<T: IsLight>(&self, bundle: &AnalyticalLight<T>)
Remove an AnalyticalLight from the internal list of lights.
Use this to exclude a light from rendering, without dropping the light.
After calling this function you can include the light again using Stage::add_light.
Sourcepub fn new_shadow_map<T>(
&self,
analytical_light: &AnalyticalLight<T>,
size: UVec2,
z_near: f32,
z_far: f32,
) -> Result<ShadowMap, StageError>
pub fn new_shadow_map<T>( &self, analytical_light: &AnalyticalLight<T>, size: UVec2, z_near: f32, z_far: f32, ) -> Result<ShadowMap, StageError>
Enable shadow mapping for the given AnalyticalLight, creating
a new ShadowMap.
§Tips for making a good shadow map
- Make sure the map is big enough.
Using a big map can fix some peter panning issues, even before
playing with bias in the returned
ShadowMap. The bigger the map, the cleaner the shadows will be. This can also solve PCF problems. - Don’t set PCF samples too high in the returned
ShadowMap, as this can cause peter panning. - Ensure the znear and zfar parameters make sense, as the
shadow map uses these to determine how much of the scene to cover.
If you find that shadows are cut off in a straight line, it’s likely
znearorzfarneeds adjustment.
Sourcepub fn new_light_tiling(&self, config: LightTilingConfig) -> LightTiling
pub fn new_light_tiling(&self, config: LightTilingConfig) -> LightTiling
Enable light tiling, creating a new LightTiling.
Source§impl Stage
Skybox methods
impl Stage
Skybox methods
Sourcepub fn use_skybox(&self, skybox: &Skybox) -> &Self
pub fn use_skybox(&self, skybox: &Skybox) -> &Self
Sourcepub fn remove_skybox(&self) -> Option<Skybox>
pub fn remove_skybox(&self) -> Option<Skybox>
Sourcepub fn new_skybox_from_path(
&self,
path: impl AsRef<Path>,
) -> Result<Skybox, AtlasImageError>
pub fn new_skybox_from_path( &self, path: impl AsRef<Path>, ) -> Result<Skybox, AtlasImageError>
Returns a new Skybox using the HDR image at the given path, if possible.
The returned Skybox must be used with Stage::use_skybox.
Sourcepub fn new_skybox_from_bytes(
&self,
bytes: &[u8],
) -> Result<Skybox, AtlasImageError>
pub fn new_skybox_from_bytes( &self, bytes: &[u8], ) -> Result<Skybox, AtlasImageError>
Returns a new Skybox using the bytes of an HDR image, if possible.
The returned Skybox must be used with Stage::use_skybox.
Source§impl Stage
Image based lighting methods
impl Stage
Image based lighting methods
Sourcepub fn use_ibl(&self, ibl: &Ibl) -> &Self
pub fn use_ibl(&self, ibl: &Ibl) -> &Self
Use the given image based lighting.
Use Stage::new_ibl to create a new Ibl.
Sourcepub fn remove_ibl(&self) -> Option<Ibl>
pub fn remove_ibl(&self) -> Option<Ibl>
Remove the current image based lighting from the stage and return it, if any.
Source§impl Stage
impl Stage
Sourcepub fn runtime(&self) -> &WgpuRuntime
pub fn runtime(&self) -> &WgpuRuntime
Returns the runtime.
pub fn device(&self) -> &Device
pub fn queue(&self) -> &Queue
Sourcepub fn brdf_lut(&self) -> &BrdfLut
pub fn brdf_lut(&self) -> &BrdfLut
Returns a reference to the BrdfLut.
This is used for creating skyboxes used in image based lighting.
Sourcepub fn used_gpu_buffer_byte_size(&self) -> usize
pub fn used_gpu_buffer_byte_size(&self) -> usize
Sum the byte size of all used GPU memory.
Adds together the byte size of all underlying slab buffers.
§Note
This does not take into consideration staged data that has not yet
been committed with either Stage::commit or Stage::render.
pub fn hdr_texture(&self) -> impl Deref<Target = Texture> + '_
Sourcepub fn commit(&self) -> StageCommitResult
pub fn commit(&self) -> StageCommitResult
Run all upkeep and commit all staged changes to the GPU.
This is done implicitly in Stage::render.
This can be used after dropping resources to reclaim those resources on the GPU.
pub fn create_primitive_pipeline( device: &Device, fragment_color_format: TextureFormat, multisample_count: u32, ) -> RenderPipeline
pub fn set_background_color(&self, color: impl Into<Vec4>)
pub fn with_background_color(self, color: impl Into<Vec4>) -> Self
Sourcepub fn get_msaa_sample_count(&self) -> u32
pub fn get_msaa_sample_count(&self) -> u32
Return the multisample count.
Sourcepub fn set_msaa_sample_count(&self, multisample_count: u32)
pub fn set_msaa_sample_count(&self, multisample_count: u32)
Set the MSAA multisample count.
Set to 1 to disable MSAA. Setting to 0 will be treated the same as
setting to 1.
Sourcepub fn with_msaa_sample_count(self, multisample_count: u32) -> Self
pub fn with_msaa_sample_count(self, multisample_count: u32) -> Self
Set the MSAA multisample count.
Set to 1 to disable MSAA. Setting to 0 will be treated the same as
setting to 1.
Sourcepub fn set_clear_color_attachments(&self, should_clear: bool)
pub fn set_clear_color_attachments(&self, should_clear: bool)
Set whether color attachments are cleared before rendering.
Sourcepub fn with_clear_color_attachments(self, should_clear: bool) -> Self
pub fn with_clear_color_attachments(self, should_clear: bool) -> Self
Set whether color attachments are cleared before rendering.
Sourcepub fn set_clear_depth_attachments(&self, should_clear: bool)
pub fn set_clear_depth_attachments(&self, should_clear: bool)
Set whether color attachments are cleared before rendering.
Sourcepub fn with_clear_depth_attachments(self, should_clear: bool) -> Self
pub fn with_clear_depth_attachments(self, should_clear: bool) -> Self
Set whether color attachments are cleared before rendering.
Sourcepub fn set_debug_mode(&self, debug_mode: DebugChannel)
pub fn set_debug_mode(&self, debug_mode: DebugChannel)
Set the debug mode.
Sourcepub fn with_debug_mode(self, debug_mode: DebugChannel) -> Self
pub fn with_debug_mode(self, debug_mode: DebugChannel) -> Self
Set the debug mode.
Sourcepub fn set_use_debug_overlay(&self, use_debug_overlay: bool)
pub fn set_use_debug_overlay(&self, use_debug_overlay: bool)
Set whether to render the debug overlay.
Sourcepub fn with_debug_overlay(self, use_debug_overlay: bool) -> Self
pub fn with_debug_overlay(self, use_debug_overlay: bool) -> Self
Set whether to render the debug overlay.
Sourcepub fn set_use_frustum_culling(&self, use_frustum_culling: bool)
pub fn set_use_frustum_culling(&self, use_frustum_culling: bool)
Set whether to use frustum culling on GPU before drawing.
This defaults to true.
Sourcepub fn with_frustum_culling(self, use_frustum_culling: bool) -> Self
pub fn with_frustum_culling(self, use_frustum_culling: bool) -> Self
Set whether to render the debug overlay.
Sourcepub fn set_use_occlusion_culling(&self, use_occlusion_culling: bool)
pub fn set_use_occlusion_culling(&self, use_occlusion_culling: bool)
Set whether to use occlusion culling on GPU before drawing.
This defaults to false.
§Warning
Occlusion culling is a feature in development. YMMV.
Sourcepub fn with_occlusion_culling(self, use_occlusion_culling: bool) -> Self
pub fn with_occlusion_culling(self, use_occlusion_culling: bool) -> Self
Set whether to render the debug overlay.
Sourcepub fn set_has_lighting(&self, use_lighting: bool)
pub fn set_has_lighting(&self, use_lighting: bool)
Set whether the stage uses lighting.
Sourcepub fn with_lighting(self, use_lighting: bool) -> Self
pub fn with_lighting(self, use_lighting: bool) -> Self
Set whether the stage uses lighting.
Sourcepub fn set_has_vertex_skinning(&self, use_skinning: bool)
pub fn set_has_vertex_skinning(&self, use_skinning: bool)
Set whether to use vertex skinning.
Sourcepub fn with_vertex_skinning(self, use_skinning: bool) -> Self
pub fn with_vertex_skinning(self, use_skinning: bool) -> Self
Set whether to use vertex skinning.
pub fn get_size(&self) -> UVec2
pub fn set_size(&self, size: UVec2)
pub fn with_size(self, size: UVec2) -> Self
Sourcepub fn set_has_bloom(&self, has_bloom: bool)
pub fn set_has_bloom(&self, has_bloom: bool)
Turn the bloom effect on or off.
Sourcepub fn with_bloom(self, has_bloom: bool) -> Self
pub fn with_bloom(self, has_bloom: bool) -> Self
Turn the bloom effect on or off.
Sourcepub fn set_bloom_mix_strength(&self, strength: f32)
pub fn set_bloom_mix_strength(&self, strength: f32)
Set the amount of bloom that is mixed in with the input image.
Defaults to 0.04.
pub fn with_bloom_mix_strength(self, strength: f32) -> Self
Sourcepub fn set_bloom_filter_radius(&self, filter_radius: f32)
pub fn set_bloom_filter_radius(&self, filter_radius: f32)
Sets the bloom filter radius, in pixels.
Default is 1.0.
Sourcepub fn with_bloom_filter_radius(self, filter_radius: f32) -> Self
pub fn with_bloom_filter_radius(self, filter_radius: f32) -> Self
Sets the bloom filter radius, in pixels.
Default is 1.0.
Sourcepub fn add_primitive(&self, primitive: &Primitive) -> usize
pub fn add_primitive(&self, primitive: &Primitive) -> usize
Adds a primitive to the internal list of primitives to be drawn each frame.
Returns the number of primitives added.
If you drop the primitive and no other references are kept, it will be removed automatically from the internal list and will cease to be drawn each frame.
Sourcepub fn remove_primitive(&self, primitive: &Primitive) -> usize
pub fn remove_primitive(&self, primitive: &Primitive) -> usize
Erase the given primitive from the internal list of primitives to be drawn each frame.
Returns the number of primitives added.
Sourcepub fn sort_primitive(&self, f: impl Fn(&Primitive, &Primitive) -> Ordering)
pub fn sort_primitive(&self, f: impl Fn(&Primitive, &Primitive) -> Ordering)
Sort the drawing order of primitives.
This determines the order in which Primitives are drawn each frame.
Sourcepub fn get_depth_texture(&self) -> DepthTexture
pub fn get_depth_texture(&self) -> DepthTexture
Returns a clone of the current depth texture.
Sourcepub fn new_nested_transform(&self) -> NestedTransform
pub fn new_nested_transform(&self) -> NestedTransform
Create a new NestedTransform.
Trait Implementations§
Source§impl AsRef<WgpuRuntime> for Stage
impl AsRef<WgpuRuntime> for Stage
Source§fn as_ref(&self) -> &WgpuRuntime
fn as_ref(&self) -> &WgpuRuntime
Auto Trait Implementations§
impl Freeze for Stage
impl !RefUnwindSafe for Stage
impl Send for Stage
impl Sync for Stage
impl Unpin for Stage
impl !UnwindSafe for Stage
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling [Attribute] value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi [Quirk] value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the [Condition] value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);