| 
									
										
										
										
											2018-04-21 21:24:46 +08:00
										 |  |  | #include "..\..\e2dshape.h"
 | 
					
						
							| 
									
										
										
										
											2018-04-02 23:01:38 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | e2d::Shape::Shape() | 
					
						
							| 
									
										
										
										
											2018-05-08 17:40:36 +08:00
										 |  |  | 	: _nStyle(ShapeStyle::SOLID) | 
					
						
							|  |  |  | 	, _nFillColor(Color::WHITE) | 
					
						
							|  |  |  | 	, _nLineColor(Color::BLUE, 0.5) | 
					
						
							|  |  |  | 	, _fStrokeWidth(1) | 
					
						
							| 
									
										
										
										
											2018-04-02 23:01:38 +08:00
										 |  |  | { | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | e2d::Shape::~Shape() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void e2d::Shape::onRender() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-04-22 13:15:57 +08:00
										 |  |  | 	auto pBrush = Renderer::getSolidColorBrush(); | 
					
						
							| 
									
										
										
										
											2018-05-08 17:40:36 +08:00
										 |  |  | 	pBrush->SetOpacity(_fDisplayOpacity); | 
					
						
							| 
									
										
										
										
											2018-04-22 13:15:57 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-08 17:40:36 +08:00
										 |  |  | 	switch (_nStyle) | 
					
						
							| 
									
										
										
										
											2018-04-02 23:01:38 +08:00
										 |  |  | 	{ | 
					
						
							|  |  |  | 	case ShapeStyle::FILL: | 
					
						
							|  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2018-05-08 17:40:36 +08:00
										 |  |  | 		pBrush->SetColor(_nFillColor.toColorF()); | 
					
						
							| 
									
										
										
										
											2018-04-02 23:01:38 +08:00
										 |  |  | 		this->_renderFill(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-08 17:40:36 +08:00
										 |  |  | 		pBrush->SetColor(_nLineColor.toColorF()); | 
					
						
							| 
									
										
										
										
											2018-04-02 23:01:38 +08:00
										 |  |  | 		this->_renderLine(); | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	case ShapeStyle::ROUND: | 
					
						
							|  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2018-05-08 17:40:36 +08:00
										 |  |  | 		pBrush->SetColor(_nLineColor.toColorF()); | 
					
						
							| 
									
										
										
										
											2018-04-02 23:01:38 +08:00
										 |  |  | 		this->_renderLine(); | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	case ShapeStyle::SOLID: | 
					
						
							|  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2018-05-08 17:40:36 +08:00
										 |  |  | 		pBrush->SetColor(_nFillColor.toColorF()); | 
					
						
							| 
									
										
										
										
											2018-04-02 23:01:38 +08:00
										 |  |  | 		this->_renderFill(); | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	default: | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-22 13:15:57 +08:00
										 |  |  | e2d::Color e2d::Shape::getFillColor() const | 
					
						
							| 
									
										
										
										
											2018-04-02 23:01:38 +08:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2018-05-08 17:40:36 +08:00
										 |  |  | 	return _nFillColor; | 
					
						
							| 
									
										
										
										
											2018-04-02 23:01:38 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-22 13:15:57 +08:00
										 |  |  | e2d::Color e2d::Shape::getLineColor() const | 
					
						
							| 
									
										
										
										
											2018-04-02 23:01:38 +08:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2018-05-08 17:40:36 +08:00
										 |  |  | 	return _nLineColor; | 
					
						
							| 
									
										
										
										
											2018-04-02 23:01:38 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | double e2d::Shape::getStrokeWidth() const | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-05-08 17:40:36 +08:00
										 |  |  | 	return _fStrokeWidth; | 
					
						
							| 
									
										
										
										
											2018-04-02 23:01:38 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-24 21:22:34 +08:00
										 |  |  | e2d::ShapeStyle e2d::Shape::getStyle() const | 
					
						
							| 
									
										
										
										
											2018-04-02 23:01:38 +08:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2018-05-08 17:40:36 +08:00
										 |  |  | 	return _nStyle; | 
					
						
							| 
									
										
										
										
											2018-04-02 23:01:38 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-22 13:15:57 +08:00
										 |  |  | void e2d::Shape::setFillColor(Color fillColor) | 
					
						
							| 
									
										
										
										
											2018-04-02 23:01:38 +08:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2018-05-08 17:40:36 +08:00
										 |  |  | 	_nFillColor = fillColor; | 
					
						
							| 
									
										
										
										
											2018-04-02 23:01:38 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-22 13:15:57 +08:00
										 |  |  | void e2d::Shape::setLineColor(Color lineColor) | 
					
						
							| 
									
										
										
										
											2018-04-02 23:01:38 +08:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2018-05-08 17:40:36 +08:00
										 |  |  | 	_nLineColor = lineColor; | 
					
						
							| 
									
										
										
										
											2018-04-02 23:01:38 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void e2d::Shape::setStrokeWidth(double strokeWidth) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-05-08 17:40:36 +08:00
										 |  |  | 	_fStrokeWidth = static_cast<float>(strokeWidth); | 
					
						
							| 
									
										
										
										
											2018-04-02 23:01:38 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-24 21:22:34 +08:00
										 |  |  | void e2d::Shape::setStyle(ShapeStyle style) | 
					
						
							| 
									
										
										
										
											2018-04-02 23:01:38 +08:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2018-05-08 17:40:36 +08:00
										 |  |  | 	_nStyle = style; | 
					
						
							| 
									
										
										
										
											2018-04-02 23:01:38 +08:00
										 |  |  | } |