// Copyright (c) 2016-2018 Kiwano - Nomango // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. #pragma once #include namespace kiwano { KGE_DECLARE_SMART_PTR(KeyFrame); /** * \~chinese * @brief 关键帧 */ class KGE_API KeyFrame : public ObjectBase { public: KeyFrame(); /// \~chinese /// @brief 创建关键帧 /// @param file_path 图像路径 KeyFrame(const String& file_path); /// \~chinese /// @brief 创建关键帧 /// @param res 图像资源 KeyFrame(const Resource& res); /// \~chinese /// @brief 创建关键帧 /// @param texture 纹理 KeyFrame(TexturePtr texture); /// \~chinese /// @brief 创建关键帧 /// @param file_path 图像路径 /// @param crop_rect 裁剪矩形 KeyFrame(const String& file_path, const Rect& crop_rect); /// \~chinese /// @brief 创建关键帧 /// @param res 图像资源 /// @param crop_rect 裁剪矩形 KeyFrame(const Resource& res, const Rect& crop_rect); /// \~chinese /// @brief 创建关键帧 /// @param texture 纹理 /// @param crop_rect 裁剪矩形 KeyFrame(TexturePtr texture, const Rect& crop_rect); /// \~chinese /// @brief 加载图像 /// @param file_path 图像路径 bool Load(const String& file_path); /// \~chinese /// @brief 加载图像 /// @param res 图像资源 bool Load(const Resource& res); /// \~chinese /// @brief 是否有效 bool IsValid() const; /// \~chinese /// @brief 裁剪关键帧为矩形 /// @param crop_rect 裁剪矩形 void SetCropRect(const Rect& crop_rect); /// \~chinese /// @brief 设置纹理 /// @param texture 纹理 void SetTexture(TexturePtr texture); /// \~chinese /// @brief 获取裁剪矩形 const Rect& GetCropRect() const; /// \~chinese /// @brief 获取纹理 TexturePtr GetTexture() const; private: TexturePtr texture_; Rect crop_rect_; }; inline bool KeyFrame::IsValid() const { return texture_ && texture_->IsValid(); } inline const Rect& KeyFrame::GetCropRect() const { return crop_rect_; } inline TexturePtr KeyFrame::GetTexture() const { return texture_; } } // namespace kiwano