| 
									
										
										
										
											2019-04-11 14:40:54 +08:00
										 |  |  |  | // Copyright (c) 2016-2018 Kiwano - Nomango
 | 
					
						
							| 
									
										
										
										
											2020-01-21 10:09:55 +08:00
										 |  |  |  | //
 | 
					
						
							| 
									
										
										
										
											2019-03-31 01:37:06 +08:00
										 |  |  |  | // 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:
 | 
					
						
							| 
									
										
										
										
											2020-01-21 10:09:55 +08:00
										 |  |  |  | //
 | 
					
						
							| 
									
										
										
										
											2019-03-31 01:37:06 +08:00
										 |  |  |  | // The above copyright notice and this permission notice shall be included in
 | 
					
						
							|  |  |  |  | // all copies or substantial portions of the Software.
 | 
					
						
							| 
									
										
										
										
											2020-01-21 10:09:55 +08:00
										 |  |  |  | //
 | 
					
						
							| 
									
										
										
										
											2019-03-31 01:37:06 +08:00
										 |  |  |  | // 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
 | 
					
						
							| 
									
										
										
										
											2019-10-11 21:55:29 +08:00
										 |  |  |  | #include <kiwano/2d/Actor.h>
 | 
					
						
							| 
									
										
										
										
											2020-01-17 16:55:47 +08:00
										 |  |  |  | #include <kiwano/render/GeometrySink.h>
 | 
					
						
							| 
									
										
										
										
											2020-01-21 10:09:55 +08:00
										 |  |  |  | #include <kiwano/render/RenderContext.h>
 | 
					
						
							| 
									
										
										
										
											2019-03-31 01:37:06 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-11 14:40:54 +08:00
										 |  |  |  | namespace kiwano | 
					
						
							| 
									
										
										
										
											2019-03-31 01:37:06 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2020-01-21 10:09:55 +08:00
										 |  |  |  | KGE_DECLARE_SMART_PTR(Canvas); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | /**
 | 
					
						
							|  |  |  |  |  * \addtogroup Actors | 
					
						
							|  |  |  |  |  * @{ | 
					
						
							|  |  |  |  |  */ | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | /**
 | 
					
						
							|  |  |  |  |  * \~chinese | 
					
						
							|  |  |  |  |  * @brief <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڻ<EFBFBD><EFBFBD><EFBFBD>ͼԪ | 
					
						
							|  |  |  |  |  */ | 
					
						
							|  |  |  |  | class KGE_API Canvas : public Actor | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  | public: | 
					
						
							|  |  |  |  |     /// \~chinese
 | 
					
						
							|  |  |  |  |     /// @brief <20><><EFBFBD><EFBFBD><EFBFBD>ջ<EFBFBD><D5BB><EFBFBD>
 | 
					
						
							|  |  |  |  |     Canvas(); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     virtual ~Canvas(); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     /// \~chinese
 | 
					
						
							|  |  |  |  |     /// @brief <20><>ʼ<EFBFBD><CABC>ͼ
 | 
					
						
							|  |  |  |  |     void BeginDraw(); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     /// \~chinese
 | 
					
						
							|  |  |  |  |     /// @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ
 | 
					
						
							|  |  |  |  |     void EndDraw(); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     /// \~chinese
 | 
					
						
							|  |  |  |  |     /// @brief <20><><EFBFBD>߶<EFBFBD>
 | 
					
						
							|  |  |  |  |     /// @param begin <20>߶<EFBFBD><DFB6><EFBFBD><EFBFBD><EFBFBD>
 | 
					
						
							|  |  |  |  |     /// @param end <20>߶<EFBFBD><DFB6>յ<EFBFBD>
 | 
					
						
							|  |  |  |  |     void DrawLine(Point const& begin, Point const& end); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     /// \~chinese
 | 
					
						
							|  |  |  |  |     /// @brief <20><>Բ<EFBFBD>α߿<CEB1>
 | 
					
						
							|  |  |  |  |     /// @param center Բ<><D4B2>ԭ<EFBFBD><D4AD>
 | 
					
						
							|  |  |  |  |     /// @param radius Բ<>ΰ뾶
 | 
					
						
							|  |  |  |  |     void DrawCircle(Point const& center, float radius); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     /// \~chinese
 | 
					
						
							|  |  |  |  |     /// @brief <20><><EFBFBD><EFBFBD>Բ<EFBFBD>α߿<CEB1>
 | 
					
						
							|  |  |  |  |     /// @param center <20><>Բԭ<D4B2><D4AD>
 | 
					
						
							|  |  |  |  |     /// @param radius <20><>Բ<EFBFBD>뾶
 | 
					
						
							|  |  |  |  |     void DrawEllipse(Point const& center, Vec2 const& radius); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     /// \~chinese
 | 
					
						
							|  |  |  |  |     /// @brief <20><><EFBFBD><EFBFBD><EFBFBD>α߿<CEB1>
 | 
					
						
							|  |  |  |  |     /// @param rect <20><><EFBFBD><EFBFBD>
 | 
					
						
							|  |  |  |  |     void DrawRect(Rect const& rect); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     /// \~chinese
 | 
					
						
							|  |  |  |  |     /// @brief <20><>Բ<EFBFBD>Ǿ<EFBFBD><C7BE>α߿<CEB1>
 | 
					
						
							|  |  |  |  |     /// @param rect <20><><EFBFBD><EFBFBD>
 | 
					
						
							|  |  |  |  |     /// @param radius <20><><EFBFBD><EFBFBD>Բ<EFBFBD>ǰ뾶
 | 
					
						
							|  |  |  |  |     void DrawRoundedRect(Rect const& rect, Vec2 const& radius); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     /// \~chinese
 | 
					
						
							|  |  |  |  |     /// @brief <20><><EFBFBD><EFBFBD>Բ<EFBFBD><D4B2>
 | 
					
						
							|  |  |  |  |     /// @param center Բ<><D4B2>ԭ<EFBFBD><D4AD>
 | 
					
						
							|  |  |  |  |     /// @param radius Բ<>ΰ뾶
 | 
					
						
							|  |  |  |  |     void FillCircle(Point const& center, float radius); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     /// \~chinese
 | 
					
						
							|  |  |  |  |     /// @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Բ<EFBFBD><D4B2>
 | 
					
						
							|  |  |  |  |     /// @param center <20><>Բԭ<D4B2><D4AD>
 | 
					
						
							|  |  |  |  |     /// @param radius <20><>Բ<EFBFBD>뾶
 | 
					
						
							|  |  |  |  |     void FillEllipse(Point const& center, Vec2 const& radius); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     /// \~chinese
 | 
					
						
							|  |  |  |  |     /// @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
 | 
					
						
							|  |  |  |  |     /// @param rect <20><><EFBFBD><EFBFBD>
 | 
					
						
							|  |  |  |  |     void FillRect(Rect const& rect); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     /// \~chinese
 | 
					
						
							|  |  |  |  |     /// @brief <20><><EFBFBD><EFBFBD>Բ<EFBFBD>Ǿ<EFBFBD><C7BE><EFBFBD>
 | 
					
						
							|  |  |  |  |     /// @param rect <20><><EFBFBD><EFBFBD>
 | 
					
						
							|  |  |  |  |     /// @param radius <20><><EFBFBD><EFBFBD>Բ<EFBFBD>ǰ뾶
 | 
					
						
							|  |  |  |  |     void FillRoundedRect(Rect const& rect, Vec2 const& radius); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     /// \~chinese
 | 
					
						
							|  |  |  |  |     /// @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
 | 
					
						
							|  |  |  |  |     /// @param texture <20><><EFBFBD><EFBFBD>
 | 
					
						
							|  |  |  |  |     /// @param src_rect <20><><EFBFBD><EFBFBD><EFBFBD>ü<EFBFBD><C3BC><EFBFBD><EFBFBD><EFBFBD>
 | 
					
						
							|  |  |  |  |     /// @param dest_rect <20><><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
 | 
					
						
							|  |  |  |  |     void DrawTexture(TexturePtr texture, const Rect* src_rect = nullptr, const Rect* dest_rect = nullptr); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     /// \~chinese
 | 
					
						
							|  |  |  |  |     /// @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֲ<EFBFBD><D6B2><EFBFBD>
 | 
					
						
							|  |  |  |  |     /// @param text <20><><EFBFBD><EFBFBD>
 | 
					
						
							|  |  |  |  |     /// @param point <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD>λ<EFBFBD><CEBB>
 | 
					
						
							|  |  |  |  |     void DrawTextLayout(String const& text, Point const& point); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     /// \~chinese
 | 
					
						
							|  |  |  |  |     /// @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֲ<EFBFBD><D6B2><EFBFBD>
 | 
					
						
							|  |  |  |  |     /// @param layout <20><><EFBFBD>ֲ<EFBFBD><D6B2><EFBFBD>
 | 
					
						
							|  |  |  |  |     /// @param point <20><><EFBFBD>Ʋ<EFBFBD><C6B2>ֵ<EFBFBD>λ<EFBFBD><CEBB>
 | 
					
						
							|  |  |  |  |     void DrawTextLayout(TextLayout const& layout, Point const& point); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     /// \~chinese
 | 
					
						
							|  |  |  |  |     /// @brief <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>·<EFBFBD><C2B7>
 | 
					
						
							|  |  |  |  |     /// @param begin_pos ·<><C2B7><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>
 | 
					
						
							|  |  |  |  |     void BeginPath(Point const& begin_pos); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     /// \~chinese
 | 
					
						
							|  |  |  |  |     /// @brief <20><><EFBFBD><EFBFBD>·<EFBFBD><C2B7>
 | 
					
						
							|  |  |  |  |     /// @param closed ·<><C2B7><EFBFBD>Ƿ<EFBFBD><C7B7>պ<EFBFBD>
 | 
					
						
							|  |  |  |  |     void EndPath(bool closed = false); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     /// \~chinese
 | 
					
						
							|  |  |  |  |     /// @brief <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>߶<EFBFBD>
 | 
					
						
							|  |  |  |  |     /// @param point <20>˵<EFBFBD>
 | 
					
						
							|  |  |  |  |     void AddLine(Point const& point); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     /// \~chinese
 | 
					
						
							|  |  |  |  |     /// @brief <20><><EFBFBD>Ӷ<EFBFBD><D3B6><EFBFBD><EFBFBD>߶<EFBFBD>
 | 
					
						
							|  |  |  |  |     /// @param points <20>˵㼯<CBB5><E3BCAF>
 | 
					
						
							|  |  |  |  |     void AddLines(Vector<Point> const& points); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     /// \~chinese
 | 
					
						
							|  |  |  |  |     /// @brief <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD>η<EFBFBD><CEB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
 | 
					
						
							|  |  |  |  |     /// @param point1 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ߵĵ<DFB5>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD>Ƶ<EFBFBD>
 | 
					
						
							|  |  |  |  |     /// @param point2 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ߵĵڶ<C4B5><DAB6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƶ<EFBFBD>
 | 
					
						
							|  |  |  |  |     /// @param point3 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ߵ<EFBFBD><DFB5>յ<EFBFBD>
 | 
					
						
							|  |  |  |  |     void AddBezier(Point const& point1, Point const& point2, Point const& point3); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     /// \~chinese
 | 
					
						
							|  |  |  |  |     /// @brief <20><><EFBFBD>ӻ<EFBFBD><D3BB><EFBFBD>
 | 
					
						
							|  |  |  |  |     /// @param point <20>յ<EFBFBD>
 | 
					
						
							|  |  |  |  |     /// @param radius <20><>Բ<EFBFBD>뾶
 | 
					
						
							|  |  |  |  |     /// @param rotation <20><>Բ<EFBFBD><D4B2>ת<EFBFBD>Ƕ<EFBFBD>
 | 
					
						
							|  |  |  |  |     /// @param clockwise ˳ʱ<CBB3><CAB1> or <20><>ʱ<EFBFBD><CAB1>
 | 
					
						
							|  |  |  |  |     /// @param is_small <20>Ƿ<EFBFBD>ȡС<C8A1><D0A1> 180<38><30> <20>Ļ<EFBFBD>
 | 
					
						
							|  |  |  |  |     void AddArc(Point const& point, Size const& radius, float rotation, bool clockwise = true, bool is_small = true); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     /// \~chinese
 | 
					
						
							|  |  |  |  |     /// @brief <20><><EFBFBD><EFBFBD><EFBFBD>ߵķ<DFB5>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD>·<EFBFBD><C2B7>
 | 
					
						
							|  |  |  |  |     void StrokePath(); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     /// \~chinese
 | 
					
						
							|  |  |  |  |     /// @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ķ<EFBFBD>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD>·<EFBFBD><C2B7>
 | 
					
						
							|  |  |  |  |     void FillPath(); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     /// \~chinese
 | 
					
						
							|  |  |  |  |     /// @brief <20><><EFBFBD>ջ<EFBFBD><D5BB><EFBFBD>
 | 
					
						
							|  |  |  |  |     void Clear(); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     /// \~chinese
 | 
					
						
							|  |  |  |  |     /// @brief <20><><EFBFBD>ջ<EFBFBD><D5BB><EFBFBD>
 | 
					
						
							|  |  |  |  |     /// @param clear_color <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ
 | 
					
						
							|  |  |  |  |     void Clear(Color const& clear_color); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     /// \~chinese
 | 
					
						
							|  |  |  |  |     /// @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ
 | 
					
						
							|  |  |  |  |     /// @param color <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ
 | 
					
						
							|  |  |  |  |     void SetFillColor(Color const& color); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     /// \~chinese
 | 
					
						
							|  |  |  |  |     /// @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>仭ˢ
 | 
					
						
							|  |  |  |  |     /// @param[in] brush <20><><EFBFBD>仭ˢ
 | 
					
						
							|  |  |  |  |     void SetFillBrush(BrushPtr brush); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     /// \~chinese
 | 
					
						
							|  |  |  |  |     /// @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ
 | 
					
						
							|  |  |  |  |     /// @param color <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ
 | 
					
						
							|  |  |  |  |     void SetStrokeColor(Color const& color); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     /// \~chinese
 | 
					
						
							|  |  |  |  |     /// @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ˢ
 | 
					
						
							|  |  |  |  |     /// @param[in] brush <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ˢ
 | 
					
						
							|  |  |  |  |     void SetStrokeBrush(BrushPtr brush); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     /// \~chinese
 | 
					
						
							|  |  |  |  |     /// @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
 | 
					
						
							|  |  |  |  |     /// @param width <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
 | 
					
						
							|  |  |  |  |     void SetStrokeWidth(float width); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     /// \~chinese
 | 
					
						
							|  |  |  |  |     /// @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ
 | 
					
						
							|  |  |  |  |     /// @param stroke_style <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ
 | 
					
						
							|  |  |  |  |     void SetStrokeStyle(const StrokeStyle& stroke_style); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     /// \~chinese
 | 
					
						
							|  |  |  |  |     /// @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֻ<EFBFBD>ˢ<EFBFBD><CBA2>ʽ
 | 
					
						
							|  |  |  |  |     /// @param text_style <20><><EFBFBD>ֻ<EFBFBD>ˢ<EFBFBD><CBA2>ʽ
 | 
					
						
							|  |  |  |  |     void SetTextStyle(TextStyle const& text_style); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     /// \~chinese
 | 
					
						
							|  |  |  |  |     /// @brief <20><><EFBFBD>û<EFBFBD>ˢ
 | 
					
						
							|  |  |  |  |     /// @param[in] brush <20><>ˢ
 | 
					
						
							|  |  |  |  |     void SetBrush(BrushPtr brush); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     /// \~chinese
 | 
					
						
							|  |  |  |  |     /// @brief <20><><EFBFBD>û<EFBFBD>ˢ<EFBFBD><CBA2>ά<EFBFBD>任
 | 
					
						
							|  |  |  |  |     /// @param transform <20><>ά<EFBFBD>任
 | 
					
						
							|  |  |  |  |     void SetBrushTransform(Transform const& transform); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     /// \~chinese
 | 
					
						
							|  |  |  |  |     /// @brief <20><><EFBFBD>û<EFBFBD>ˢ<EFBFBD><CBA2>ά<EFBFBD>任<EFBFBD><E4BBBB><EFBFBD><EFBFBD>
 | 
					
						
							|  |  |  |  |     /// @param transform <20><>ά<EFBFBD>任<EFBFBD><E4BBBB><EFBFBD><EFBFBD>
 | 
					
						
							|  |  |  |  |     void SetBrushTransform(Matrix3x2 const& transform); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     /// \~chinese
 | 
					
						
							|  |  |  |  |     /// @brief <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>ͼ<EFBFBD><CDBC>
 | 
					
						
							|  |  |  |  |     /// @param area ͼ<><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
 | 
					
						
							|  |  |  |  |     void PushLayerArea(LayerArea& area); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     /// \~chinese
 | 
					
						
							|  |  |  |  |     /// @brief ɾ<><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӵ<EFBFBD>ͼ<EFBFBD><CDBC>
 | 
					
						
							|  |  |  |  |     void PopLayerArea(); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     /// \~chinese
 | 
					
						
							|  |  |  |  |     /// @brief <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>ü<EFBFBD><C3BC><EFBFBD><EFBFBD><EFBFBD>
 | 
					
						
							|  |  |  |  |     /// @param clip_rect <20>ü<EFBFBD><C3BC><EFBFBD><EFBFBD><EFBFBD>
 | 
					
						
							|  |  |  |  |     void PushClipRect(Rect const& clip_rect); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     /// \~chinese
 | 
					
						
							|  |  |  |  |     /// @brief ɾ<><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӵIJü<C4B2><C3BC><EFBFBD><EFBFBD><EFBFBD>
 | 
					
						
							|  |  |  |  |     void PopClipRect(); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     /// \~chinese
 | 
					
						
							|  |  |  |  |     /// @brief <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
 | 
					
						
							|  |  |  |  |     float GetStrokeWidth() const; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     /// \~chinese
 | 
					
						
							|  |  |  |  |     /// @brief <20><>ȡ<EFBFBD><C8A1><EFBFBD>仭ˢ
 | 
					
						
							|  |  |  |  |     BrushPtr GetFillBrush() const; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     /// \~chinese
 | 
					
						
							|  |  |  |  |     /// @brief <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ˢ
 | 
					
						
							|  |  |  |  |     BrushPtr GetStrokeBrush() const; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     /// \~chinese
 | 
					
						
							|  |  |  |  |     /// @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
 | 
					
						
							|  |  |  |  |     TexturePtr ExportToTexture() const; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     void OnRender(RenderContext& ctx) override; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | private: | 
					
						
							|  |  |  |  |     void InitRenderTargetAndBrushs(); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     void UpdateCache() const; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | private: | 
					
						
							|  |  |  |  |     float        stroke_width_; | 
					
						
							|  |  |  |  |     TextStyle    text_style_; | 
					
						
							|  |  |  |  |     StrokeStyle  stroke_style_; | 
					
						
							|  |  |  |  |     GeometrySink geo_sink_; | 
					
						
							|  |  |  |  |     BrushPtr     fill_brush_; | 
					
						
							|  |  |  |  |     BrushPtr     stroke_brush_; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     mutable bool                    cache_expired_; | 
					
						
							|  |  |  |  |     mutable TexturePtr              texture_cached_; | 
					
						
							|  |  |  |  |     mutable TextureRenderContextPtr ctx_; | 
					
						
							|  |  |  |  | }; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | /** @} */ | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | inline void Canvas::SetStrokeWidth(float width) | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  |     stroke_width_ = std::max(width, 0.f); | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | inline void Canvas::SetStrokeStyle(const StrokeStyle& stroke_style) | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  |     stroke_style_ = stroke_style; | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | inline void Canvas::SetTextStyle(TextStyle const& text_style) | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  |     text_style_ = text_style; | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | inline void Canvas::SetStrokeColor(Color const& color) | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  |     InitRenderTargetAndBrushs(); | 
					
						
							|  |  |  |  |     stroke_brush_->SetColor(color); | 
					
						
							|  |  |  |  | } | 
					
						
							| 
									
										
										
										
											2019-12-27 23:42:51 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-01-21 10:09:55 +08:00
										 |  |  |  | inline void Canvas::SetFillColor(Color const& color) | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  |     InitRenderTargetAndBrushs(); | 
					
						
							|  |  |  |  |     fill_brush_->SetColor(color); | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | inline void Canvas::SetFillBrush(BrushPtr brush) | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  |     fill_brush_ = brush; | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | inline void Canvas::SetStrokeBrush(BrushPtr brush) | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  |     stroke_brush_ = brush; | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | inline BrushPtr Canvas::GetFillBrush() const | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  |     return fill_brush_; | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | inline BrushPtr Canvas::GetStrokeBrush() const | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  |     return stroke_brush_; | 
					
						
							| 
									
										
										
										
											2019-08-08 14:15:06 +08:00
										 |  |  |  | } | 
					
						
							| 
									
										
										
										
											2020-01-21 10:09:55 +08:00
										 |  |  |  | }  // namespace kiwano
 |