Struct canvas::canvas_data::CanvasData
source · pub struct CanvasData<'a> {
backend: Box<dyn Backend>,
drawtarget: Box<dyn GenericDrawTarget>,
path_state: Option<PathState>,
state: CanvasPaintState<'a>,
saved_states: Vec<CanvasPaintState<'a>>,
compositor_api: CrossProcessCompositorApi,
image_key: Option<ImageKey>,
old_image_key: Option<ImageKey>,
very_old_image_key: Option<ImageKey>,
font_context: Arc<FontContext>,
}
Fields§
§backend: Box<dyn Backend>
§drawtarget: Box<dyn GenericDrawTarget>
§path_state: Option<PathState>
§state: CanvasPaintState<'a>
§saved_states: Vec<CanvasPaintState<'a>>
§compositor_api: CrossProcessCompositorApi
§image_key: Option<ImageKey>
§old_image_key: Option<ImageKey>
An old webrender image key that can be deleted when the next epoch ends.
very_old_image_key: Option<ImageKey>
An old webrender image key that can be deleted when the current epoch ends.
font_context: Arc<FontContext>
Implementations§
source§impl<'a> CanvasData<'a>
impl<'a> CanvasData<'a>
pub fn new( size: Size2D<u64>, compositor_api: CrossProcessCompositorApi, antialias: AntialiasMode, font_context: Arc<FontContext>, ) -> CanvasData<'a>
pub fn draw_image( &mut self, image_data: &[u8], image_size: Size2D<f64>, dest_rect: Rect<f64>, source_rect: Rect<f64>, smoothing_enabled: bool, premultiply: bool, )
pub fn save_context_state(&mut self)
pub fn restore_context_state(&mut self)
pub fn fill_text_with_size( &mut self, text: String, x: f64, y: f64, max_width: Option<f64>, is_rtl: bool, size: f64, )
sourcepub fn fill_text(
&mut self,
text: String,
x: f64,
y: f64,
max_width: Option<f64>,
is_rtl: bool,
)
pub fn fill_text( &mut self, text: String, x: f64, y: f64, max_width: Option<f64>, is_rtl: bool, )
sourcepub fn measure_text(&mut self, text: String) -> TextMetrics
pub fn measure_text(&mut self, text: String) -> TextMetrics
fn build_unshaped_text_runs<'b>( &self, text: &'b str, font_group: &mut FontGroup, ) -> Vec<UnshapedTextRun<'b>>
sourcefn find_anchor_point_for_line_of_text(
&self,
x: f32,
y: f32,
metrics: &FontMetrics,
width: f32,
is_rtl: bool,
) -> Point2D<f32>
fn find_anchor_point_for_line_of_text( &self, x: f32, y: f32, metrics: &FontMetrics, width: f32, is_rtl: bool, ) -> Point2D<f32>
Find the anchor_point for the given parameters of a line of text. See https://html.spec.whatwg.org/multipage/#text-preparation-algorithm.
pub fn fill_rect(&mut self, rect: &Rect<f32>)
pub fn clear_rect(&mut self, rect: &Rect<f32>)
pub fn stroke_rect(&mut self, rect: &Rect<f32>)
pub fn begin_path(&mut self)
pub fn close_path(&mut self)
fn ensure_path(&mut self)
fn path(&self) -> &Path
pub fn fill(&mut self)
pub fn stroke(&mut self)
pub fn clip(&mut self)
pub fn is_point_in_path( &mut self, x: f64, y: f64, _fill_rule: FillRule, chan: IpcSender<bool>, )
pub fn move_to(&mut self, point: &Point2D<f32>)
pub fn line_to(&mut self, point: &Point2D<f32>)
fn path_builder(&mut self) -> PathBuilderRef<'_>
pub fn rect(&mut self, rect: &Rect<f32>)
pub fn quadratic_curve_to(&mut self, cp: &Point2D<f32>, endpoint: &Point2D<f32>)
pub fn bezier_curve_to( &mut self, cp1: &Point2D<f32>, cp2: &Point2D<f32>, endpoint: &Point2D<f32>, )
pub fn arc( &mut self, center: &Point2D<f32>, radius: f32, start_angle: f32, end_angle: f32, ccw: bool, )
pub fn arc_to(&mut self, cp1: &Point2D<f32>, cp2: &Point2D<f32>, radius: f32)
pub fn ellipse( &mut self, center: &Point2D<f32>, radius_x: f32, radius_y: f32, rotation_angle: f32, start_angle: f32, end_angle: f32, ccw: bool, )
pub fn set_fill_style(&mut self, style: FillOrStrokeStyle)
pub fn set_stroke_style(&mut self, style: FillOrStrokeStyle)
pub fn set_line_width(&mut self, width: f32)
pub fn set_line_cap(&mut self, cap: LineCapStyle)
pub fn set_line_join(&mut self, join: LineJoinStyle)
pub fn set_miter_limit(&mut self, limit: f32)
pub fn get_transform(&self) -> Transform2D<f32>
pub fn set_transform(&mut self, transform: &Transform2D<f32>)
pub fn set_global_alpha(&mut self, alpha: f32)
pub fn set_global_composition(&mut self, op: CompositionOrBlending)
pub fn recreate(&mut self, size: Option<Size2D<u64>>)
pub fn send_pixels(&mut self, chan: IpcSender<IpcSharedMemory>)
pub fn send_data(&mut self, chan: IpcSender<CanvasImageData>)
pub fn put_image_data(&mut self, imagedata: Vec<u8>, rect: Rect<u64>)
pub fn set_shadow_offset_x(&mut self, value: f64)
pub fn set_shadow_offset_y(&mut self, value: f64)
pub fn set_shadow_blur(&mut self, value: f64)
pub fn set_shadow_color(&mut self, value: AbsoluteColor)
pub fn set_font(&mut self, font_style: FontStyleStruct)
pub fn set_text_align(&mut self, text_align: TextAlign)
pub fn set_text_baseline(&mut self, text_baseline: TextBaseline)
fn need_to_draw_shadow(&self) -> bool
fn create_draw_target_for_shadow( &self, source_rect: &Rect<f32>, ) -> Box<dyn GenericDrawTarget>
fn draw_with_shadow<F>(&self, rect: &Rect<f32>, draw_shadow_source: F)where
F: FnOnce(&mut dyn GenericDrawTarget),
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for CanvasData<'a>
impl<'a> !RefUnwindSafe for CanvasData<'a>
impl<'a> !Send for CanvasData<'a>
impl<'a> !Sync for CanvasData<'a>
impl<'a> Unpin for CanvasData<'a>
impl<'a> !UnwindSafe for CanvasData<'a>
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
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§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>
Converts
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>
Converts
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 moresource§impl<T> MaybeBoxed<Box<T>> for T
impl<T> MaybeBoxed<Box<T>> for T
source§fn maybe_boxed(self) -> Box<T>
fn maybe_boxed(self) -> Box<T>
Convert
source§impl<T> MaybeBoxed<T> for T
impl<T> MaybeBoxed<T> for T
source§fn maybe_boxed(self) -> T
fn maybe_boxed(self) -> T
Convert