pub struct CanvasGradient(/* private fields */);
Expand description
The CanvasGradient struct represents an opaque object describing a gradient. It is returned by the methods CanvasRenderingContext2D.createLinearGradient() or CanvasRenderingContext2D.createRadialGradient().
Implementations§
Source§impl CanvasGradient
impl CanvasGradient
Sourcepub fn add_color_stop(
&self,
offset: f64,
color: &str,
) -> Result<(), AddColorStopError>
pub fn add_color_stop( &self, offset: f64, color: &str, ) -> Result<(), AddColorStopError>
Adds a new stop, defined by an offset and a color, to the gradient. If the offset is
not between 0 and 1, an INDEX_SIZE_ERR is returned, if the color can’t be parsed as a
CSS
Trait Implementations§
Source§impl AsRef<Reference> for CanvasGradient
impl AsRef<Reference> for CanvasGradient
Source§impl Clone for CanvasGradient
impl Clone for CanvasGradient
Source§fn clone(&self) -> CanvasGradient
fn clone(&self) -> CanvasGradient
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for CanvasGradient
impl Debug for CanvasGradient
Source§impl From<CanvasGradient> for Reference
impl From<CanvasGradient> for Reference
Source§fn from(value: CanvasGradient) -> Self
fn from(value: CanvasGradient) -> Self
Converts to this type from the input type.
Source§impl InstanceOf for CanvasGradient
impl InstanceOf for CanvasGradient
Source§impl PartialEq for CanvasGradient
impl PartialEq for CanvasGradient
Source§impl ReferenceType for CanvasGradient
impl ReferenceType for CanvasGradient
Source§unsafe fn from_reference_unchecked(reference: Reference) -> Self
unsafe fn from_reference_unchecked(reference: Reference) -> Self
Converts a given reference into a concrete reference-like wrapper.
Doesn’t do any type checking; highly unsafe to use!
Source§impl<'_r> TryFrom<&'_r Reference> for CanvasGradient
impl<'_r> TryFrom<&'_r Reference> for CanvasGradient
Source§impl<'_r> TryFrom<&'_r Value> for CanvasGradient
impl<'_r> TryFrom<&'_r Value> for CanvasGradient
Source§impl TryFrom<CanvasGradient> for Reference
impl TryFrom<CanvasGradient> for Reference
Source§impl TryFrom<Reference> for CanvasGradient
impl TryFrom<Reference> for CanvasGradient
Source§impl TryFrom<Value> for CanvasGradient
impl TryFrom<Value> for CanvasGradient
impl Eq for CanvasGradient
impl JsSerialize for CanvasGradient
impl StructuralPartialEq for CanvasGradient
Auto Trait Implementations§
impl Freeze for CanvasGradient
impl RefUnwindSafe for CanvasGradient
impl Send for CanvasGradient
impl Sync for CanvasGradient
impl Unpin for CanvasGradient
impl UnwindSafe for CanvasGradient
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
Mutably borrows from an owned value. Read more