Add FillRule type
This commit is contained in:
38
src/types/fill_rule.rs
Normal file
38
src/types/fill_rule.rs
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
use crate::bindings;
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||||
|
#[repr(u32)]
|
||||||
|
pub enum FillRule {
|
||||||
|
Undefined = bindings::FillRule_UndefinedRule,
|
||||||
|
EvenOdd = bindings::FillRule_EvenOddRule,
|
||||||
|
NonZero = bindings::FillRule_NonZeroRule,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for FillRule {
|
||||||
|
fn default() -> Self {
|
||||||
|
return FillRule::Undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<FillRule> for bindings::FillRule {
|
||||||
|
fn from(value: FillRule) -> Self {
|
||||||
|
return value as bindings::FillRule;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<bindings::FillRule> for FillRule {
|
||||||
|
fn from(value: bindings::FillRule) -> Self {
|
||||||
|
/*
|
||||||
|
* SAFETY:
|
||||||
|
*
|
||||||
|
* `FillRule` has the same repr as `bindings::FillRule` - u32
|
||||||
|
*
|
||||||
|
* If `value` is less than NonZero than it is in the vaild range and can be safely
|
||||||
|
* reinterpreted as `FillRule`
|
||||||
|
*/
|
||||||
|
if value <= bindings::FillRule_NonZeroRule {
|
||||||
|
return unsafe { std::mem::transmute(value) };
|
||||||
|
}
|
||||||
|
return FillRule::default();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -5,6 +5,7 @@ mod compression_type;
|
|||||||
mod dispose_type;
|
mod dispose_type;
|
||||||
mod dither_method;
|
mod dither_method;
|
||||||
mod endian_type;
|
mod endian_type;
|
||||||
|
mod fill_rule;
|
||||||
mod filter_type;
|
mod filter_type;
|
||||||
mod gravity_type;
|
mod gravity_type;
|
||||||
mod image_type;
|
mod image_type;
|
||||||
@ -24,6 +25,7 @@ pub use self::compression_type::CompressionType;
|
|||||||
pub use self::dispose_type::DisposeType;
|
pub use self::dispose_type::DisposeType;
|
||||||
pub use self::dither_method::DitherMethod;
|
pub use self::dither_method::DitherMethod;
|
||||||
pub use self::endian_type::EndianType;
|
pub use self::endian_type::EndianType;
|
||||||
|
pub use self::fill_rule::FillRule;
|
||||||
pub use self::filter_type::FilterType;
|
pub use self::filter_type::FilterType;
|
||||||
pub use self::gravity_type::GravityType;
|
pub use self::gravity_type::GravityType;
|
||||||
pub use self::image_type::ImageType;
|
pub use self::image_type::ImageType;
|
||||||
|
|||||||
@ -20,7 +20,10 @@ use bindings;
|
|||||||
|
|
||||||
use crate::result::MagickError;
|
use crate::result::MagickError;
|
||||||
use crate::result::Result;
|
use crate::result::Result;
|
||||||
use crate::GravityType;
|
use crate::{
|
||||||
|
FillRule,
|
||||||
|
GravityType,
|
||||||
|
};
|
||||||
|
|
||||||
wand_common!(
|
wand_common!(
|
||||||
DrawingWand,
|
DrawingWand,
|
||||||
@ -89,9 +92,9 @@ impl DrawingWand {
|
|||||||
set_get_unchecked!(
|
set_get_unchecked!(
|
||||||
get_gravity, set_gravity, DrawGetGravity, DrawSetGravity, GravityType
|
get_gravity, set_gravity, DrawGetGravity, DrawSetGravity, GravityType
|
||||||
get_opacity, set_opacity, DrawGetOpacity, DrawSetOpacity, f64
|
get_opacity, set_opacity, DrawGetOpacity, DrawSetOpacity, f64
|
||||||
get_clip_rule, set_clip_rule, DrawGetClipRule, DrawSetClipRule, bindings::FillRule
|
get_clip_rule, set_clip_rule, DrawGetClipRule, DrawSetClipRule, FillRule
|
||||||
get_clip_units, set_clip_units, DrawGetClipUnits, DrawSetClipUnits, bindings::ClipPathUnits
|
get_clip_units, set_clip_units, DrawGetClipUnits, DrawSetClipUnits, bindings::ClipPathUnits
|
||||||
get_fill_rule, set_fill_rule, DrawGetFillRule, DrawSetFillRule, bindings::FillRule
|
get_fill_rule, set_fill_rule, DrawGetFillRule, DrawSetFillRule, FillRule
|
||||||
get_fill_opacity, set_fill_opacity, DrawGetFillOpacity, DrawSetFillOpacity, f64
|
get_fill_opacity, set_fill_opacity, DrawGetFillOpacity, DrawSetFillOpacity, f64
|
||||||
|
|
||||||
get_font_size, set_font_size, DrawGetFontSize, DrawSetFontSize, f64
|
get_font_size, set_font_size, DrawGetFontSize, DrawSetFontSize, f64
|
||||||
|
|||||||
Reference in New Issue
Block a user