add: Transform
This commit is contained in:
		
							parent
							
								
									909a72b189
								
							
						
					
					
						commit
						4d9649eedf
					
				|  | @ -46,7 +46,7 @@ void e2d::JumpBy::Update() | ||||||
| 		start_pos_ = diff + start_pos_; | 		start_pos_ = diff + start_pos_; | ||||||
| 
 | 
 | ||||||
| 		Point newPos = start_pos_ + Point(x, y); | 		Point newPos = start_pos_ + Point(x, y); | ||||||
| 		target_->SetPos(newPos); | 		target_->SetPosition(newPos); | ||||||
| 
 | 
 | ||||||
| 		prev_pos_ = newPos; | 		prev_pos_ = newPos; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | @ -29,7 +29,7 @@ void e2d::MoveBy::Update() | ||||||
| 		start_pos_ = start_pos_ + diff; | 		start_pos_ = start_pos_ + diff; | ||||||
| 
 | 
 | ||||||
| 		Point newPos = start_pos_ + (delta_pos_ * delta_); | 		Point newPos = start_pos_ + (delta_pos_ * delta_); | ||||||
| 		target_->SetPos(newPos); | 		target_->SetPosition(newPos); | ||||||
| 
 | 
 | ||||||
| 		prev_pos_ = newPos; | 		prev_pos_ = newPos; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | @ -171,7 +171,7 @@ bool e2d::Button::Dispatch(const MouseEvent & e, bool handled) | ||||||
| 		{ | 		{ | ||||||
| 			is_selected_ = false; | 			is_selected_ = false; | ||||||
| 		} | 		} | ||||||
| 		else if (e.GetType() == MouseEvent::Type::Move && is_selected_ && contains) | 		else if (e.GetType() == MouseEvent::Type::MoveBy && is_selected_ && contains) | ||||||
| 		{ | 		{ | ||||||
| 			SetStatus(Status::Selected); | 			SetStatus(Status::Selected); | ||||||
| 			return true; | 			return true; | ||||||
|  |  | ||||||
|  | @ -70,7 +70,7 @@ namespace e2d | ||||||
| 			const Function& func | 			const Function& func | ||||||
| 		); | 		); | ||||||
| 
 | 
 | ||||||
| 		// 设置锚点位置
 | 		// 设置支点位置
 | ||||||
| 		// 默认为 (0, 0), 范围 [0, 1]
 | 		// 默认为 (0, 0), 范围 [0, 1]
 | ||||||
| 		virtual void SetAnchor( | 		virtual void SetAnchor( | ||||||
| 			float anchor_x, | 			float anchor_x, | ||||||
|  |  | ||||||
|  | @ -46,7 +46,7 @@ namespace e2d | ||||||
| 		// 報炎<E5A0B1>連窃侏
 | 		// 報炎<E5A0B1>連窃侏
 | ||||||
| 		enum class Type : int | 		enum class Type : int | ||||||
| 		{ | 		{ | ||||||
| 			Move = 0x0200,		// 鼠标移动
 | 			MoveBy = 0x0200,		// 鼠标移动
 | ||||||
| 			LeftDown,			// 報炎恣囚梓和
 | 			LeftDown,			// 報炎恣囚梓和
 | ||||||
| 			LeftUp,				// 報炎恣囚箕軟
 | 			LeftUp,				// 報炎恣囚箕軟
 | ||||||
| 			LeftDoubleClick,	// 報炎恣囚褒似
 | 			LeftDoubleClick,	// 報炎恣囚褒似
 | ||||||
|  |  | ||||||
							
								
								
									
										103
									
								
								core/e2dobject.h
								
								
								
								
							
							
						
						
									
										103
									
								
								core/e2dobject.h
								
								
								
								
							|  | @ -50,31 +50,34 @@ namespace e2d | ||||||
| 		); | 		); | ||||||
| 
 | 
 | ||||||
| 		// 获取宽度
 | 		// 获取宽度
 | ||||||
| 		virtual float GetWidth() const; | 		float GetWidth() const; | ||||||
| 
 | 
 | ||||||
| 		// 获取高度
 | 		// 获取高度
 | ||||||
| 		virtual float GetHeight() const; | 		float GetHeight() const; | ||||||
| 
 | 
 | ||||||
| 		// 获取大小
 | 		// 获取大小
 | ||||||
| 		virtual Size GetSize() const; | 		Size GetSize() const; | ||||||
| 
 | 
 | ||||||
| 		// 获取源图片宽度
 | 		// 获取源图片宽度
 | ||||||
| 		virtual float GetSourceWidth() const; | 		float GetSourceWidth() const; | ||||||
| 
 | 
 | ||||||
| 		// 获取源图片高度
 | 		// 获取源图片高度
 | ||||||
| 		virtual float GetSourceHeight() const; | 		float GetSourceHeight() const; | ||||||
| 
 | 
 | ||||||
| 		// 获取源图片大小
 | 		// 获取源图片大小
 | ||||||
| 		virtual Size GetSourceSize() const; | 		Size GetSourceSize() const; | ||||||
| 
 | 
 | ||||||
| 		// 获取裁剪位置 X 坐标
 | 		// 获取裁剪位置 X 坐标
 | ||||||
| 		virtual float GetCropX() const; | 		float GetCropX() const; | ||||||
| 
 | 
 | ||||||
| 		// 获取裁剪位置 Y 坐标
 | 		// 获取裁剪位置 Y 坐标
 | ||||||
| 		virtual float GetCropY() const; | 		float GetCropY() const; | ||||||
| 
 | 
 | ||||||
| 		// 获取裁剪位置
 | 		// 获取裁剪位置
 | ||||||
| 		virtual Point GetCropPos() const; | 		Point GetCropPos() const; | ||||||
|  | 
 | ||||||
|  | 		// 获取裁剪矩形
 | ||||||
|  | 		const Rect& GetCropRect() const; | ||||||
| 
 | 
 | ||||||
| 		// 获取 ID2D1Bitmap 对象
 | 		// 获取 ID2D1Bitmap 对象
 | ||||||
| 		ID2D1Bitmap * GetBitmap(); | 		ID2D1Bitmap * GetBitmap(); | ||||||
|  | @ -419,23 +422,6 @@ namespace e2d | ||||||
| 		friend class Scene; | 		friend class Scene; | ||||||
| 		friend class Collider; | 		friend class Collider; | ||||||
| 
 | 
 | ||||||
| 	public: |  | ||||||
| 		// 节点属性
 |  | ||||||
| 		struct Property |  | ||||||
| 		{ |  | ||||||
| 			Point pos;			// 坐标
 |  | ||||||
| 			Size size;			// 大小
 |  | ||||||
| 			Point anchor;		// 锚点坐标
 |  | ||||||
| 			Point scale;		// 缩放
 |  | ||||||
| 			Point skew;			// 倾斜角度
 |  | ||||||
| 			float rotation;		// 旋转角度
 |  | ||||||
| 
 |  | ||||||
| 			Property operator+ (Property const & prop) const; |  | ||||||
| 			Property operator- (Property const & prop) const; |  | ||||||
| 
 |  | ||||||
| 			static const Property Origin; |  | ||||||
| 		}; |  | ||||||
| 
 |  | ||||||
| 	public: | 	public: | ||||||
| 		typedef std::vector<Node*> Nodes; | 		typedef std::vector<Node*> Nodes; | ||||||
| 		typedef std::vector<Action*> Actions; | 		typedef std::vector<Action*> Actions; | ||||||
|  | @ -481,10 +467,10 @@ namespace e2d | ||||||
| 		// 获取节点大小(不考虑缩放)
 | 		// 获取节点大小(不考虑缩放)
 | ||||||
| 		const Size& GetRealSize() const; | 		const Size& GetRealSize() const; | ||||||
| 
 | 
 | ||||||
| 		// 获取节点的锚点
 | 		// 获取节点的支点
 | ||||||
| 		float GetAnchorX() const; | 		float GetAnchorX() const; | ||||||
| 
 | 
 | ||||||
| 		// 获取节点的锚点
 | 		// 获取节点的支点
 | ||||||
| 		float GetAnchorY() const; | 		float GetAnchorY() const; | ||||||
| 
 | 
 | ||||||
| 		// 获取节点大小
 | 		// 获取节点大小
 | ||||||
|  | @ -505,15 +491,12 @@ namespace e2d | ||||||
| 		// 获取节点旋转角度
 | 		// 获取节点旋转角度
 | ||||||
| 		float GetRotation() const; | 		float GetRotation() const; | ||||||
| 
 | 
 | ||||||
|  | 		// 获取二维转换
 | ||||||
|  | 		const Transform& GetTransform() const; | ||||||
|  | 
 | ||||||
| 		// 获取节点透明度
 | 		// 获取节点透明度
 | ||||||
| 		float GetOpacity() const; | 		float GetOpacity() const; | ||||||
| 
 | 
 | ||||||
| 		// 获取节点属性
 |  | ||||||
| 		Property GetProperty() const; |  | ||||||
| 
 |  | ||||||
| 		// 获取差别属性
 |  | ||||||
| 		Property GetExtrapolate() const; |  | ||||||
| 
 |  | ||||||
| 		// 获取节点碰撞体
 | 		// 获取节点碰撞体
 | ||||||
| 		Collider * GetCollider(); | 		Collider * GetCollider(); | ||||||
| 
 | 
 | ||||||
|  | @ -534,40 +517,35 @@ namespace e2d | ||||||
| 		); | 		); | ||||||
| 
 | 
 | ||||||
| 		// 设置节点横坐标
 | 		// 设置节点横坐标
 | ||||||
| 		virtual void SetPosX( | 		virtual void SetPositionX( | ||||||
| 			float x | 			float x | ||||||
| 		); | 		); | ||||||
| 
 | 
 | ||||||
| 		// 设置节点纵坐标
 | 		// 设置节点纵坐标
 | ||||||
| 		virtual void SetPosY( | 		virtual void SetPositionY( | ||||||
| 			float y | 			float y | ||||||
| 		); | 		); | ||||||
| 
 | 
 | ||||||
| 		// 设置节点坐标
 | 		// 设置节点坐标
 | ||||||
| 		virtual void SetPos( | 		virtual void SetPosition( | ||||||
| 			const Point & point | 			const Point & point | ||||||
| 		); | 		); | ||||||
| 
 | 
 | ||||||
| 		// 设置节点坐标
 | 		// 设置节点坐标
 | ||||||
| 		virtual void SetPos( | 		virtual void SetPosition( | ||||||
| 			float x, |  | ||||||
| 			float y |  | ||||||
| 		); |  | ||||||
| 
 |  | ||||||
| 		// 节点坐标固定
 |  | ||||||
| 		virtual void SetPosFixed( |  | ||||||
| 			bool fixed |  | ||||||
| 		); |  | ||||||
| 
 |  | ||||||
| 		// 移动节点
 |  | ||||||
| 		virtual void Move( |  | ||||||
| 			float x, | 			float x, | ||||||
| 			float y | 			float y | ||||||
| 		); | 		); | ||||||
| 
 | 
 | ||||||
| 		// 移动节点
 | 		// 移动节点
 | ||||||
| 		virtual void Move( | 		virtual void MoveBy( | ||||||
| 			const Point & v | 			float x, | ||||||
|  | 			float y | ||||||
|  | 		); | ||||||
|  | 
 | ||||||
|  | 		// 移动节点
 | ||||||
|  | 		virtual void MoveBy( | ||||||
|  | 			const Point & vector | ||||||
| 		); | 		); | ||||||
| 
 | 
 | ||||||
| 		// 设置节点绘图顺序
 | 		// 设置节点绘图顺序
 | ||||||
|  | @ -632,19 +610,19 @@ namespace e2d | ||||||
| 			float opacity | 			float opacity | ||||||
| 		); | 		); | ||||||
| 
 | 
 | ||||||
| 		// 设置锚点的横向位置
 | 		// 设置支点的横向位置
 | ||||||
| 		// 默认为 0, 范围 [0, 1]
 | 		// 默认为 0, 范围 [0, 1]
 | ||||||
| 		virtual void SetAnchorX( | 		virtual void SetAnchorX( | ||||||
| 			float anchor_x | 			float anchor_x | ||||||
| 		); | 		); | ||||||
| 
 | 
 | ||||||
| 		// 设置锚点的纵向位置
 | 		// 设置支点的纵向位置
 | ||||||
| 		// 默认为 0, 范围 [0, 1]
 | 		// 默认为 0, 范围 [0, 1]
 | ||||||
| 		virtual void SetAnchorY( | 		virtual void SetAnchorY( | ||||||
| 			float anchor_y | 			float anchor_y | ||||||
| 		); | 		); | ||||||
| 
 | 
 | ||||||
| 		// 设置锚点位置
 | 		// 设置支点位置
 | ||||||
| 		// 默认为 (0, 0), 范围 [0, 1]
 | 		// 默认为 (0, 0), 范围 [0, 1]
 | ||||||
| 		virtual void SetAnchor( | 		virtual void SetAnchor( | ||||||
| 			float anchor_x, | 			float anchor_x, | ||||||
|  | @ -669,12 +647,12 @@ namespace e2d | ||||||
| 
 | 
 | ||||||
| 		// 修改节点大小
 | 		// 修改节点大小
 | ||||||
| 		virtual void SetSize( | 		virtual void SetSize( | ||||||
| 			Size size | 			const Size & size | ||||||
| 		); | 		); | ||||||
| 
 | 
 | ||||||
| 		// 设置节点属性
 | 		// 设置二维转换
 | ||||||
| 		virtual void SetProperty( | 		virtual void SetTransform( | ||||||
| 			Property prop | 			const Transform& transform | ||||||
| 		); | 		); | ||||||
| 
 | 
 | ||||||
| 		// 启用或关闭渲染区域裁剪
 | 		// 启用或关闭渲染区域裁剪
 | ||||||
|  | @ -852,12 +830,7 @@ namespace e2d | ||||||
| 	protected: | 	protected: | ||||||
| 		String		name_; | 		String		name_; | ||||||
| 		size_t		hash_name_; | 		size_t		hash_name_; | ||||||
| 		Point		pos_; | 		Transform	transform_; | ||||||
| 		Size		size_; |  | ||||||
| 		Point		scale_; |  | ||||||
| 		Point		anchor_; |  | ||||||
| 		Point		skew_; |  | ||||||
| 		float		rotation_; |  | ||||||
| 		float		display_opacity_; | 		float		display_opacity_; | ||||||
| 		float		real_opacity_; | 		float		real_opacity_; | ||||||
| 		int			order_; | 		int			order_; | ||||||
|  | @ -865,11 +838,9 @@ namespace e2d | ||||||
| 		bool		clip_enabled_; | 		bool		clip_enabled_; | ||||||
| 		bool		dirty_sort_; | 		bool		dirty_sort_; | ||||||
| 		bool		dirty_transform_; | 		bool		dirty_transform_; | ||||||
| 		bool		fixed_position_; |  | ||||||
| 		Collider	collider_; | 		Collider	collider_; | ||||||
| 		Scene *		parent_scene_; | 		Scene *		parent_scene_; | ||||||
| 		Node *		parent_; | 		Node *		parent_; | ||||||
| 		Property	extrapolate_; |  | ||||||
| 		Color		border_color_; | 		Color		border_color_; | ||||||
| 		Actions		actions_; | 		Actions		actions_; | ||||||
| 		Tasks		tasks_; | 		Tasks		tasks_; | ||||||
|  |  | ||||||
|  | @ -601,6 +601,29 @@ namespace e2d | ||||||
| 	}; | 	}; | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | 	// 二维转换
 | ||||||
|  | 	class Transform | ||||||
|  | 	{ | ||||||
|  | 	public: | ||||||
|  | 		Transform(); | ||||||
|  | 
 | ||||||
|  | 		E2D_OP_EXPLICIT operator D2D1::Matrix3x2F() const; | ||||||
|  | 
 | ||||||
|  | 		bool operator== (const Transform& other) const; | ||||||
|  | 
 | ||||||
|  | 	public: | ||||||
|  | 		Point position;		// 坐标
 | ||||||
|  | 		Size size;			// 大小
 | ||||||
|  | 		float scale_x;		// 横向缩放
 | ||||||
|  | 		float scale_y;		// 纵向缩放
 | ||||||
|  | 		float rotation;		// 旋转
 | ||||||
|  | 		float skew_x;		// 横向倾斜角度
 | ||||||
|  | 		float skew_y;		// 纵向倾斜角度
 | ||||||
|  | 		float pivot_x;		// 支点横坐标
 | ||||||
|  | 		float pivot_y;		// 支点纵坐标
 | ||||||
|  | 	}; | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
| 	// 引用计数对象
 | 	// 引用计数对象
 | ||||||
| 	class Ref | 	class Ref | ||||||
| 	{ | 	{ | ||||||
|  |  | ||||||
|  | @ -78,10 +78,11 @@ void e2d::Image::Crop(const Rect& crop_rect) | ||||||
| { | { | ||||||
| 	if (bitmap_) | 	if (bitmap_) | ||||||
| 	{ | 	{ | ||||||
| 		crop_rect_.origin.x = std::min(std::max(crop_rect.origin.x, 0.f), this->GetSourceWidth()); | 		auto bitmap_size = bitmap_->GetSize(); | ||||||
| 		crop_rect_.origin.y = std::min(std::max(crop_rect.origin.y, 0.f), this->GetSourceHeight()); | 		crop_rect_.origin.x = std::min(std::max(crop_rect.origin.x, 0.f), bitmap_size.width); | ||||||
| 		crop_rect_.size.width = std::min(std::max(crop_rect.size.width, 0.f), this->GetSourceWidth() - crop_rect.origin.x); | 		crop_rect_.origin.y = std::min(std::max(crop_rect.origin.y, 0.f), bitmap_size.height); | ||||||
| 		crop_rect_.size.height = std::min(std::max(crop_rect.size.height, 0.f), this->GetSourceHeight() - crop_rect.origin.y); | 		crop_rect_.size.width = std::min(std::max(crop_rect.size.width, 0.f), bitmap_size.width - crop_rect.origin.x); | ||||||
|  | 		crop_rect_.size.height = std::min(std::max(crop_rect.size.height, 0.f), bitmap_size.height - crop_rect.origin.y); | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | @ -126,14 +127,14 @@ float e2d::Image::GetSourceHeight() const | ||||||
| 
 | 
 | ||||||
| e2d::Size e2d::Image::GetSourceSize() const | e2d::Size e2d::Image::GetSourceSize() const | ||||||
| { | { | ||||||
|  | 	Size source_size; | ||||||
| 	if (bitmap_) | 	if (bitmap_) | ||||||
| 	{ | 	{ | ||||||
| 		return Size(GetSourceWidth(), GetSourceHeight()); | 		auto bitmap_size = bitmap_->GetSize(); | ||||||
| 	} | 		source_size.width = bitmap_size.width; | ||||||
| 	else | 		source_size.height = bitmap_size.height; | ||||||
| 	{ |  | ||||||
| 		return Size(); |  | ||||||
| 	} | 	} | ||||||
|  | 	return std::move(source_size); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| float e2d::Image::GetCropX() const | float e2d::Image::GetCropX() const | ||||||
|  | @ -151,6 +152,11 @@ e2d::Point e2d::Image::GetCropPos() const | ||||||
| 	return crop_rect_.origin; | 	return crop_rect_.origin; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | const e2d::Rect & e2d::Image::GetCropRect() const | ||||||
|  | { | ||||||
|  | 	return crop_rect_; | ||||||
|  | } | ||||||
|  | 
 | ||||||
| bool e2d::Image::Preload(const Resource& res) | bool e2d::Image::Preload(const Resource& res) | ||||||
| { | { | ||||||
| 	if (bitmap_cache_.find(res.id) != bitmap_cache_.end()) | 	if (bitmap_cache_.find(res.id) != bitmap_cache_.end()) | ||||||
|  |  | ||||||
|  | @ -3,32 +3,6 @@ | ||||||
| #include "..\e2dmanager.h" | #include "..\e2dmanager.h" | ||||||
| #include "..\e2daction.h" | #include "..\e2daction.h" | ||||||
| 
 | 
 | ||||||
| const e2d::Node::Property e2d::Node::Property::Origin = { }; |  | ||||||
| 
 |  | ||||||
| e2d::Node::Property e2d::Node::Property::operator+(Property const & prop) const |  | ||||||
| { |  | ||||||
| 	Property result; |  | ||||||
| 	result.pos = this->pos + prop.pos; |  | ||||||
| 	result.size = this->size + prop.size; |  | ||||||
| 	result.anchor = this->anchor + prop.anchor; |  | ||||||
| 	result.scale = this->scale + prop.scale; |  | ||||||
| 	result.skew = this->skew + prop.skew; |  | ||||||
| 	result.rotation = this->rotation + prop.rotation; |  | ||||||
| 	return std::move(result); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| e2d::Node::Property e2d::Node::Property::operator-(Property const & prop) const |  | ||||||
| { |  | ||||||
| 	Property result; |  | ||||||
| 	result.pos = this->pos - prop.pos; |  | ||||||
| 	result.size = this->size - prop.size; |  | ||||||
| 	result.anchor = this->anchor - prop.anchor; |  | ||||||
| 	result.scale = this->scale - prop.scale; |  | ||||||
| 	result.skew = this->skew - prop.skew; |  | ||||||
| 	result.rotation = this->rotation - prop.rotation; |  | ||||||
| 	return std::move(result); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| 
 | 
 | ||||||
| e2d::Node::Node() | e2d::Node::Node() | ||||||
| 	: visible_(true) | 	: visible_(true) | ||||||
|  | @ -38,25 +12,18 @@ e2d::Node::Node() | ||||||
| 	, clip_enabled_(false) | 	, clip_enabled_(false) | ||||||
| 	, dirty_sort_(false) | 	, dirty_sort_(false) | ||||||
| 	, dirty_transform_(false) | 	, dirty_transform_(false) | ||||||
| 	, fixed_position_(false) |  | ||||||
| 	, collider_(this) | 	, collider_(this) | ||||||
| 	, border_(nullptr) | 	, border_(nullptr) | ||||||
| 	, order_(0) | 	, order_(0) | ||||||
| 	, pos_() | 	, transform_() | ||||||
| 	, size_() |  | ||||||
| 	, scale_(1.f, 1.f) |  | ||||||
| 	, rotation_(0) |  | ||||||
| 	, skew_(0, 0) |  | ||||||
| 	, display_opacity_(1.f) | 	, display_opacity_(1.f) | ||||||
| 	, real_opacity_(1.f) | 	, real_opacity_(1.f) | ||||||
| 	, anchor_() |  | ||||||
| 	, children_() | 	, children_() | ||||||
| 	, actions_() | 	, actions_() | ||||||
| 	, tasks_() | 	, tasks_() | ||||||
| 	, initial_matrix_(D2D1::Matrix3x2F::Identity()) | 	, initial_matrix_(D2D1::Matrix3x2F::Identity()) | ||||||
| 	, final_matrix_(D2D1::Matrix3x2F::Identity()) | 	, final_matrix_(D2D1::Matrix3x2F::Identity()) | ||||||
| 	, border_color_(Color::Red, 0.6f) | 	, border_color_(Color::Red, 0.6f) | ||||||
| 	, extrapolate_(Property::Origin) |  | ||||||
| { | { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | @ -98,14 +65,13 @@ void e2d::Node::Visit() | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	UpdateTransform(); | 	UpdateTransform(); | ||||||
| 	extrapolate_ = this->GetProperty(); |  | ||||||
| 
 | 
 | ||||||
| 	auto render_target = Renderer::GetInstance()->GetRenderTarget(); | 	auto render_target = Renderer::GetInstance()->GetRenderTarget(); | ||||||
| 	if (clip_enabled_) | 	if (clip_enabled_) | ||||||
| 	{ | 	{ | ||||||
| 		render_target->SetTransform(final_matrix_); | 		render_target->SetTransform(final_matrix_); | ||||||
| 		render_target->PushAxisAlignedClip( | 		render_target->PushAxisAlignedClip( | ||||||
| 			D2D1::RectF(0, 0, size_.width, size_.height), | 			D2D1::RectF(0, 0, transform_.size.width, transform_.size.height), | ||||||
| 			D2D1_ANTIALIAS_MODE_PER_PRIMITIVE | 			D2D1_ANTIALIAS_MODE_PER_PRIMITIVE | ||||||
| 		); | 		); | ||||||
| 	} | 	} | ||||||
|  | @ -209,34 +175,19 @@ void e2d::Node::UpdateTransform() | ||||||
| 
 | 
 | ||||||
| 	dirty_transform_ = false; | 	dirty_transform_ = false; | ||||||
| 
 | 
 | ||||||
| 	// 计算锚点坐标
 | 	final_matrix_ = static_cast<D2D1::Matrix3x2F>(transform_); | ||||||
| 	D2D1_POINT_2F anchor = { size_.width * anchor_.x, size_.height * anchor_.y }; | 
 | ||||||
| 	// 变换 Initial 矩阵,子节点将根据这个矩阵进行变换
 | 	// 根据自身支点计算 Initial 矩阵,子节点将根据这个矩阵进行变换
 | ||||||
| 	initial_matrix_ = D2D1::Matrix3x2F::Scale( | 	auto pivot = Point( | ||||||
| 		scale_.x, | 		transform_.size.width * transform_.pivot_x, | ||||||
| 		scale_.y, | 		transform_.size.height * transform_.pivot_y | ||||||
| 		anchor |  | ||||||
| 	) * D2D1::Matrix3x2F::Skew( |  | ||||||
| 		skew_.x, |  | ||||||
| 		skew_.y, |  | ||||||
| 		anchor |  | ||||||
| 	) * D2D1::Matrix3x2F::Rotation( |  | ||||||
| 		rotation_, |  | ||||||
| 		anchor |  | ||||||
| 	) * D2D1::Matrix3x2F::Translation( |  | ||||||
| 		pos_.x, |  | ||||||
| 		pos_.y |  | ||||||
| 	); | 	); | ||||||
| 	// 根据自身锚点变换 Final 矩阵
 | 	initial_matrix_ = final_matrix_ * D2D1::Matrix3x2F::Translation(pivot.x, pivot.y); | ||||||
| 	final_matrix_ = initial_matrix_ * D2D1::Matrix3x2F::Translation(-anchor.x, -anchor.y); |  | ||||||
| 
 | 
 | ||||||
| 	if (parent_) | 	if (parent_) | ||||||
| 	{ | 	{ | ||||||
| 		if (!fixed_position_) | 		initial_matrix_ = initial_matrix_ * parent_->initial_matrix_; | ||||||
| 		{ | 		final_matrix_ = final_matrix_ * parent_->initial_matrix_; | ||||||
| 			initial_matrix_ = initial_matrix_ * parent_->initial_matrix_; |  | ||||||
| 			final_matrix_ = final_matrix_ * parent_->initial_matrix_; |  | ||||||
| 		} |  | ||||||
| 	} | 	} | ||||||
| 	else if (parent_scene_) | 	else if (parent_scene_) | ||||||
| 	{ | 	{ | ||||||
|  | @ -252,7 +203,7 @@ void e2d::Node::UpdateTransform() | ||||||
| 	ID2D1TransformedGeometry * transformed = nullptr; | 	ID2D1TransformedGeometry * transformed = nullptr; | ||||||
| 	ThrowIfFailed( | 	ThrowIfFailed( | ||||||
| 		factory->CreateRectangleGeometry( | 		factory->CreateRectangleGeometry( | ||||||
| 			D2D1::RectF(0, 0, size_.width, size_.height), | 			D2D1::RectF(0, 0, transform_.size.width, transform_.size.height), | ||||||
| 			&rectangle | 			&rectangle | ||||||
| 		) | 		) | ||||||
| 	); | 	); | ||||||
|  | @ -376,82 +327,87 @@ size_t e2d::Node::GetHashName() const | ||||||
| 
 | 
 | ||||||
| float e2d::Node::GetPosX() const | float e2d::Node::GetPosX() const | ||||||
| { | { | ||||||
| 	return pos_.x; | 	return transform_.position.x; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| float e2d::Node::GetPosY() const | float e2d::Node::GetPosY() const | ||||||
| { | { | ||||||
| 	return pos_.y; | 	return transform_.position.y; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| const e2d::Point& e2d::Node::GetPos() const | const e2d::Point& e2d::Node::GetPos() const | ||||||
| { | { | ||||||
| 	return pos_; | 	return transform_.position; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| float e2d::Node::GetWidth() const | float e2d::Node::GetWidth() const | ||||||
| { | { | ||||||
| 	return size_.width * scale_.x; | 	return transform_.size.width * transform_.scale_x; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| float e2d::Node::GetHeight() const | float e2d::Node::GetHeight() const | ||||||
| { | { | ||||||
| 	return size_.height * scale_.y; | 	return transform_.size.height * transform_.scale_y; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| float e2d::Node::GetRealWidth() const | float e2d::Node::GetRealWidth() const | ||||||
| { | { | ||||||
| 	return size_.width; | 	return transform_.size.width; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| float e2d::Node::GetRealHeight() const | float e2d::Node::GetRealHeight() const | ||||||
| { | { | ||||||
| 	return size_.height; | 	return transform_.size.height; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| const e2d::Size& e2d::Node::GetRealSize() const | const e2d::Size& e2d::Node::GetRealSize() const | ||||||
| { | { | ||||||
| 	return size_; | 	return transform_.size; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| float e2d::Node::GetAnchorX() const | float e2d::Node::GetAnchorX() const | ||||||
| { | { | ||||||
| 	return anchor_.x; | 	return transform_.pivot_x; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| float e2d::Node::GetAnchorY() const | float e2d::Node::GetAnchorY() const | ||||||
| { | { | ||||||
| 	return anchor_.y; | 	return transform_.pivot_y; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| e2d::Size e2d::Node::GetSize() const | e2d::Size e2d::Node::GetSize() const | ||||||
| { | { | ||||||
| 	return Size(GetWidth(), GetHeight()); | 	return std::move(Size(GetWidth(), GetHeight())); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| float e2d::Node::GetScaleX() const | float e2d::Node::GetScaleX() const | ||||||
| { | { | ||||||
| 	return scale_.x; | 	return transform_.scale_x; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| float e2d::Node::GetScaleY() const | float e2d::Node::GetScaleY() const | ||||||
| { | { | ||||||
| 	return scale_.y; | 	return transform_.scale_y; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| float e2d::Node::GetSkewX() const | float e2d::Node::GetSkewX() const | ||||||
| { | { | ||||||
| 	return skew_.x; | 	return transform_.skew_x; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| float e2d::Node::GetSkewY() const | float e2d::Node::GetSkewY() const | ||||||
| { | { | ||||||
| 	return skew_.y; | 	return transform_.skew_y; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| float e2d::Node::GetRotation() const | float e2d::Node::GetRotation() const | ||||||
| { | { | ||||||
| 	return rotation_; | 	return transform_.rotation; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | const e2d::Transform & e2d::Node::GetTransform() const | ||||||
|  | { | ||||||
|  | 	return transform_; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| float e2d::Node::GetOpacity() const | float e2d::Node::GetOpacity() const | ||||||
|  | @ -459,23 +415,6 @@ float e2d::Node::GetOpacity() const | ||||||
| 	return real_opacity_; | 	return real_opacity_; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| e2d::Node::Property e2d::Node::GetProperty() const |  | ||||||
| { |  | ||||||
| 	Property prop; |  | ||||||
| 	prop.pos = pos_; |  | ||||||
| 	prop.size = size_; |  | ||||||
| 	prop.anchor = anchor_; |  | ||||||
| 	prop.scale = scale_; |  | ||||||
| 	prop.rotation = rotation_; |  | ||||||
| 	prop.skew = skew_; |  | ||||||
| 	return std::move(prop); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| e2d::Node::Property e2d::Node::GetExtrapolate() const |  | ||||||
| { |  | ||||||
| 	return this->GetProperty() - extrapolate_; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| e2d::Collider* e2d::Node::GetCollider() | e2d::Collider* e2d::Node::GetCollider() | ||||||
| { | { | ||||||
| 	return &collider_; | 	return &collider_; | ||||||
|  | @ -498,58 +437,49 @@ void e2d::Node::SetOrder(int order) | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void e2d::Node::SetPosX(float x) | void e2d::Node::SetPositionX(float x) | ||||||
| { | { | ||||||
| 	this->SetPos(x, pos_.y); | 	this->SetPosition(x, transform_.position.y); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void e2d::Node::SetPosY(float y) | void e2d::Node::SetPositionY(float y) | ||||||
| { | { | ||||||
| 	this->SetPos(pos_.x, y); | 	this->SetPosition(transform_.position.x, y); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void e2d::Node::SetPos(const Point & p) | void e2d::Node::SetPosition(const Point & p) | ||||||
| { | { | ||||||
| 	this->SetPos(p.x, p.y); | 	this->SetPosition(p.x, p.y); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void e2d::Node::SetPos(float x, float y) | void e2d::Node::SetPosition(float x, float y) | ||||||
| { | { | ||||||
| 	if (pos_.x == x && pos_.y == y) | 	if (transform_.position.x == x && transform_.position.y == y) | ||||||
| 		return; | 		return; | ||||||
| 
 | 
 | ||||||
| 	pos_.x = x; | 	transform_.position.x = x; | ||||||
| 	pos_.y = y; | 	transform_.position.y = y; | ||||||
| 	dirty_transform_ = true; | 	dirty_transform_ = true; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void e2d::Node::SetPosFixed(bool fixed) | void e2d::Node::MoveBy(float x, float y) | ||||||
| { | { | ||||||
| 	if (fixed_position_ == fixed) | 	this->SetPosition(transform_.position.x + x, transform_.position.y + y); | ||||||
| 		return; |  | ||||||
| 
 |  | ||||||
| 	fixed_position_ = fixed; |  | ||||||
| 	dirty_transform_ = true; |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void e2d::Node::Move(float x, float y) | void e2d::Node::MoveBy(const Point & v) | ||||||
| { | { | ||||||
| 	this->SetPos(pos_.x + x, pos_.y + y); | 	this->MoveBy(v.x, v.y); | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void e2d::Node::Move(const Point & v) |  | ||||||
| { |  | ||||||
| 	this->Move(v.x, v.y); |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void e2d::Node::SetScaleX(float scale_x) | void e2d::Node::SetScaleX(float scale_x) | ||||||
| { | { | ||||||
| 	this->SetScale(scale_x, scale_.y); | 	this->SetScale(scale_x, transform_.scale_y); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void e2d::Node::SetScaleY(float scale_y) | void e2d::Node::SetScaleY(float scale_y) | ||||||
| { | { | ||||||
| 	this->SetScale(scale_.x, scale_y); | 	this->SetScale(transform_.scale_x, scale_y); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void e2d::Node::SetScale(float scale) | void e2d::Node::SetScale(float scale) | ||||||
|  | @ -559,40 +489,40 @@ void e2d::Node::SetScale(float scale) | ||||||
| 
 | 
 | ||||||
| void e2d::Node::SetScale(float scale_x, float scale_y) | void e2d::Node::SetScale(float scale_x, float scale_y) | ||||||
| { | { | ||||||
| 	if (scale_.x == scale_x && scale_.y == scale_y) | 	if (transform_.scale_x == scale_x && transform_.scale_y == scale_y) | ||||||
| 		return; | 		return; | ||||||
| 
 | 
 | ||||||
| 	scale_.x = scale_x; | 	transform_.scale_x = scale_x; | ||||||
| 	scale_.y = scale_y; | 	transform_.scale_y = scale_y; | ||||||
| 	dirty_transform_ = true; | 	dirty_transform_ = true; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void e2d::Node::SetSkewX(float skew_x) | void e2d::Node::SetSkewX(float skew_x) | ||||||
| { | { | ||||||
| 	this->SetSkew(skew_x, skew_.y); | 	this->SetSkew(skew_x, transform_.skew_y); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void e2d::Node::SetSkewY(float skew_y) | void e2d::Node::SetSkewY(float skew_y) | ||||||
| { | { | ||||||
| 	this->SetSkew(skew_.x, skew_y); | 	this->SetSkew(transform_.skew_x, skew_y); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void e2d::Node::SetSkew(float skew_x, float skew_y) | void e2d::Node::SetSkew(float skew_x, float skew_y) | ||||||
| { | { | ||||||
| 	if (skew_.x == skew_x && skew_.y == skew_y) | 	if (transform_.skew_x == skew_x && transform_.skew_y == skew_y) | ||||||
| 		return; | 		return; | ||||||
| 
 | 
 | ||||||
| 	skew_.x = skew_x; | 	transform_.skew_x = skew_x; | ||||||
| 	skew_.y = skew_y; | 	transform_.skew_y = skew_y; | ||||||
| 	dirty_transform_ = true; | 	dirty_transform_ = true; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void e2d::Node::SetRotation(float angle) | void e2d::Node::SetRotation(float angle) | ||||||
| { | { | ||||||
| 	if (rotation_ == angle) | 	if (transform_.rotation == angle) | ||||||
| 		return; | 		return; | ||||||
| 
 | 
 | ||||||
| 	rotation_ = angle; | 	transform_.rotation = angle; | ||||||
| 	dirty_transform_ = true; | 	dirty_transform_ = true; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | @ -608,57 +538,53 @@ void e2d::Node::SetOpacity(float opacity) | ||||||
| 
 | 
 | ||||||
| void e2d::Node::SetAnchorX(float anchor_x) | void e2d::Node::SetAnchorX(float anchor_x) | ||||||
| { | { | ||||||
| 	this->SetAnchor(anchor_x, anchor_.y); | 	this->SetAnchor(anchor_x, transform_.pivot_y); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void e2d::Node::SetAnchorY(float anchor_y) | void e2d::Node::SetAnchorY(float anchor_y) | ||||||
| { | { | ||||||
| 	this->SetAnchor(anchor_.x, anchor_y); | 	this->SetAnchor(transform_.pivot_x, anchor_y); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void e2d::Node::SetAnchor(float anchor_x, float anchor_y) | void e2d::Node::SetAnchor(float anchor_x, float anchor_y) | ||||||
| { | { | ||||||
| 	if (anchor_.x == anchor_x && anchor_.y == anchor_y) | 	if (transform_.pivot_x == anchor_x && transform_.pivot_y == anchor_y) | ||||||
| 		return; | 		return; | ||||||
| 
 | 
 | ||||||
| 	anchor_.x = anchor_x; | 	transform_.pivot_x = anchor_x; | ||||||
| 	anchor_.y = anchor_y; | 	transform_.pivot_y = anchor_y; | ||||||
| 	dirty_transform_ = true; | 	dirty_transform_ = true; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void e2d::Node::SetWidth(float width) | void e2d::Node::SetWidth(float width) | ||||||
| { | { | ||||||
| 	this->SetSize(width, size_.height); | 	this->SetSize(width, transform_.size.height); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void e2d::Node::SetHeight(float height) | void e2d::Node::SetHeight(float height) | ||||||
| { | { | ||||||
| 	this->SetSize(size_.width, height); | 	this->SetSize(transform_.size.width, height); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void e2d::Node::SetSize(float width, float height) | void e2d::Node::SetSize(float width, float height) | ||||||
| { | { | ||||||
| 	if (size_.width == width && size_.height == height) | 	if (transform_.size.width == width && transform_.size.height == height) | ||||||
| 		return; | 		return; | ||||||
| 
 | 
 | ||||||
| 	size_.width = width; | 	transform_.size.width = width; | ||||||
| 	size_.height = height; | 	transform_.size.height = height; | ||||||
| 	dirty_transform_ = true; | 	dirty_transform_ = true; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void e2d::Node::SetSize(Size size) | void e2d::Node::SetSize(const Size& size) | ||||||
| { | { | ||||||
| 	this->SetSize(size.width, size.height); | 	this->SetSize(size.width, size.height); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void e2d::Node::SetProperty(Property prop) | void e2d::Node::SetTransform(const Transform & transform) | ||||||
| { | { | ||||||
| 	this->SetPos(prop.pos.x, prop.pos.y); | 	transform_ = transform; | ||||||
| 	this->SetSize(prop.size.width, prop.size.height); | 	dirty_transform_ = true; | ||||||
| 	this->SetAnchor(prop.anchor.x, prop.anchor.y); |  | ||||||
| 	this->SetScale(prop.scale.x, prop.scale.y); |  | ||||||
| 	this->SetRotation(prop.rotation); |  | ||||||
| 	this->SetSkew(prop.skew.x, prop.skew.y); |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void e2d::Node::SetClipEnabled(bool enabled) | void e2d::Node::SetClipEnabled(bool enabled) | ||||||
|  | @ -671,7 +597,7 @@ void e2d::Node::SetBorderColor(const Color & color) | ||||||
| 	border_color_ = color; | 	border_color_ = color; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void e2d::Node::AddChild(Node * child, int order  /* = 0 */) | void e2d::Node::AddChild(Node * child, int order) | ||||||
| { | { | ||||||
| 	WARN_IF(child == nullptr, "Node::AddChild NULL pointer exception."); | 	WARN_IF(child == nullptr, "Node::AddChild NULL pointer exception."); | ||||||
| 
 | 
 | ||||||
|  | @ -806,31 +732,28 @@ bool e2d::Node::RemoveChild(Node * child) | ||||||
| 
 | 
 | ||||||
| void e2d::Node::RemoveChildren(const String& child_name) | void e2d::Node::RemoveChildren(const String& child_name) | ||||||
| { | { | ||||||
| 	WARN_IF(child_name.IsEmpty(), "Invalid Node name."); |  | ||||||
| 
 |  | ||||||
| 	if (children_.empty()) | 	if (children_.empty()) | ||||||
| 	{ | 	{ | ||||||
| 		return; | 		return; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	// 计算名称 Hash 值
 |  | ||||||
| 	size_t hash = child_name.GetHash(); | 	size_t hash = child_name.GetHash(); | ||||||
| 
 | 	for (auto iter = children_.begin(); iter != children_.end();) | ||||||
| 	auto iter = std::find_if( |  | ||||||
| 		children_.begin(), |  | ||||||
| 		children_.end(), |  | ||||||
| 		[child_name, hash](Node* child) ->bool { return child->hash_name_ == hash && child->name_ == child_name; } |  | ||||||
| 	); |  | ||||||
| 
 |  | ||||||
| 	if (iter != children_.end()) |  | ||||||
| 	{ | 	{ | ||||||
| 		(*iter)->parent_ = nullptr; | 		if ((*iter)->hash_name_ == hash && (*iter)->name_ == child_name) | ||||||
| 		if ((*iter)->parent_scene_) |  | ||||||
| 		{ | 		{ | ||||||
| 			(*iter)->SetParentScene(nullptr); | 			(*iter)->parent_ = nullptr; | ||||||
|  | 			if ((*iter)->parent_scene_) | ||||||
|  | 			{ | ||||||
|  | 				(*iter)->SetParentScene(nullptr); | ||||||
|  | 			} | ||||||
|  | 			(*iter)->Release(); | ||||||
|  | 			iter = children_.erase(iter); | ||||||
|  | 		} | ||||||
|  | 		else | ||||||
|  | 		{ | ||||||
|  | 			++iter; | ||||||
| 		} | 		} | ||||||
| 		(*iter)->Release(); |  | ||||||
| 		children_.erase(iter); |  | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | @ -912,7 +835,7 @@ void e2d::Node::StopAction(const String& name) | ||||||
| 
 | 
 | ||||||
| bool e2d::Node::ContainsPoint(const Point& point) | bool e2d::Node::ContainsPoint(const Point& point) | ||||||
| { | { | ||||||
| 	if (size_.width == 0.f || size_.height == 0.f) | 	if (transform_.size.width == 0.f || transform_.size.height == 0.f) | ||||||
| 		return false; | 		return false; | ||||||
| 
 | 
 | ||||||
| 	UpdateTransform(); | 	UpdateTransform(); | ||||||
|  | @ -930,7 +853,7 @@ bool e2d::Node::ContainsPoint(const Point& point) | ||||||
| 
 | 
 | ||||||
| bool e2d::Node::Intersects(Node * node) | bool e2d::Node::Intersects(Node * node) | ||||||
| { | { | ||||||
| 	if (size_.width == 0.f || size_.height == 0.f || node->size_.width == 0.f || node->size_.height == 0.f) | 	if (transform_.size.width == 0.f || transform_.size.height == 0.f || node->transform_.size.width == 0.f || node->transform_.size.height == 0.f) | ||||||
| 		return false; | 		return false; | ||||||
| 
 | 
 | ||||||
| 	// ¸üÐÂת»»¾ØÕó
 | 	// ¸üÐÂת»»¾ØÕó
 | ||||||
|  | @ -1059,6 +982,11 @@ void e2d::Node::RemoveAllTasks() | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | const e2d::Node::Tasks & e2d::Node::GetAllTasks() const | ||||||
|  | { | ||||||
|  | 	return tasks_; | ||||||
|  | } | ||||||
|  | 
 | ||||||
| void e2d::Node::UpdateTasks() | void e2d::Node::UpdateTasks() | ||||||
| { | { | ||||||
| 	if (tasks_.empty()) | 	if (tasks_.empty()) | ||||||
|  |  | ||||||
|  | @ -1,12 +1,12 @@ | ||||||
| #include "..\e2dutil.h" | #include "..\e2dutil.h" | ||||||
| 
 | 
 | ||||||
| static const UINT sc_redShift = 16; | static const UINT kRedShift = 16; | ||||||
| static const UINT sc_greenShift = 8; | static const UINT kGreenShift = 8; | ||||||
| static const UINT sc_blueShift = 0; | static const UINT kBlueShift = 0; | ||||||
| 
 | 
 | ||||||
| static const UINT sc_redMask = 0xff << sc_redShift; | static const UINT kRedMask = 0xff << kRedShift; | ||||||
| static const UINT sc_greenMask = 0xff << sc_greenShift; | static const UINT kGreenMask = 0xff << kGreenShift; | ||||||
| static const UINT sc_blueMask = 0xff << sc_blueShift; | static const UINT kBlueMask = 0xff << kBlueShift; | ||||||
| 
 | 
 | ||||||
| e2d::Color::Color() | e2d::Color::Color() | ||||||
| 	: r(0) | 	: r(0) | ||||||
|  | @ -33,17 +33,17 @@ e2d::Color::Color(float r, float g, float b, float alpha) | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| e2d::Color::Color(UINT rgb) | e2d::Color::Color(UINT rgb) | ||||||
| 	: r(((rgb & sc_redMask) >> sc_redShift) / 255.f) | 	: r(((rgb & kRedMask) >> kRedShift) / 255.f) | ||||||
| 	, g(((rgb & sc_greenMask) >> sc_greenShift) / 255.f) | 	, g(((rgb & kGreenMask) >> kGreenShift) / 255.f) | ||||||
| 	, b(((rgb & sc_blueMask) >> sc_blueShift) / 255.f) | 	, b(((rgb & kBlueMask) >> kBlueShift) / 255.f) | ||||||
| 	, a(1.f) | 	, a(1.f) | ||||||
| { | { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| e2d::Color::Color(UINT rgb, float alpha) | e2d::Color::Color(UINT rgb, float alpha) | ||||||
| 	: r(((rgb & sc_redMask) >> sc_redShift) / 255.f) | 	: r(((rgb & kRedMask) >> kRedShift) / 255.f) | ||||||
| 	, g(((rgb & sc_greenMask) >> sc_greenShift) / 255.f) | 	, g(((rgb & kGreenMask) >> kGreenShift) / 255.f) | ||||||
| 	, b(((rgb & sc_blueMask) >> sc_blueShift) / 255.f) | 	, b(((rgb & kBlueMask) >> kBlueShift) / 255.f) | ||||||
| 	, a(alpha) | 	, a(alpha) | ||||||
| { | { | ||||||
| } | } | ||||||
|  | @ -58,5 +58,6 @@ e2d::Color::Color(const D2D1_COLOR_F& color) | ||||||
| 
 | 
 | ||||||
| e2d::Color::operator D2D1_COLOR_F() const | e2d::Color::operator D2D1_COLOR_F() const | ||||||
| { | { | ||||||
| 	return std::move(D2D1::ColorF(r, g, b, a)); | 	D2D1::ColorF color_f(r, g, b, a); | ||||||
|  | 	return std::move(color_f); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -0,0 +1,49 @@ | ||||||
|  | #include "..\e2dutil.h" | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | e2d::Transform::Transform() | ||||||
|  | 	: position() | ||||||
|  | 	, size() | ||||||
|  | 	, scale_x(1.f) | ||||||
|  | 	, scale_y(1.f) | ||||||
|  | 	, rotation(0) | ||||||
|  | 	, skew_x(0) | ||||||
|  | 	, skew_y(0) | ||||||
|  | 	, pivot_x(0) | ||||||
|  | 	, pivot_y(0) | ||||||
|  | { | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | e2d::Transform::operator D2D1::Matrix3x2F() const | ||||||
|  | { | ||||||
|  | 	auto pivot = D2D1::Point2F(size.width * pivot_x, size.height * pivot_y); | ||||||
|  | 	auto matrix = D2D1::Matrix3x2F::Scale( | ||||||
|  | 		scale_x, | ||||||
|  | 		scale_y, | ||||||
|  | 		pivot | ||||||
|  | 	) * D2D1::Matrix3x2F::Skew( | ||||||
|  | 		skew_x, | ||||||
|  | 		skew_y, | ||||||
|  | 		pivot | ||||||
|  | 	) * D2D1::Matrix3x2F::Rotation( | ||||||
|  | 		rotation, | ||||||
|  | 		pivot | ||||||
|  | 	) * D2D1::Matrix3x2F::Translation( | ||||||
|  | 		position.x - pivot.x, | ||||||
|  | 		position.y - pivot.y | ||||||
|  | 	); | ||||||
|  | 	return std::move(matrix); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | bool e2d::Transform::operator==(const Transform & other) const | ||||||
|  | { | ||||||
|  | 	return position == other.position && | ||||||
|  | 		size == other.size && | ||||||
|  | 		scale_x == other.scale_x && | ||||||
|  | 		scale_y == other.scale_y && | ||||||
|  | 		skew_x == other.skew_x && | ||||||
|  | 		skew_y == other.skew_y && | ||||||
|  | 		rotation == other.rotation && | ||||||
|  | 		pivot_x == other.pivot_x && | ||||||
|  | 		pivot_y == other.pivot_y; | ||||||
|  | } | ||||||
|  | @ -85,6 +85,7 @@ | ||||||
|     <ClCompile Include="..\..\core\utils\Size.cpp" /> |     <ClCompile Include="..\..\core\utils\Size.cpp" /> | ||||||
|     <ClCompile Include="..\..\core\utils\String.cpp" /> |     <ClCompile Include="..\..\core\utils\String.cpp" /> | ||||||
|     <ClCompile Include="..\..\core\utils\Time.cpp" /> |     <ClCompile Include="..\..\core\utils\Time.cpp" /> | ||||||
|  |     <ClCompile Include="..\..\core\utils\Transform.cpp" /> | ||||||
|   </ItemGroup> |   </ItemGroup> | ||||||
|   <ItemGroup> |   <ItemGroup> | ||||||
|     <ClInclude Include="..\..\core\e2dobject.h" /> |     <ClInclude Include="..\..\core\e2dobject.h" /> | ||||||
|  |  | ||||||
|  | @ -231,6 +231,9 @@ | ||||||
|     <ClCompile Include="..\..\core\utils\Ref.cpp"> |     <ClCompile Include="..\..\core\utils\Ref.cpp"> | ||||||
|       <Filter>utils</Filter> |       <Filter>utils</Filter> | ||||||
|     </ClCompile> |     </ClCompile> | ||||||
|  |     <ClCompile Include="..\..\core\utils\Transform.cpp"> | ||||||
|  |       <Filter>utils</Filter> | ||||||
|  |     </ClCompile> | ||||||
|   </ItemGroup> |   </ItemGroup> | ||||||
|   <ItemGroup> |   <ItemGroup> | ||||||
|     <ClInclude Include="..\..\core\easy2d.h" /> |     <ClInclude Include="..\..\core\easy2d.h" /> | ||||||
|  |  | ||||||
|  | @ -229,6 +229,7 @@ | ||||||
|     <ClCompile Include="..\..\core\utils\Size.cpp" /> |     <ClCompile Include="..\..\core\utils\Size.cpp" /> | ||||||
|     <ClCompile Include="..\..\core\utils\String.cpp" /> |     <ClCompile Include="..\..\core\utils\String.cpp" /> | ||||||
|     <ClCompile Include="..\..\core\utils\Time.cpp" /> |     <ClCompile Include="..\..\core\utils\Time.cpp" /> | ||||||
|  |     <ClCompile Include="..\..\core\utils\Transform.cpp" /> | ||||||
|   </ItemGroup> |   </ItemGroup> | ||||||
|   <ItemGroup> |   <ItemGroup> | ||||||
|     <ClInclude Include="..\..\core\e2dobject.h" /> |     <ClInclude Include="..\..\core\e2dobject.h" /> | ||||||
|  |  | ||||||
|  | @ -231,6 +231,9 @@ | ||||||
|     <ClCompile Include="..\..\core\utils\Ref.cpp"> |     <ClCompile Include="..\..\core\utils\Ref.cpp"> | ||||||
|       <Filter>utils</Filter> |       <Filter>utils</Filter> | ||||||
|     </ClCompile> |     </ClCompile> | ||||||
|  |     <ClCompile Include="..\..\core\utils\Transform.cpp"> | ||||||
|  |       <Filter>utils</Filter> | ||||||
|  |     </ClCompile> | ||||||
|   </ItemGroup> |   </ItemGroup> | ||||||
|   <ItemGroup> |   <ItemGroup> | ||||||
|     <ClInclude Include="..\..\core\easy2d.h" /> |     <ClInclude Include="..\..\core\easy2d.h" /> | ||||||
|  |  | ||||||
|  | @ -262,6 +262,7 @@ | ||||||
|     <ClCompile Include="..\..\core\utils\Size.cpp" /> |     <ClCompile Include="..\..\core\utils\Size.cpp" /> | ||||||
|     <ClCompile Include="..\..\core\utils\String.cpp" /> |     <ClCompile Include="..\..\core\utils\String.cpp" /> | ||||||
|     <ClCompile Include="..\..\core\utils\Time.cpp" /> |     <ClCompile Include="..\..\core\utils\Time.cpp" /> | ||||||
|  |     <ClCompile Include="..\..\core\utils\Transform.cpp" /> | ||||||
|   </ItemGroup> |   </ItemGroup> | ||||||
|   <ItemGroup> |   <ItemGroup> | ||||||
|     <ClInclude Include="..\..\core\e2dobject.h" /> |     <ClInclude Include="..\..\core\e2dobject.h" /> | ||||||
|  |  | ||||||
|  | @ -231,6 +231,9 @@ | ||||||
|     <ClCompile Include="..\..\core\utils\Ref.cpp"> |     <ClCompile Include="..\..\core\utils\Ref.cpp"> | ||||||
|       <Filter>utils</Filter> |       <Filter>utils</Filter> | ||||||
|     </ClCompile> |     </ClCompile> | ||||||
|  |     <ClCompile Include="..\..\core\utils\Transform.cpp"> | ||||||
|  |       <Filter>utils</Filter> | ||||||
|  |     </ClCompile> | ||||||
|   </ItemGroup> |   </ItemGroup> | ||||||
|   <ItemGroup> |   <ItemGroup> | ||||||
|     <ClInclude Include="..\..\core\easy2d.h" /> |     <ClInclude Include="..\..\core\easy2d.h" /> | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue