Skip to content

Instantly share code, notes, and snippets.

@sknjpn
Created September 8, 2019 05:29
Show Gist options
  • Save sknjpn/21ffa1d4c73865fc55488e9aa0cd1265 to your computer and use it in GitHub Desktop.
Save sknjpn/21ffa1d4c73865fc55488e9aa0cd1265 to your computer and use it in GitHub Desktop.
Geometry2D::Subtractのテスト
# include <Siv3D.hpp> // OpenSiv3D v0.4.0
void Main()
{
RectF r1(100, 100, 300, 300);
RectF r2(50, 50, 50, 50);
RectF r3(150, 150, 50, 50);
Scene::SetBackground(Palette::Skyblue);
while (System::Update())
{
Polygon polygon(r1.asPolygon());
ClearPrint();
Print << Geometry2D::Subtract(polygon, r2.asPolygon()).size();
polygon = Geometry2D::Subtract(polygon, r2.asPolygon()).front();
// 表示
Geometry2D::Subtract(polygon, r3.asPolygon()).back().movedBy(350, 0).draw(ColorF(Palette::Red, 0.5)).drawWireframe(1.0, Palette::Red);
Print << Geometry2D::Subtract(polygon, r3.asPolygon()).size();
polygon = Geometry2D::Subtract(polygon, r3.asPolygon()).front();
r2.setCenter(Cursor::PosF());
r1.drawFrame(2.0, Palette::Black);
r2.drawFrame(2.0, Palette::Black);
r3.drawFrame(2.0, Palette::Black);
polygon.draw(ColorF(Palette::Red, 0.5));
polygon.drawWireframe(1.0, Palette::Red);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment