Skip to main content

draw_shadow

Function draw_shadow 

pub fn draw_shadow(
    canvas: &Canvas,
    path: &Handle<SkPath>,
    z_plane_params: impl Into<Point3>,
    light_pos: impl Into<Point3>,
    light_radius: f32,
    ambient_color: impl Into<Color>,
    spot_color: impl Into<Color>,
    flags: impl Into<Option<ShadowFlags>>,
)
Expand description

Draw an offset spot shadow and outlining ambient shadow for the given path using a disc light. The shadow may be cached, depending on the path type and canvas matrix. If the matrix is perspective or the path is volatile, it will not be cached.

  • canvas The canvas on which to draw the shadows.
  • path The occluder used to generate the shadows.
  • z_plane_params Values for the plane function which returns the Z offset of the occluder from the canvas based on local x and y values (the current matrix is not applied).
  • light_pos Generally, the 3D position of the light relative to the canvas plane. If self::ShadowFlags::DIRECTIONAL_LIGHT is set, this specifies a vector pointing towards the light.
  • light_radius Generally, the radius of the disc light. If self::ShadowFlags::DIRECTIONAL_LIGHT is set, this specifies the amount of blur when the occluder is at Z offset == 1. The blur will grow linearly as the Z value increases.
  • ambient_color The color of the ambient shadow.
  • spot_color The color of the spot shadow.
  • flags Options controlling opaque occluder optimizations, shadow appearance, and light position. See self::ShadowFlags.