YSTest: YDraw.h 源文件

YSTest PreAlpha_b800_20170810 The YSLib Test Project

- 首页
- 相关页面
- 模块
- 命名空间
- 类
- 文件

- 文件列表
- 文件成员

YDraw.h
浏览该文件的文档.
1 /*
2 © 2011-2015 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
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
88
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
151 /*
152 \brief 描画线段：在区域 ds 绘制端点为 p1(x1, y1) 和 p2(x2, y2) 的线段。
153 \pre 断言： bounds 在 g 指定的边界内。
154 */
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
NPL::dst
YF_API const char src const string const char * dst
Definition: Dependency.h:95
YSLib::Drawing::buffer
The boundary is out of the buffer
Definition: YDraw.h:118
YModules.h
YSLib
YSLib 命名空间。
Definition: AndroidHost.h:45
YSLib::Drawing::GGraphics
二维图形接口上下文模板。
Definition: YGraphics.h:62
YSLib::UI::y
SPos SPos y
Definition: YWidget.cpp:44
YSLib::Drawing::BitmapPtr
Pixel * BitmapPtr
Definition: YGraphics.h:42
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::Color
The boundary is out of the const Rect SDst SPos SPos SPos Color
Definition: YDraw.h:127
ystdex::is_undereferenceable
bool is_undereferenceable(const _tIter &)
Definition: deref_op.hpp:45
YSLib::Drawing::Point
GBinaryGroup< SPos > Point
屏幕二维点（直角坐标表示）。
Definition: YGDIBase.h:278
YSLib::YAssert
YAssert(!(v< Deref(a)),"Value less than lower bound found.")
yunseq
#define yunseq
无序列依赖表达式组求值。
Definition: ydef.h:1022
YSLib::Drawing::FillRect
c YF_API void FillRect(const Graphics &g, const Rect &r, Color c)
填充标准矩形。
Definition: YDraw.cpp:150
YSLib::Drawing::y1
The boundary is out of the const Rect SDst SPos SPos y1
Definition: YDraw.h:127
YSLib::Drawing::x2
The boundary is out of the const Rect SDst SPos SPos SPos x2
Definition: YDraw.h:148
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 。 ...
platform::SDst
std::uint16_t SDst
屏幕坐标距离。
Definition: Video.h:44
YSLib::Drawing::x
The boundary is out of the const Rect SDst SPos x
Definition: YDraw.h:127
YSLib::Drawing::w
The boundary is out of the const Rect SDst w
Definition: YDraw.h:127
YSLib::Drawing::g
The boundary is out of the const Graphics & g
Definition: YDraw.h:161
CHRLib::s
_tDst const _tSrc * s
Definition: CharacterProcessing.h:140
YSLib::Drawing::DrawLineSeg
The boundary is out of the DrawLineSeg
Definition: YDraw.h:161
platform::KeyCodes::DS::Y
Definition: Keys.h:229
YSLib::Drawing::ImplExpr
tr TextRegion &tr ImplExpr(tr.Margin.Bottom=SPos(FetchResizedBottomMargin(tr))) YF_API SDst FetchCharWidth(const Font &
取指定的字符使用指定字体的显示宽度。
YSLib::Drawing::Graphics
GGraphics< BitmapPtr > Graphics
Definition: YGraphics.h:163
YF_API
#define YF_API
Definition: Platform.h:56
YSLib::Drawing::p1
The boundary is out of the const Graphics const Rect const Point & p1
Definition: YDraw.h:161
Drawing
platform::SPos
std::int16_t SPos
屏幕坐标度量。
Definition: Video.h:43
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::Color
颜色。
Definition: Video.h:416
YSLib::Drawing::GBinaryGroup< SPos >
YSLib::Drawing::DrawRect
void DrawRect(const Graphics &g, const Rect &bounds, const Rect &r, Color c)
Definition: YDraw.cpp:136
platform::KeyCodes::DS::X
Definition: Keys.h:228
YSLib::Drawing::Rect
屏幕标准矩形：表示屏幕矩形区域。
Definition: YGDIBase.h:540
YSLib::Drawing::PlotLineSeg
The boundary is out of the PlotLineSeg(g.GetBufferPtr(), bounds, g.GetWidth(), x1, y1, x2, y2, c)) inline PDefH(void
platform::Nonnull
_type && Nonnull(_type &&p) ynothrowv
断言并返回非空参数。
Definition: Debug.h:422
YSLib::Drawing::DrawCircle
bounds c YF_API void DrawCircle(const Graphics &g, const Rect &bounds, const Point &, SDst, Color)
描画圆形。
Definition: YDraw.cpp:180
YSLib::Drawing::Size
屏幕区域大小。
Definition: YGDIBase.h:293
YSLib::Drawing::bounds
The boundary is out of the const Rect & bounds
Definition: YDraw.h:127
YSLib::Drawing::PDefH
yconstfn PDefH(Size, Transpose, const Size &s) ynothrow ImplRet(
转置。
Definition: YGDIBase.h:516
YB_LIKELY
#define YB_LIKELY(_expr)
Definition: ydef.h:463
YSLib::Drawing::DrawPolygon
void DrawPolygon(Graphics &g, const Rect &bounds, _tIn first, _tIn last, Color c)
描画多边形。
Definition: YDraw.h:214
YSLib::Drawing::FillCircle
YF_API void FillCircle(const Graphics &g, const Rect &bounds, const Point &, SDst, Color)
填充圆形。
Definition: YDraw.cpp:202
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::y2
The boundary is out of the const Rect SDst SPos SPos SPos y2
Definition: YDraw.h:127
YSLib::Drawing::p2
The boundary is out of the const Graphics const Rect const Point const Point & p2
Definition: YDraw.h:161