Add LineCap type
This commit is contained in:
39
src/types/line_cap.rs
Normal file
39
src/types/line_cap.rs
Normal file
@ -0,0 +1,39 @@
|
||||
use crate::bindings;
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
#[repr(u32)]
|
||||
pub enum LineCap {
|
||||
Undefined = bindings::LineCap_UndefinedCap,
|
||||
Butt = bindings::LineCap_ButtCap,
|
||||
Round = bindings::LineCap_RoundCap,
|
||||
Square = bindings::LineCap_SquareCap,
|
||||
}
|
||||
|
||||
impl Default for LineCap {
|
||||
fn default() -> Self {
|
||||
return LineCap::Undefined;
|
||||
}
|
||||
}
|
||||
|
||||
impl From<LineCap> for bindings::LineCap {
|
||||
fn from(value: LineCap) -> Self {
|
||||
return value as bindings::LineCap;
|
||||
}
|
||||
}
|
||||
|
||||
impl From<bindings::LineCap> for LineCap {
|
||||
fn from(value: bindings::LineCap) -> Self {
|
||||
/*
|
||||
* SAFETY:
|
||||
*
|
||||
* `LineCap` has the same repr as `bindings::LineCap` - u32
|
||||
*
|
||||
* If `value` is less than Square than it is in the vaild range and can be safely
|
||||
* reinterpreted as `LineCap`
|
||||
*/
|
||||
if value <= bindings::LineCap_SquareCap {
|
||||
return unsafe { std::mem::transmute(value) };
|
||||
}
|
||||
return LineCap::default();
|
||||
}
|
||||
}
|
||||
@ -11,6 +11,7 @@ mod filter_type;
|
||||
mod gravity_type;
|
||||
mod image_type;
|
||||
mod interlace_type;
|
||||
mod line_cap;
|
||||
mod line_join;
|
||||
mod metric_type;
|
||||
mod orientation_type;
|
||||
@ -35,6 +36,7 @@ pub use self::filter_type::FilterType;
|
||||
pub use self::gravity_type::GravityType;
|
||||
pub use self::image_type::ImageType;
|
||||
pub use self::interlace_type::InterlaceType;
|
||||
pub use self::line_cap::LineCap;
|
||||
pub use self::line_join::LineJoin;
|
||||
pub use self::metric_type::MetricType;
|
||||
pub use self::orientation_type::OrientationType;
|
||||
|
||||
@ -24,6 +24,7 @@ use crate::{
|
||||
ClipPathUnits,
|
||||
FillRule,
|
||||
GravityType,
|
||||
LineCap,
|
||||
LineJoin,
|
||||
StretchType,
|
||||
StyleType,
|
||||
@ -107,7 +108,7 @@ impl DrawingWand {
|
||||
get_font_stretch, set_font_stretch, DrawGetFontStretch, DrawSetFontStretch, StretchType
|
||||
|
||||
get_stroke_dash_offset, set_stroke_dash_offset, DrawGetStrokeDashOffset, DrawSetStrokeDashOffset, f64
|
||||
get_stroke_line_cap, set_stroke_line_cap, DrawGetStrokeLineCap, DrawSetStrokeLineCap, bindings::LineCap
|
||||
get_stroke_line_cap, set_stroke_line_cap, DrawGetStrokeLineCap, DrawSetStrokeLineCap, LineCap
|
||||
get_stroke_line_join, set_stroke_line_join, DrawGetStrokeLineJoin, DrawSetStrokeLineJoin, LineJoin
|
||||
get_stroke_miter_limit, set_stroke_miter_limit, DrawGetStrokeMiterLimit, DrawSetStrokeMiterLimit, usize
|
||||
get_stroke_opacity, set_stroke_opacity, DrawGetStrokeOpacity, DrawSetStrokeOpacity, f64
|
||||
|
||||
Reference in New Issue
Block a user