Add DecorationType type

This commit is contained in:
5ohue
2024-05-11 22:04:49 +03:00
parent dc80d78ce2
commit d8d6a12d02
3 changed files with 44 additions and 1 deletions

View File

@ -0,0 +1,40 @@
use crate::bindings;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[repr(u32)]
pub enum DecorationType {
Undefined = bindings::DecorationType_UndefinedDecoration,
No = bindings::DecorationType_NoDecoration,
Underline = bindings::DecorationType_UnderlineDecoration,
Overline = bindings::DecorationType_OverlineDecoration,
LineThrough = bindings::DecorationType_LineThroughDecoration,
}
impl Default for DecorationType {
fn default() -> Self {
return DecorationType::Undefined;
}
}
impl From<DecorationType> for bindings::DecorationType {
fn from(value: DecorationType) -> Self {
return value as bindings::DecorationType;
}
}
impl From<bindings::DecorationType> for DecorationType {
fn from(value: bindings::DecorationType) -> Self {
/*
* SAFETY:
*
* `DecorationType` has the same repr as `bindings::DecorationType` - u32
*
* If `value` is less than LineThrough than it is in the vaild range and can be safely
* reinterpreted as `DecorationType`
*/
if value <= bindings::DecorationType_LineThroughDecoration {
return unsafe { std::mem::transmute(value) };
}
return DecorationType::default();
}
}

View File

@ -4,6 +4,7 @@ mod clip_path_units;
mod colorspace_type;
mod composite_operator;
mod compression_type;
mod decoration_type;
mod dispose_type;
mod dither_method;
mod endian_type;
@ -30,6 +31,7 @@ pub use self::clip_path_units::ClipPathUnits;
pub use self::colorspace_type::ColorspaceType;
pub use self::composite_operator::CompositeOperator;
pub use self::compression_type::CompressionType;
pub use self::decoration_type::DecorationType;
pub use self::dispose_type::DisposeType;
pub use self::dither_method::DitherMethod;
pub use self::endian_type::EndianType;

View File

@ -23,6 +23,7 @@ use crate::result::Result;
use crate::{
AlignType,
ClipPathUnits,
DecorationType,
FillRule,
GravityType,
LineCap,
@ -118,7 +119,7 @@ impl DrawingWand {
get_text_alignment, set_text_alignment, DrawGetTextAlignment, DrawSetTextAlignment, AlignType
get_text_antialias, set_text_antialias, DrawGetTextAntialias, DrawSetTextAntialias, bindings::MagickBooleanType
get_text_decoration, set_text_decoration, DrawGetTextDecoration, DrawSetTextDecoration, bindings::DecorationType
get_text_decoration, set_text_decoration, DrawGetTextDecoration, DrawSetTextDecoration, DecorationType
get_text_direction, set_text_direction, DrawGetTextDirection, DrawSetTextDirection, bindings::DirectionType
get_text_kerning, set_text_kerning, DrawGetTextKerning, DrawSetTextKerning, f64
get_text_interline_spacing, set_text_interline_spacing, DrawGetTextInterlineSpacing, DrawSetTextInterlineSpacing, f64