Open3
Siv3D v0.6.16 新規追加・更新サンプル
v0.6.15 からのアップグレード手順(Windows)
手順に従うことで、既存の v0.6.15 プロジェクトを簡単に v0.6.16 にアップグレードできます。
1. v0.6.16 のインストール
Siv3D v0.6.16 をインストールします。
2. バックアップ
手順の間違いでプロジェクトデータを消失しないよう、アップデート対象のプロジェクトを別の場所にコピーしてバックアップをとります。
3. ヘッダ・ライブラリパスの更新
Visual Studio のメニューからプロジェクトのプロパティを開き、「構成」を「すべての構成」にしたうえで「構成プロパティ」→「VC++ ディレクトリ」の 3 箇所の環境変数を SIV3D_0_6_15
から SIV3D_0_6_16
に書き換え、「適用」「OK」を押します。
4. プロジェクトのリビルド
プロジェクトをリビルドします。
Rect::chamfered()
# include <Siv3D.hpp>
void Main()
{
Scene::SetBackground(ColorF{ 0.6, 0.8, 0.7 });
const Font font{ FontMethod::MSDF, 48, Typeface::Bold };
const Rect button1{ 100, 100, 320, 100 };
const Rect button2{ 100, 300, 320, 100 };
double s = 0.0;
double tl = 50.0;
double tr = 50.0;
double bl = 50.0;
double br = 50.0;
while (System::Update())
{
button1.chamfered(s).draw(ColorF{ 0.3, 0.6, 0.9 });
font(U"アイテム").drawAt(44, button1.center(), ColorF{ 1.0 });
button2.chamfered(tl, tr, bl, br).draw(ColorF{ 0.3, 0.6, 0.9 });
font(U"アイテム").drawAt(44, button2.center(), ColorF{ 1.0 });
SimpleGUI::Slider(s, 0.0, 100.0, Vec2{ 500, 100 }, 180);
SimpleGUI::Slider(tl, 0.0, 100.0, Vec2{ 500, 300 }, 180);
SimpleGUI::Slider(tr, 0.0, 100.0, Vec2{ 500, 340 }, 180);
SimpleGUI::Slider(bl, 0.0, 100.0, Vec2{ 500, 380 }, 180);
SimpleGUI::Slider(br, 0.0, 100.0, Vec2{ 500, 420 }, 180);
}
}
Geometry2D::SmallestEnclosingCircle()
# include <Siv3D.hpp>
Array<Vec2> GeneratePoint(const Vec2& center, size_t n)
{
Array<Vec2> points = { center };
while (points.size() < n)
{
points << (points.back() + RandomVec2(30.0));
}
return points;
}
void Main()
{
Window::Resize(1280, 720);
Array<Vec2> points = GeneratePoint(Scene::CenterF(), 0);
Array<Vec2> prevPoints = points;
Array<Vec2> nextPoints = points;
Array<Vec2> pointVelocities(nextPoints.size(), Vec2::Zero());
Circle currentCircle{ Scene::Center(), 0 };
Circle targetCircle = currentCircle;
Circle circleVelocity{ 0 };
Stopwatch stopwatch{ StartImmediately::Yes };
while (System::Update())
{
if (0.86s <= stopwatch)
{
points = nextPoints;
nextPoints = GeneratePoint(RandomVec2(Scene::Rect().scaledAt(Scene::Center(), 0.7)), Min<size_t>((points.size() + 1), 100));
if (points.size() < nextPoints.size())
{
points << points.back();
}
prevPoints = points;
pointVelocities.assign(nextPoints.size(), Vec2::Zero());
targetCircle = Geometry2D::SmallestEnclosingCircle(nextPoints);
stopwatch.restart();
}
for (size_t i = 0; i < points.size(); ++i)
{
points[i] = Math::SmoothDamp(points[i], nextPoints[i], pointVelocities[i], 0.1);
}
if (0.38s < stopwatch)
{
currentCircle.center = Math::SmoothDamp(currentCircle.center, targetCircle.center, circleVelocity.center, 0.05);
currentCircle.r = Math::SmoothDamp(currentCircle.r, targetCircle.r, circleVelocity.r, 0.05);
}
Circle{ Scene::Center(), (Scene::Size().length() / 2) }.draw(ColorF{ 0.4, 0.8, 0.6 }, ColorF{ 0.3, 0.7, 0.5 });
for (int32 y = 0; y <= (Scene::Height() / 40); ++y)
{
for (int32 x = 0; x <= (Scene::Width() / 40); ++x)
{
if (IsEven(y + x))
{
RectF{ (x * 40), (y * 40), 40 }.draw(ColorF{ 0.0, 0.04 });
}
}
}
currentCircle.drawShadow(Vec2{ 2, 2 }, 14, 2).draw(ColorF{ 0.2, 0.5, 0.9 }).drawFrame(6, ColorF{ 0.8, 0.9, 1.0 });
for (size_t i = 0; i < points.size(); ++i)
{
Line{ prevPoints[i], nextPoints[i] }.draw(5, HSV{ (i * 15), 0.5, 1.0, 0.25 });
}
for (const auto& point : points)
{
point.asCircle(6).draw(point.intersects(currentCircle.stretched(0.1)) ? ColorF{ 1.0 } : ColorF{ 0.15 }).drawFrame(2, ColorF{ 0.1 });
}
}
}