Skip to content

Commit

Permalink
Add SkinTone enum
Browse files Browse the repository at this point in the history
  • Loading branch information
yuraiz committed Oct 28, 2022
1 parent 2cd62f1 commit 64b52e3
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 14 deletions.
2 changes: 1 addition & 1 deletion rlottie-sys/wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ struct Lottie_Animation_S {
uint32_t* mBufferRef;
};

LOT_EXPORT Lottie_Animation* lottie_animation_from_data_tg(const char* data, const char* key, const char* resourcePath, FitzModifier fitzModifier) {
LOT_EXPORT Lottie_Animation* lottie_animation_from_data_tg(const char* data, const char* key, const char* resourcePath, int fitzModifier) {
if (auto animation = Animation::loadFromData(data, key, resourcePath, true, {}, rlottie::FitzModifier(fitzModifier))) {
Lottie_Animation_S* handle = new Lottie_Animation_S();
handle->mAnimation = std::move(animation);
Expand Down
11 changes: 1 addition & 10 deletions rlottie-sys/wrapper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,7 @@
extern "C" {
#endif

enum class FitzModifier {
None,
Type12,
Type3,
Type4,
Type5,
Type6
};

LOT_EXPORT Lottie_Animation* lottie_animation_from_data_tg(const char* data, const char* key, const char* resource_path, FitzModifier fitz_modifier);
LOT_EXPORT Lottie_Animation* lottie_animation_from_data_tg(const char* data, const char* key, const char* resource_path, int fitz_modifier);

#ifdef __cplusplus
}
Expand Down
27 changes: 24 additions & 3 deletions rlottie/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,28 @@ use std::{
};

#[cfg(feature = "tg")]
pub use rlottie_sys::FitzModifier;
pub enum SkinTone {
None = 0,
Light,
MediumLight,
Medium,
MediumDark,
Dark
}

#[cfg(feature = "tg")]
impl SkinTone {
pub fn from_emoji_modifier(emoji_modifier: char) -> Self {
match emoji_modifier {
'\u{1F3FB}' => Self::Light,
'\u{1F3FC}' => Self::MediumLight,
'\u{1F3FD}' => Self::Medium,
'\u{1F3FE}' => Self::MediumDark,
'\u{1F3FF}' => Self::Dark,
_ => Self::None
}
}
}

pub type Bgra<T = u8> = BGRA<T>;
pub type Rgb<T = f64> = RGB<T>;
Expand Down Expand Up @@ -252,7 +273,7 @@ impl Animation {
json_data: D,
cache_key: K,
resource_path: P,
fitz_modifier: FitzModifier
skin_tone: SkinTone
) -> Option<Self>
where
D: Into<Vec<u8>>,
Expand All @@ -268,7 +289,7 @@ impl Animation {
json_data.as_ptr(),
cache_key.as_ptr(),
resource_path.as_ptr(),
fitz_modifier
skin_tone as i32
)
};
Self::from_ptr(ptr)
Expand Down

0 comments on commit 64b52e3

Please sign in to comment.