Skip to content

Instantly share code, notes, and snippets.

@sthairno
sthairno / Redis_Siv3D.cpp
Created December 27, 2024 22:21
OpenSiv3Dにredis-plus-plusを組み込んでみた実験
#include <Siv3D.hpp> // Siv3D v0.6.15
#include <sw/redis++/redis++.h>
void Main()
{
Window::Resize(400, 300);
// Redisサーバーに接続
sw::redis::ConnectionOptions options;
options.type = sw::redis::ConnectionType::TCP;
@sthairno
sthairno / DrawStripe.cpp
Created December 24, 2024 03:39
OpenSiv3Dで縞模様を描く
#include <Siv3D.hpp>
void DrawStripe(const Rect& rect, double angle, double barWidth, const Array<ColorF>& pattern = { Palette::Yellow, Palette::Black })
{
// 傾けたときの描画範囲を計算
const auto renderRect =
RectF{ 0, 0, rect.size }.asQuad()
.rotatedAt(0, 0, -angle)
.boundingRect();
@sthairno
sthairno / Main.cpp
Last active October 20, 2024 09:21
OpenSiv3Dで某アクションゲームのメニュー画面を再現したデモ
#include <Siv3D.hpp>
#include <FlexLayout.hpp>
struct Item
{
String emoji;
int level;
};
@sthairno
sthairno / Dockerfile
Created March 27, 2024 06:53
Container which builds and installs OpenSiv3D
FROM ubuntu:22.04
ARG SIV3D_VERSION="main"
ARG GCC_OPTIONS="-j4"
RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y \
git \
build-essential \
cmake \
@sthairno
sthairno / ScrollBar.cpp
Last active June 8, 2023 18:43
アニメーション付きのヌルヌル動くスクロールバー
# include <Siv3D.hpp>
namespace SasaGUI
{
namespace Config
{
struct ScrollBar
{
// | ______________ |
// | =======|______________|== |
@sthairno
sthairno / DelayRepeat.cpp
Created April 3, 2023 06:33
ディレイとリピート機能を簡単に実装できるやつ
# include <Siv3D.hpp> // OpenSiv3D v0.6.6
class Delay
{
public:
constexpr Delay(Duration duration) noexcept
: m_duration(duration.count())
{
assert(duration >= 0s);
@sthairno
sthairno / Builder.cpp
Created July 26, 2022 16:01
即時モードのUI定義 egui風サンプル
#include "Builder.hpp"
namespace GUI
{
BuilderContext::BuilderContext(Widget& root)
: m_root(root)
{
reset();
}
@sthairno
sthairno / GuruGuruUI.cpp
Created June 11, 2022 08:03
角度を指定するUI
#include <Siv3D.hpp> // OpenSiv3D v0.6.4
void DrawAngleText(const Font& font, const Circle& circle, double angle, ColorF color)
{
const auto degText = font(U"{:.1f}"_fmt(ToDegrees(angle)));
degText.region(Arg::topCenter = circle.center + Vec2{ 0, circle.r + 2 }).draw(ColorF(Scene::GetBackground(), 0.8));
degText.draw(Arg::topCenter = circle.center + Vec2{ 0, circle.r + 2 }, color);
}
void Main()
@sthairno
sthairno / Main.cpp
Last active February 1, 2022 06:13
線(LineString)の特徴から図形(線, 円, ポリゴン, 三角形, 四角形)を検出するプログラム
# include <Siv3D.hpp> // OpenSiv3D v0.6.3
struct Arc
{
Vec2 center;
double r;
double startAngle;