YSTest: YDraw.h 源文件

YSTest PreAlpha_b900_20201012 The YSLib Test Project

YDraw.h
浏览该文件的文档.
1 /*
2 © 2011-2015, 2018-2019 FrankHB.
3
4 This file is part of the YSLib project, and may only be used,
5 modified, and distributed under the terms of the YSLib project
6 license, LICENSE.TXT. By continuing to use, modify, or distribute
7 this file you indicate that you have read the license and
8 understand and accept it fully.
9 */
10
28 #ifndef YSL_INC_Service_YDraw_h_
29 #define YSL_INC_Service_YDraw_h_ 1
30
31 #include "YModules.h"
32 #include YFM_YSLib_Core_YGraphics
33
34 namespace YSLib
35 {
36
37 namespace Drawing
38 {
39
63 inline PDefH(void, PutPixel, BitmapPtr dst, SDst w, SPos x, SPos y, Color c)
64 // XXX: Conversion to 'ptrdiff_t' might be implementation-defined.
65 ImplExpr(Nonnull(dst)[y * ptrdiff_t(w) + x] = c)
72 inline PDefH(void, PutPixel, const Graphics& g, SPos x, SPos y, Color c)
73 ImplExpr(YAssert(Rect(g.GetSize()).Contains(x, y),
74 "The pixel is out of the buffer."),
75 PutPixel(g.GetBufferPtr(), g.GetWidth(), x, y, c))
76
77
82 inline PDefH(void, PlotPixel, BitmapPtr dst, const Rect& bounds, SDst w, SPos x,
84 SPos y, Color c)
85 ImplExpr(bounds.Contains(x, y) ? PutPixel(dst, w, x, y, c) : void())
86
87
89 inline PDefH(void, DrawPoint, const Graphics& g, const Rect& bounds, SPos x,
90 SPos y, Color c)
91 ImplExpr(YAssert(bounds.IsUnstrictlyEmpty() || Rect(g.GetSize()).Contains(
92 bounds), "The boundary is out of the buffer."),
93 PlotPixel(g.GetBufferPtr(), bounds, g.GetWidth(), x, y, c))
94 inline PDefH(void, DrawPoint, const Graphics& g, const Rect& bounds,
95 const Point& pt, Color c)
96 ImplExpr(DrawPoint(g, bounds, pt.X, pt.Y, c))
98
99
105 YF_API void
106 PlotHLineSeg(BitmapPtr dst, const Rect& bounds, SDst w, SPos y, SPos x1,
107 SPos x2, Color);
108
115 inline PDefH(void, DrawHLineSeg, const Graphics& g, const Rect& bounds, SPos y,
116 SPos x1, SPos x2, Color c)
117 ImplExpr(YAssert(bounds.IsUnstrictlyEmpty() || Rect(g.GetSize()).Contains(
118 bounds), "The boundary is out of the buffer."),
119 PlotHLineSeg(g.GetBufferPtr(), bounds, g.GetWidth(), y, x1, x2, c))
120
126 YF_API void
127 PlotVLineSeg(BitmapPtr dst, const Rect& bounds, SDst w, SPos x, SPos y1,
128 SPos y2, Color);
129
136 inline PDefH(void, DrawVLineSeg, const Graphics& g, const Rect& bounds, SPos x,
137 SPos y1, SPos y2, Color c)
138 ImplExpr(YAssert(bounds.IsUnstrictlyEmpty() || Rect(g.GetSize()).Contains(
139 bounds), "The boundary is out of the buffer."),
140 PlotVLineSeg(g.GetBufferPtr(), bounds, g.GetWidth(), x, y1, y2, c))
141
147 YF_API void
148 PlotLineSeg(BitmapPtr dst, const Rect& bounds, SDst w, SPos x1, SPos y1,
149 SPos x2, SPos y2, Color);
150
156 inline PDefH(void, DrawLineSeg, const Graphics& g, const Rect& bounds, SPos x1,
157 SPos y1, SPos x2, SPos y2, Color c)
158 ImplExpr(YAssert(bounds.IsUnstrictlyEmpty() || Rect(g.GetSize()).Contains(
159 bounds), "The boundary is out of the buffer."),
160 PlotLineSeg(g.GetBufferPtr(), bounds, g.GetWidth(), x1, y1, x2, y2, c))
161 inline PDefH(void, DrawLineSeg, const Graphics& g, const Rect& bounds,
162 const Point& p1, const Point& p2, Color c)
163 ImplExpr(DrawLineSeg(g, bounds, p1.X, p1.Y, p2.X, p2.Y, c))
165
166
172 YF_API void
174 DrawRect(const Graphics& g, const Rect& bounds, const Rect& r, Color c);
176 inline PDefH(void, DrawRect, const Graphics& g, const Rect& bounds,
177 const Point& pt, const Size& s, Color c)
178 ImplExpr(DrawRect(g, bounds, {pt, s}, c))
180
187 YF_API void
189 FillRect(const Graphics& g, const Rect& r, Color c);
190 inline PDefH(void, FillRect, const Graphics& g, const Rect& bounds,
191 const Rect& r, Color c)
192 ImplExpr(FillRect(g, bounds & r, c))
194
195
196
201 YF_API void
203 DrawCircle(const Graphics& g, const Rect& bounds, const Point&, SDst, Color);
204
206 YF_API void
207 FillCircle(const Graphics& g, const Rect& bounds, const Point&, SDst, Color);
209
210
212 template<typename _tIn>
213 void
214 DrawPolygon(Graphics& g, const Rect& bounds, _tIn first, _tIn last, Color c)
215 {
216 if(YB_LIKELY(first != last))
217 {
218 using ystdex::is_undereferenceable;
219 const _tIn old(first);
220 _tIn mid(first);
221
222 ++mid;
223 while(mid != last)
224 {
225 YAssert(!is_undereferenceable(first), "Invalid iterator found."),
226 YAssert(!is_undereferenceable(mid), "Invalid iterator found.");
227
228 DrawLineSeg(g, bounds, *first, *mid, c);
229 yunseq(++first, ++mid);
230 }
231 YAssert(!is_undereferenceable(first), "Invalid iterator found."),
232 YAssert(!is_undereferenceable(old), "Invalid iterator found.");
233 DrawLineSeg(g, bounds, *first, *old, c);
234 }
235 }
237
238 } // namespace Drawing;
239
240 } // namespace YSLib;
241
242 #endif
243
YSLib::Drawing::DrawLineSeg
The boundary is out of the DrawLineSeg
Definition: YDraw.h:161
YSLib::Drawing::buffer
The boundary is out of the buffer
Definition: YDraw.h:118
YSLib::Drawing::Color
The boundary is out of the const Rect SDst SPos SPos SPos Color
Definition: YDraw.h:128
YSLib::Drawing::PlotVLineSeg
The boundary is out of the PlotVLineSeg(g.GetBufferPtr(), bounds, g.GetWidth(), x, y1, y2, c)) YF_API void PlotLineSeg(BitmapPtr dst
绘制线段：在宽 w 的缓冲区内的区域 bounds 绘制端点为 p1(x1, y1) 和 p2(x2, y2) 的线段。
platform::Nonnull
YB_PURE _type && Nonnull(_type &&p) ynothrowv
断言并返回非空参数。
Definition: Debug.h:518
YSLib::Drawing::y2
The boundary is out of the const Rect SDst SPos SPos SPos y2
Definition: YDraw.h:128
YSLib::Drawing::Size
屏幕区域大小。
Definition: YGDIBase.h:536
YSLib::Drawing::FillRect
c YF_API void FillRect(const Graphics &g, const Rect &r, Color c)
填充标准矩形。
Definition: YDraw.cpp:150
YSLib::Drawing::c
The boundary is out of the const Graphics const Rect const Point const Point Color c const Rect const Rect Color c
Definition: YDraw.h:174
YSLib::Drawing::x1
The boundary is out of the const Rect SDst SPos x1
Definition: YDraw.h:148
YSLib::Drawing::r
The boundary is out of the const Graphics const Rect const Point const Point Color c const Rect const Rect & r
Definition: YDraw.h:174
YSLib::Drawing::PlotHLineSeg
The boundary is out of the PlotHLineSeg(g.GetBufferPtr(), bounds, g.GetWidth(), y, x1, x2, c)) YF_API void PlotVLineSeg(BitmapPtr dst
绘制竖直线段：在宽 w 的缓冲区内的区域 bounds 绘制指定竖直水平坐标 x ， 竖直坐标 y1 - 1 、 y2 。
YSLib::Drawing::x
const TextState &ts const TextState &ts const TextState &ts TextState SPos x
Definition: TextBase.h:190
YSLib::Drawing::PlotLineSeg
The boundary is out of the PlotLineSeg(g.GetBufferPtr(), bounds, g.GetWidth(), x1, y1, x2, y2, c)) inline PDefH(void
YSLib::Drawing::x2
The boundary is out of the const Rect SDst SPos SPos SPos x2
Definition: YDraw.h:149
YF_API
#define YF_API
Definition: Platform.h:56
YSLib::Drawing::p2
The boundary is out of the const Graphics const Rect const Point const Point & p2
Definition: YDraw.h:162
YSLib::Drawing::g
The boundary is out of the const Graphics & g
Definition: YDraw.h:161
YSLib::Drawing::Rect::Contains
YB_ATTR_nodiscard YB_PURE bool Contains(SPos px, SPos py) const ynothrow
判断点 (px, py) 是否在矩形内或边上。
Definition: YGDIBase.cpp:91
YSLib::Drawing::PDefH
YB_ATTR_nodiscard YB_PURE yconstfn PDefH(Size, Transpose, const Size &s) ynothrow ImplRet(
转置。
Definition: YGDIBase.h:763
YSLib::Drawing::DrawCircle
bounds c YF_API void DrawCircle(const Graphics &g, const Rect &bounds, const Point &, SDst, Color)
描画圆形。
Definition: YDraw.cpp:180
YSLib::YAssert
YAssert(!(v< Deref(a)), "Value less than lower bound found.")
YSLib::Drawing::p1
The boundary is out of the const Graphics const Rect const Point & p1
Definition: YDraw.h:162
YSLib::Drawing::GGraphics
二维图形接口上下文模板。
Definition: YGraphics.h:63
YSLib::Drawing::IsUnstrictlyEmpty
YB_ATTR_nodiscard !x IsUnstrictlyEmpty()) YB_ATTR_nodiscard YF_API Point ClipBounds(Rect &
根据指定源的边界优化绘制上下文的剪切区域。
YSLib::Drawing::GBinaryGroup< SPos >
platform::KeyCodes::DS::X
@ X
Definition: Keys.h:229
YSLib::Drawing::GetSize
dst GetSize()
yunseq
#define yunseq
无序列依赖表达式组求值。
Definition: ydef.h:1535
platform::SDst
std::uint16_t SDst
屏幕坐标距离。
Definition: Video.h:44
YSLib::Drawing::FillCircle
YF_API void FillCircle(const Graphics &g, const Rect &bounds, const Point &, SDst, Color)
填充圆形。
Definition: YDraw.cpp:202
YSLib::UI::y
SPos SPos y
Definition: YWidget.cpp:44
platform::KeyCodes::DS::Y
@ Y
Definition: Keys.h:230
YSLib::Drawing::Rect
屏幕标准矩形：表示屏幕矩形区域。
Definition: YGDIBase.h:788
YSLib
YSLib 命名空间。
Definition: AndroidHost.h:46
CHRLib::s
_tDst const _tSrc * s
Definition: CharacterProcessing.h:143
YB_LIKELY
#define YB_LIKELY(_expr)
Definition: ydef.h:827
YModules.h
YSLib 用户界面模块配置文件。
YSLib::Drawing::y1
The boundary is out of the const Rect SDst SPos SPos y1
Definition: YDraw.h:127
ystdex::is_undereferenceable
bool is_undereferenceable(const _tIter &)
Definition: deref_op.hpp:46
YSLib::Drawing::ImplExpr
const TextState &ts const TextState &ts const TextState &ts TextState SPos SPos y ImplExpr(ts.Pen=Point(x, y)) YF_API void SetCurrentTextLineNOf(TextState &
设置笔的行位置。
YSLib::Drawing::bounds
The boundary is out of the const Rect & bounds
Definition: YDraw.h:127
YSLib::Drawing::w
The boundary is out of the const Rect SDst w
Definition: YDraw.h:127
YSLib::Drawing::DrawPolygon
void DrawPolygon(Graphics &g, const Rect &bounds, _tIn first, _tIn last, Color c)
描画多边形。
Definition: YDraw.h:214
const
const Decapsulate const Decapsulate &y ynothrow ContextNode &ctx const
Definition: NPLA1Forms.cpp:1629
platform::SPos
std::int16_t SPos
屏幕坐标度量。
Definition: Video.h:43
NPL::dst
YF_API const char src const string const char * dst
Definition: Dependency.h:96
YSLib::Drawing::BitmapPtr
Pixel * BitmapPtr
Definition: YGraphics.h:42
YSLib::Drawing::DrawRect
void DrawRect(const Graphics &g, const Rect &bounds, const Rect &r, Color c)
Definition: YDraw.cpp:136