OpenSiv3D
OpenSiv3D copied to clipboard
サイズが 0 の Rect, RectF を "empty" な状態であると定義
サイズが 0 の長方形を「空の長方形」とする。
-
Rect::isEmpty()
,Rect::operator bool
#880 -
Rect::getOverlap(cother)
#872 -
static Rect Rect::Empty()
#881
RectF も同様に。
# include <Siv3D.hpp> // OpenSiv3D v0.6.6
void Main()
{
Optional<Point> from;
const Rect rect{ 300, 200, 300, 200 };
while (System::Update())
{
ClearPrint();
if (MouseL.down())
{
from = Cursor::Pos();
}
else if (MouseL.up())
{
from.reset();
}
rect.drawFrame(1, 0);
if (from)
{
const Rect rect2 = Rect::FromPoints(*from, Cursor::Pos());
rect2.drawFrame(1, 0, Palette::Skyblue);
if (const Rect overlap = rect.getOverlap(rect2))
{
Print << overlap;
overlap.draw(Palette::Orange);
}
}
}
}