Add ClipPathUnits and StyleType types
This commit is contained in:
39
src/types/clip_path_units.rs
Normal file
39
src/types/clip_path_units.rs
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
use crate::bindings;
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||||
|
#[repr(u32)]
|
||||||
|
pub enum ClipPathUnits {
|
||||||
|
Undefined = bindings::ClipPathUnits_UndefinedPathUnits,
|
||||||
|
UserSpace = bindings::ClipPathUnits_UserSpace,
|
||||||
|
UserSpaceOnUse = bindings::ClipPathUnits_UserSpaceOnUse,
|
||||||
|
ObjectBoundingBox = bindings::ClipPathUnits_ObjectBoundingBox,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for ClipPathUnits {
|
||||||
|
fn default() -> Self {
|
||||||
|
return ClipPathUnits::Undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<ClipPathUnits> for bindings::ClipPathUnits {
|
||||||
|
fn from(value: ClipPathUnits) -> Self {
|
||||||
|
return value as bindings::ClipPathUnits;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<bindings::ClipPathUnits> for ClipPathUnits {
|
||||||
|
fn from(value: bindings::ClipPathUnits) -> Self {
|
||||||
|
/*
|
||||||
|
* SAFETY:
|
||||||
|
*
|
||||||
|
* `ClipPathUnits` has the same repr as `bindings::ClipPathUnits` - u32
|
||||||
|
*
|
||||||
|
* If `value` is less than ObjectBoundingBox than it is in the vaild range and can be safely
|
||||||
|
* reinterpreted as `ClipPathUnits`
|
||||||
|
*/
|
||||||
|
if value <= bindings::ClipPathUnits_ObjectBoundingBox {
|
||||||
|
return unsafe { std::mem::transmute(value) };
|
||||||
|
}
|
||||||
|
return ClipPathUnits::default();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,4 +1,5 @@
|
|||||||
mod alpha_channel_option;
|
mod alpha_channel_option;
|
||||||
|
mod clip_path_units;
|
||||||
mod colorspace_type;
|
mod colorspace_type;
|
||||||
mod composite_operator;
|
mod composite_operator;
|
||||||
mod compression_type;
|
mod compression_type;
|
||||||
@ -17,8 +18,10 @@ mod rendering_intent;
|
|||||||
mod resolution_type;
|
mod resolution_type;
|
||||||
mod resource_type;
|
mod resource_type;
|
||||||
mod statistic_type;
|
mod statistic_type;
|
||||||
|
mod style_type;
|
||||||
|
|
||||||
pub use self::alpha_channel_option::AlphaChannelOption;
|
pub use self::alpha_channel_option::AlphaChannelOption;
|
||||||
|
pub use self::clip_path_units::ClipPathUnits;
|
||||||
pub use self::colorspace_type::ColorspaceType;
|
pub use self::colorspace_type::ColorspaceType;
|
||||||
pub use self::composite_operator::CompositeOperator;
|
pub use self::composite_operator::CompositeOperator;
|
||||||
pub use self::compression_type::CompressionType;
|
pub use self::compression_type::CompressionType;
|
||||||
@ -37,3 +40,4 @@ pub use self::rendering_intent::RenderingIntent;
|
|||||||
pub use self::resolution_type::ResolutionType;
|
pub use self::resolution_type::ResolutionType;
|
||||||
pub use self::resource_type::ResourceType;
|
pub use self::resource_type::ResourceType;
|
||||||
pub use self::statistic_type::StatisticType;
|
pub use self::statistic_type::StatisticType;
|
||||||
|
pub use self::style_type::StyleType;
|
||||||
|
|||||||
41
src/types/style_type.rs
Normal file
41
src/types/style_type.rs
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
use crate::bindings;
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||||
|
#[repr(u32)]
|
||||||
|
pub enum StyleType {
|
||||||
|
Undefined = bindings::StyleType_UndefinedStyle,
|
||||||
|
Normal = bindings::StyleType_NormalStyle,
|
||||||
|
Italic = bindings::StyleType_ItalicStyle,
|
||||||
|
Oblique = bindings::StyleType_ObliqueStyle,
|
||||||
|
Any = bindings::StyleType_AnyStyle,
|
||||||
|
Bold = bindings::StyleType_BoldStyle,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for StyleType {
|
||||||
|
fn default() -> Self {
|
||||||
|
return StyleType::Undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<StyleType> for bindings::StyleType {
|
||||||
|
fn from(value: StyleType) -> Self {
|
||||||
|
return value as bindings::StyleType;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<bindings::StyleType> for StyleType {
|
||||||
|
fn from(value: bindings::StyleType) -> Self {
|
||||||
|
/*
|
||||||
|
* SAFETY:
|
||||||
|
*
|
||||||
|
* `StyleType` has the same repr as `bindings::StyleType` - u32
|
||||||
|
*
|
||||||
|
* If `value` is less than Bold than it is in the vaild range and can be safely
|
||||||
|
* reinterpreted as `StyleType`
|
||||||
|
*/
|
||||||
|
if value <= bindings::StyleType_BoldStyle {
|
||||||
|
return unsafe { std::mem::transmute(value) };
|
||||||
|
}
|
||||||
|
return StyleType::default();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -21,8 +21,10 @@ use bindings;
|
|||||||
use crate::result::MagickError;
|
use crate::result::MagickError;
|
||||||
use crate::result::Result;
|
use crate::result::Result;
|
||||||
use crate::{
|
use crate::{
|
||||||
|
ClipPathUnits,
|
||||||
FillRule,
|
FillRule,
|
||||||
GravityType,
|
GravityType,
|
||||||
|
StyleType,
|
||||||
};
|
};
|
||||||
|
|
||||||
wand_common!(
|
wand_common!(
|
||||||
@ -93,12 +95,12 @@ impl DrawingWand {
|
|||||||
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, 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, ClipPathUnits
|
||||||
get_fill_rule, set_fill_rule, DrawGetFillRule, DrawSetFillRule, 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
|
||||||
get_font_style, set_font_style, DrawGetFontStyle, DrawSetFontStyle, bindings::StyleType
|
get_font_style, set_font_style, DrawGetFontStyle, DrawSetFontStyle, StyleType
|
||||||
get_font_weight, set_font_weight, DrawGetFontWeight, DrawSetFontWeight, usize
|
get_font_weight, set_font_weight, DrawGetFontWeight, DrawSetFontWeight, usize
|
||||||
get_font_stretch, set_font_stretch, DrawGetFontStretch, DrawSetFontStretch, bindings::StretchType
|
get_font_stretch, set_font_stretch, DrawGetFontStretch, DrawSetFontStretch, bindings::StretchType
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user