28 #ifndef YSL_INC_Core_ygdibase_h_
29 #define YSL_INC_Core_ygdibase_h_ 1
32 #include YFM_YSLib_Core_YException
53 template<
typename _type>
90 template<typename _tScalar1, typename _tScalar2>
100 template<
typename _tPair>
103 :
X(std::get<0>(pr)),
Y(std::get<1>(pr))
152 GetRef(
bool b =
true) ynothrow
162 GetRef(
bool b =
true) const
ynothrow
168 template<
typename _type>
169 const GBinaryGroup<_type> GBinaryGroup<_type>::Invalid{
170 std::numeric_limits<_type>::lowest(), std::numeric_limits<_type>::lowest()};
179 template<
typename _type>
183 return a.X == b.X && a.Y == b.Y;
190 template<
typename _type>
201 template<
typename _type>
212 template<
typename _type>
223 template<
typename _type,
typename _tScalar>
267 :
Width(0), Height(0)
275 :
Width(
s.Width), Height(
s.Height)
287 template<typename _type>
296 template<
typename _tScalar1,
typename _tScalar2>
299 :
Width(w), Height(h)
326 !((Width == 0) ^ (Height == 0)))
331 yconstfn DefPred(const ynothrow, UnstrictlyEmpty, Width == 0 || Height == 0)
339 GetRef(
bool b =
true) ynothrow
341 return b ? Width : Height;
349 GetRef(
bool b =
true) const
ynothrow
351 return b ?
Width : Height;
362 return a.Width == b.Width && a.Height == b.Height;
380 template<
typename _type>
392 template<
class _tBinary>
396 return _tBinary(obj.Y, obj.X);
406 return s.Width *
s.Height;
540 operator|=(const Rect&) ynothrow;
547 using Size::operator!;
554 using Size::operator
bool;
561 Contains(
int px,
int py) const ynothrow;
574 Contains(const Rect&) const ynothrow;
581 ContainsStrict(
int px,
int py) const ynothrow;
586 PDefH(
bool, ContainsStrict, const
Point& pt) const ynothrow
594 ContainsStrict(const Rect&) const ynothrow;
601 using Size::IsLineSegment;
607 using Size::IsUnstrictlyEmpty;
613 static_cast<const Point&>(*this))
618 DefGetter(ynothrow, Point&, PointRef, static_cast<Point&>(*this))
623 static_cast<const Size&>(*this))
628 DefGetter(ynothrow, Size&, SizeRef, static_cast<Size&>(*this))
640 return x.GetPoint() == y.GetPoint() && x.GetSize() == y.GetSize();
661 return Rect(
r.GetPoint() +
v,
r.GetSize());
671 return Rect(
r.GetPoint() -
v,
r.GetSize());
688 operator|(const
Rect&, const Rect&) ynothrow;
698 YAssert(r.Width > off2 && r.Height > off2,
"Boundary is too small.");
699 yunseq(r.X += off1, r.Y += off1, r.Width -= off2, r.Height -= off2);
704 template<
typename _type>
712 :
Width(
r.Width), Height(
r.Height)
752 : pBuffer(b), sGraphics(
s)
760 : pBuffer(
g.pBuffer), sGraphics(
g.sGraphics)
785 explicit
DefCvt(const ynothrow,
bool,
786 pBuffer && sGraphics.
Width != 0 && sGraphics.Height != 0)
791 DefGetter(const ynothrow, SDst, Height, sGraphics.Height)
793 sizeof(PixelType) *
GetAreaOf(sGraphics))
825 struct YF_API PaintContext
851 UpdateClipArea(PaintContext& pc,
const Rect&
r)
853 pc.ClipArea = r & pc.Target.GetSize();
857 UpdateClipSize(PaintContext& pc,
const Size&
s)
859 UpdateClipArea(pc, {pc.Location, s});
yconstfn Rect(SPos x, SPos y, SDst w, SDst h) ynothrow
构造:使用表示位置的两个 SPos 值和表示大小的两个 SDst 值。
#define DefDeDtor(_t)
定义默认析构函数。
yconstfn Graphics(BitmapPtr b, const Size &s={}) ynothrow
构造:使用指定位图指针和大小。
#define DefPred(_q, _n,...)
static const Rect Invalid
无效对象。
static const Graphics Invalid
无效图形接口上下文。
BitmapPtr pBuffer
显示缓冲区指针。
#define DefDeCopyCtor(_t)
yconstfn GBinaryGroup() ynothrow
无参数构造。
yconstfn Size(_tScalar1 w, _tScalar2 h) ynothrow
构造:使用两个纯量。
static const GBinaryGroup Invalid
无效(不在屏幕坐标系中)对象。
yconstfn auto GetAreaOf(const Size &s) ynothrow-> decltype(s.Width *s.Height)
取面积。
yconstfn GBinaryGroup(const _tPair &pr) ynothrow
构造:使用纯量对。
GBinaryGroup & operator-=(const GBinaryGroup &val) ynothrow
减法赋值。
std::uint16_t SDst
屏幕坐标距离。
CompactPixmapEx & operator=(const CompactPixmapEx &buf)
yconstfn bool operator==(const GBinaryGroup< _type > &a, const GBinaryGroup< _type > &b) ynothrow
比较:屏幕二元组相等关系。
yconstfn GBinaryGroup operator-() const ynothrow
负运算:取加法逆元。
std::runtime_error GeneralEvent
一般运行时异常事件类。
sizeof(AlphaType)*GetAreaOf(GetSize())) using CompactPixmap void SetSize(const Size &) override
重新设置缓冲区大小。
GBinaryGroup< SPos > Point
屏幕二维点(直角坐标表示)。
#define yunseq
无序列依赖表达式组求值。
yconstfn Size(const Size &s) ynothrow
复制构造。
yconstfn Rect(const Point &pt, SDst w, SDst h) ynothrow
构造:使用屏幕二维点和表示长宽的两个 SDst 值。
GBinaryGroup & operator+=(const GBinaryGroup &val) ynothrow
加法赋值。
static const Size Invalid
无效对象。
#define ynothrow
YSLib 无异常抛出保证:若支持 noexcept 关键字, 指定特定的 noexcept 异常规范。
yconstfn Y DefSetter(_type, X, X) DefSetter(_type
yconstfn DefGetter(const ynothrow, _type, X, X) yconstfn DefGetter(const ynothrow
#define ythrow(...)
YSLib 动态异常规范:根据是否使用异常规范宏指定或忽略动态异常规范。
DeclDerivedI(YF_API, IImage, ystdex::cloneable) DeclIEntry(const Graphics &GetContext() const ynothrow) DeclIEntry(void SetSize(const Size &)) DeclIEntry(IImage *clone() const override) EndDeclstruct YF_API PaintContext
图像接口。
yconstfn GBinaryGroup< _type > operator+(const GBinaryGroup< _type > &a, const GBinaryGroup< _type > &b) ynothrow
加法:屏幕二元组。
yconstfn _tBinary Transpose(_tBinary &obj) ynothrow
二元对象转置。
yconstfn DefDeCopyCtor(GBinaryGroup) explicit yconstfn GBinaryGroup(const Size &) ynothrow
复制构造:默认实现。
yconstfn Rect(const Size &s) ynothrow
构造:使用 Size 对象。
yconstfn Rect(const Point &pt, const Size &s) ynothrow
构造:使用屏幕二维点和 Size 对象。
#define yconstfn
指定编译时常量函数。
yconstfn GBinaryGroup< _type > operator*(const GBinaryGroup< _type > &val, _tScalar l) ynothrow
数乘:屏幕二元组。
Rect operator&(const Rect &a, const Rect &b) ynothrow
Selected const shared_ptr< ListType > const pair< Color, Color > viewer Contains
yconstfn Rect operator+(const Rect &r, const Vec &v) ynothrow
加法:使用标准矩形 r 和偏移向量 v 构造屏幕标准矩形。
yconstfn bool operator!=(const Rect &x, const Rect &y) ynothrow
比较:屏幕标准矩形不等关系。
yconstfn Rect operator-(const Rect &r, const Vec &v) ynothrow
减法:使用标准矩形 r 和偏移向量的加法逆元 v 构造屏幕标准矩形。
bool operator!=(const HMultiBitmap::iterator &x, const HMultiBitmap::iterator &y) ynothrow
#define DefCvt(_q, _t,...)
yconstfn Size() ynothrow
无参数构造。
if(YB_UNLIKELY(r >=sGraphics.Height)) throw std return pBuffer r *sGraphics Width
PDefH(void, DrawLineSeg, const Graphics &g, const Rect &bounds, const Point &p1, const Point &p2, Color c) ImplExpr(DrawLineSeg(g
DefGetter(const ynothrow, AlphaType *, BufferAlphaPtr, pBufferAlpha) DefGetter(const ynothrow
取 Alpha 缓冲区的指针。
Graphics() ynothrow
默认构造:使用空指针和大小。
yconstfn Graphics(const Graphics &g) ynothrow
复制构造:浅复制。
yconstfn DefDeCtor(Rect) explicit yconstfn Rect(const Point &pt) ynothrow
无参数构造:默认实现。
yconstfn GBinaryGroup< _type > operator-(const GBinaryGroup< _type > &a, const GBinaryGroup< _type > &b) ynothrow
减法:屏幕二元组。
#define DefDeCopyAssignment(_t)
yconstfn Rect(SPos x, SPos y, const Size &s) ynothrow
构造:使用表示位置的两个 SPos 值和 Size 对象。
#define YAssert(_expr, _msg)