#[repr(C)]pub struct SdfVertex {
pub position: [f32; 2],
pub local_uv: [f32; 2],
pub color: [f32; 4],
pub corner_radii: [f32; 4],
pub shape_params: [f32; 4],
pub gradient_geo: [f32; 4],
pub gradient_color0: [f32; 4],
pub gradient_color1: [f32; 4],
pub gradient_color2: [f32; 4],
pub gradient_color3: [f32; 4],
pub gradient_offsets: [f32; 4],
}Expand description
Vertex for the SDF shape pipeline (rounded rects, circles).
Fields§
§position: [f32; 2]§local_uv: [f32; 2]Local UV coordinates (0..1) within the shape bounds.
color: [f32; 4]§corner_radii: [f32; 4]§shape_params: [f32; 4]Shape bounds in pixels: [width, height, stroke_width, paint_type]. paint_type: 0=solid, 1=linear, 2=radial, 3=conic
gradient_geo: [f32; 4]Gradient geometry: [start_x, start_y, end_x, end_y] (or center/radius for radial)
gradient_color0: [f32; 4]Gradient stop 0: [r, g, b, a]
gradient_color1: [f32; 4]Gradient stop 1: [r, g, b, a]
gradient_color2: [f32; 4]Gradient stop 2: [r, g, b, a]
gradient_color3: [f32; 4]Gradient stop 3: [r, g, b, a]
gradient_offsets: [f32; 4]Gradient stop offsets: [offset0, offset1, offset2, offset3]
Implementations§
Source§impl SdfVertex
impl SdfVertex
Sourcepub fn from_shape_quad(shape: &ShapeQuad, scale_factor: f32) -> [SdfVertex; 4]
pub fn from_shape_quad(shape: &ShapeQuad, scale_factor: f32) -> [SdfVertex; 4]
Convert a shape quad to 4 vertices with a logical stroke width — the border scales with the view transform (the default).
The rasterized quad is expanded outward by stroke_width / 2 + 1 on
every side. The SDF shader paints strokes centered on the rect
edge, so the outer half of the stroke falls outside the shape’s
bounds — if the quad isn’t padded, those fragments are never
rasterized and the stroke is visibly truncated by 1 dp on every
side (most noticeable on focus rings). local_uv is extrapolated
past [0, 1] for the padding fragments; the SDF still clips
correctly because sd_rounded_rect returns positive distances
outside the shape.
Sourcepub fn from_shape_quad_cosmetic(
shape: &ShapeQuad,
scale_factor: f32,
zoom: f32,
) -> [SdfVertex; 4]
pub fn from_shape_quad_cosmetic( shape: &ShapeQuad, scale_factor: f32, zoom: f32, ) -> [SdfVertex; 4]
Convert a shape quad to 4 vertices with a cosmetic stroke: the
border width is held constant in device pixels (width × scale_factor)
regardless of zoom, while the shape body still scales with the
transform. zoom is the uniform scale of the active view transform
(hypot(m[0], m[1])).
The shader measures the SDF in shape_params.xy = [w·sf, h·sf] units,
and one such unit maps to zoom device px on screen, so baking the
stroke param as width·sf / zoom lands the rendered border at exactly
width·sf device px at every zoom. Assumes a uniform (non-anisotropic)
transform — the scene zoom is uniform and rotation preserves the column
norm.
Trait Implementations§
impl Copy for SdfVertex
impl Pod for SdfVertex
Auto Trait Implementations§
impl Freeze for SdfVertex
impl RefUnwindSafe for SdfVertex
impl Send for SdfVertex
impl Sync for SdfVertex
impl Unpin for SdfVertex
impl UnsafeUnpin for SdfVertex
impl UnwindSafe for SdfVertex
Blanket Implementations§
impl<T> AnyBitPattern for Twhere
T: Pod,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CheckedBitPattern for Twhere
T: AnyBitPattern,
impl<T> CheckedBitPattern for Twhere
T: AnyBitPattern,
Source§type Bits = T
type Bits = T
Self must have the same layout as the specified Bits except for
the possible invalid bit patterns being checked during
is_valid_bit_pattern.Source§fn is_valid_bit_pattern(_bits: &T) -> bool
fn is_valid_bit_pattern(_bits: &T) -> bool
bits
as &Self.