29 #include YFM_YSLib_Service_YDraw
30 #include YFM_YSLib_Service_YBlit
43 YAssert(bounds.
Width <= w,
"Wrong boundary or width found.");
44 if(!bounds.IsUnstrictlyEmpty()
45 && IsInInterval<SPos>(y - bounds.
Y, bounds.
Height))
47 const auto bx(bounds.
X);
48 const auto bxw(bx + bounds.
Width);
50 if(!((x1 < bx && x2 < bx) || (x1 >= bxw && x2 >= bxw)))
55 FillPixel<PixelType>(&dst[y * w + x1], x2 - x1,
c);
65 YAssert(bounds.
Width <= w,
"Wrong boundary or width found.");
66 if(!bounds.IsUnstrictlyEmpty()
67 && IsInInterval<SPos>(x - bounds.
X, bounds.
Width))
69 const auto by(bounds.
Y);
70 const auto byh(by + bounds.
Height);
72 if(!((y1 < by && y2 < by) || (y1 >= byh && y2 >= byh)))
77 FillVerticalLine<PixelType>(&dst[y1 * w + x], y2 - y1, w,
c);
99 SDst dx(std::abs(x2 - x1)), dy(std::abs(y2 - y1));
106 const SDst dx2(dx << 1), dy2(dy << 1);
148 YAssert(
bool(g),
"Invalid graphics context found.");
149 FillRectRaw<PixelType>(g.GetBufferPtr(), g.GetSize(),
r,
c);
165 for(
SPos x(0), y(r), p(3 - 2 * r); y >= x;
166 p += p < 0 ? (4 * x++ + 6) : (4 * (x++ - y--) + 10))
167 plotter(g, bounds, pt.
X, pt.
Y, x, y, c);
179 using namespace placeholders;
180 const auto plot(bind(
PlotPixel, g.GetBufferPtr(), cref(bounds),
181 g.GetWidth(), _1, _2,
c));
183 plot(x + dx, y + dy),
184 plot(x - dx, y + dy),
185 plot(x - dx, y - dy),
186 plot(x + dx, y - dy),
187 plot(x + dy, y + dx),
188 plot(x - dy, y + dx),
189 plot(x - dy, y - dx),
190 plot(x + dy, y - dx);
201 using namespace placeholders;
202 const auto plot(bind(
PlotHLineSeg, g.GetBufferPtr(), cref(bounds),
203 g.GetWidth(), _1, _2, _3,
c));
205 plot(y + dy, x - dx, x + dx + 1),
206 plot(y - dy, x - dx, x + dx + 1),
207 plot(y + dx, x - dy, x + dy + 1),
208 plot(y - dx, x - dy, x + dy + 1);
void DrawVLineSeg(const Graphics &g, const Rect &bounds, SPos x, SPos y1, SPos y2, Color c)
描画竖直线段。
YF_API void FillCircle(const Graphics &, const Rect &, const Point &, SDst, Color c)
填充圆形。
YF_API void FillRect(const Graphics &g, const Rect &, Color c)
填充标准矩形。
YF_API void PlotLineSeg(BitmapPtr dst, const Rect &bounds, SDst w, SPos x1, SPos y1, SPos x2, SPos y2, Color)
绘制线段:在宽 w 的缓冲区内的区域 bounds 绘制端点为 p1(x1, y1) 和 p2(x2, y2) 的线段。 ...
std::uint16_t SDst
屏幕坐标距离。
void swap(any &x, any &y)
交换对象。
bounds c YF_API void DrawCircle(const Graphics &, const Rect &, const Point &, SDst, Color c)
描画圆形。
void DrawHLineSeg(const Graphics &g, const Rect &bounds, SPos y, SPos x1, SPos x2, Color c)
描画水平线段。
yconstfn s8 FetchSign(int a, int b=0) ynothrow
整数类型符号函数。
void RestrictLessEqual(_type &a, _type &b) ynothrow
约束关系:a ≤ b 。
#define YAssertNonnull(_expr)
void PlotPixel(BitmapPtr dst, const Rect &bounds, SDst w, SPos x, SPos y, Color c)
绘制指定位置的像素:(x, y) 。
YF_API void PlotVLineSeg(BitmapPtr dst, const Rect &bounds, SDst w, SPos x, SPos y1, SPos y2, Color)
绘制竖直线段:在宽 w 的缓冲区内的区域 bounds 绘制指定竖直水平坐标 x , 竖直坐标 y1 - 1 、 y2 。 ...
void RestrictInInterval(_type &i, int a, int b) ynothrow
约束整数 i 在左闭右开区间 [a, b) 中。
p1 p1 p2 p2 c YF_API void DrawRect(const Graphics &g, const Rect &bounds, const Point &pt, const Size &s, Color c)
描画标准矩形。
#define YAssert(_expr, _msg)
YF_API void PlotHLineSeg(BitmapPtr dst, const Rect &bounds, SDst w, SPos y, SPos x1, SPos x2, Color)
绘制水平线段:在宽 w 的缓冲区内的区域 bounds 绘制指定端点水平坐标 x1 、 x2 - 1 ,竖直坐标 y 。 ...