add: Geometry begin position
This commit is contained in:
parent
ad70453c21
commit
b6308ababd
|
|
@ -120,22 +120,27 @@ namespace easy2d
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
RectangleGeometry::RectangleGeometry(Size const & rect_size)
|
RectangleGeometry::RectangleGeometry(Rect const & rect)
|
||||||
{
|
{
|
||||||
SetSize(rect_size);
|
SetRect(rect);
|
||||||
|
}
|
||||||
|
|
||||||
|
RectangleGeometry::RectangleGeometry(Point const & left_top, Size const & size)
|
||||||
|
{
|
||||||
|
SetRect(Rect{ left_top, size });
|
||||||
}
|
}
|
||||||
|
|
||||||
RectangleGeometry::~RectangleGeometry()
|
RectangleGeometry::~RectangleGeometry()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void RectangleGeometry::SetSize(Size const & rect_size)
|
void RectangleGeometry::SetRect(Rect const & rect)
|
||||||
{
|
{
|
||||||
cpRectangleGeometry geo;
|
cpRectangleGeometry geo;
|
||||||
if (SUCCEEDED(devices::Graphics::Instance()->CreateRectangleGeometry(geo, Rect(Point{}, rect_size))))
|
if (SUCCEEDED(devices::Graphics::Instance()->CreateRectangleGeometry(geo, rect)))
|
||||||
{
|
{
|
||||||
geo_ = geo;
|
geo_ = geo;
|
||||||
size_ = rect_size;
|
rect_ = rect;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -148,9 +153,9 @@ namespace easy2d
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
CircleGeometry::CircleGeometry(float radius)
|
CircleGeometry::CircleGeometry(Point const & center, float radius)
|
||||||
{
|
{
|
||||||
SetRadius(radius);
|
SetCircle(center, radius);
|
||||||
}
|
}
|
||||||
|
|
||||||
CircleGeometry::~CircleGeometry()
|
CircleGeometry::~CircleGeometry()
|
||||||
|
|
@ -158,11 +163,22 @@ namespace easy2d
|
||||||
}
|
}
|
||||||
|
|
||||||
void CircleGeometry::SetRadius(float radius)
|
void CircleGeometry::SetRadius(float radius)
|
||||||
|
{
|
||||||
|
SetCircle(center_, radius);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CircleGeometry::SetCenter(Point const & center)
|
||||||
|
{
|
||||||
|
SetCircle(center, radius_);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CircleGeometry::SetCircle(Point const & center, float radius)
|
||||||
{
|
{
|
||||||
cpEllipseGeometry geo;
|
cpEllipseGeometry geo;
|
||||||
if (SUCCEEDED(devices::Graphics::Instance()->CreateEllipseGeometry(geo, Point{}, radius, radius)))
|
if (SUCCEEDED(devices::Graphics::Instance()->CreateEllipseGeometry(geo, center, radius, radius)))
|
||||||
{
|
{
|
||||||
geo_ = geo;
|
geo_ = geo;
|
||||||
|
center_ = center;
|
||||||
radius_ = radius;
|
radius_ = radius;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -176,9 +192,9 @@ namespace easy2d
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
EllipseGeometry::EllipseGeometry(float radius_x, float radius_y)
|
EllipseGeometry::EllipseGeometry(Point const & center, float radius_x, float radius_y)
|
||||||
{
|
{
|
||||||
SetRadius(radius_x, radius_y);
|
SetEllipse(center, radius_x, radius_y);
|
||||||
}
|
}
|
||||||
|
|
||||||
EllipseGeometry::~EllipseGeometry()
|
EllipseGeometry::~EllipseGeometry()
|
||||||
|
|
@ -186,9 +202,19 @@ namespace easy2d
|
||||||
}
|
}
|
||||||
|
|
||||||
void EllipseGeometry::SetRadius(float radius_x, float radius_y)
|
void EllipseGeometry::SetRadius(float radius_x, float radius_y)
|
||||||
|
{
|
||||||
|
SetEllipse(center_, radius_x, radius_y);
|
||||||
|
}
|
||||||
|
|
||||||
|
void EllipseGeometry::SetCenter(Point const & center)
|
||||||
|
{
|
||||||
|
SetEllipse(center, radius_x_, radius_y_);
|
||||||
|
}
|
||||||
|
|
||||||
|
void EllipseGeometry::SetEllipse(Point const & center, float radius_x, float radius_y)
|
||||||
{
|
{
|
||||||
cpEllipseGeometry geo;
|
cpEllipseGeometry geo;
|
||||||
if (SUCCEEDED(devices::Graphics::Instance()->CreateEllipseGeometry(geo, Point{}, radius_x, radius_y)))
|
if (SUCCEEDED(devices::Graphics::Instance()->CreateEllipseGeometry(geo, center, radius_x, radius_y)))
|
||||||
{
|
{
|
||||||
geo_ = geo;
|
geo_ = geo;
|
||||||
radius_x_ = radius_x;
|
radius_x_ = radius_x;
|
||||||
|
|
@ -209,7 +235,7 @@ namespace easy2d
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void PathGeometry::BeginPath()
|
void PathGeometry::BeginPath(Point const& begin_pos)
|
||||||
{
|
{
|
||||||
current_geometry_ = nullptr;
|
current_geometry_ = nullptr;
|
||||||
|
|
||||||
|
|
@ -221,7 +247,7 @@ namespace easy2d
|
||||||
current_geometry_->Open(¤t_sink_)
|
current_geometry_->Open(¤t_sink_)
|
||||||
);
|
);
|
||||||
|
|
||||||
current_sink_->BeginFigure(D2D1::Point2F(), D2D1_FIGURE_BEGIN_FILLED);
|
current_sink_->BeginFigure(begin_pos, D2D1_FIGURE_BEGIN_FILLED);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PathGeometry::EndPath(bool closed)
|
void PathGeometry::EndPath(bool closed)
|
||||||
|
|
|
||||||
|
|
@ -79,17 +79,22 @@ namespace easy2d
|
||||||
RectangleGeometry();
|
RectangleGeometry();
|
||||||
|
|
||||||
RectangleGeometry(
|
RectangleGeometry(
|
||||||
Size const& rect_size
|
Rect const& rect
|
||||||
|
);
|
||||||
|
|
||||||
|
RectangleGeometry(
|
||||||
|
Point const& left_top,
|
||||||
|
Size const& size
|
||||||
);
|
);
|
||||||
|
|
||||||
virtual ~RectangleGeometry();
|
virtual ~RectangleGeometry();
|
||||||
|
|
||||||
Size const& GetSize() const { return size_; }
|
Rect const& GetRect() const { return rect_; }
|
||||||
|
|
||||||
void SetSize(Size const& rect_size);
|
void SetRect(Rect const& rect);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Size size_;
|
Rect rect_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -101,6 +106,7 @@ namespace easy2d
|
||||||
CircleGeometry();
|
CircleGeometry();
|
||||||
|
|
||||||
CircleGeometry(
|
CircleGeometry(
|
||||||
|
Point const& center,
|
||||||
float radius
|
float radius
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -112,7 +118,19 @@ namespace easy2d
|
||||||
float radius
|
float radius
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Point const& GetCenter() const { return center_; }
|
||||||
|
|
||||||
|
void SetCenter(
|
||||||
|
Point const& center
|
||||||
|
);
|
||||||
|
|
||||||
|
void SetCircle(
|
||||||
|
Point const& center,
|
||||||
|
float radius
|
||||||
|
);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
Point center_;
|
||||||
float radius_;
|
float radius_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -125,6 +143,7 @@ namespace easy2d
|
||||||
EllipseGeometry();
|
EllipseGeometry();
|
||||||
|
|
||||||
EllipseGeometry(
|
EllipseGeometry(
|
||||||
|
Point const& center,
|
||||||
float radius_x,
|
float radius_x,
|
||||||
float radius_y
|
float radius_y
|
||||||
);
|
);
|
||||||
|
|
@ -140,7 +159,20 @@ namespace easy2d
|
||||||
float radius_y
|
float radius_y
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Point const& GetCenter() const { return center_; }
|
||||||
|
|
||||||
|
void SetCenter(
|
||||||
|
Point const& center
|
||||||
|
);
|
||||||
|
|
||||||
|
void SetEllipse(
|
||||||
|
Point const& center,
|
||||||
|
float radius_x,
|
||||||
|
float radius_y
|
||||||
|
);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
Point center_;
|
||||||
float radius_x_;
|
float radius_x_;
|
||||||
float radius_y_;
|
float radius_y_;
|
||||||
};
|
};
|
||||||
|
|
@ -156,7 +188,9 @@ namespace easy2d
|
||||||
virtual ~PathGeometry();
|
virtual ~PathGeometry();
|
||||||
|
|
||||||
// ¿ªÊ¼Ìí¼Ó·¾¶
|
// ¿ªÊ¼Ìí¼Ó·¾¶
|
||||||
void BeginPath();
|
void BeginPath(
|
||||||
|
Point const& begin_pos = Point{} /* Æðʼµã */
|
||||||
|
);
|
||||||
|
|
||||||
// ½áÊøÂ·¾¶
|
// ½áÊøÂ·¾¶
|
||||||
void EndPath(
|
void EndPath(
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue