Skip to content

Instantly share code, notes, and snippets.

@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;
@sthairno
sthairno / Main.cpp
Last active January 23, 2022 15:46
単語の区切りを考慮した折返し機能付きテキストレンダラー
# include <Siv3D.hpp> // OpenSiv3D v0.6.3
class TextRenderer
{
public:
TextRenderer(Font& font)
:m_font(font)
{
@sthairno
sthairno / x11clienttest.cpp
Created December 10, 2021 13:05
XIMの検証に使ったコード
#include <iostream>
#include <clocale>
#include <string>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/keysym.h>
#include <list>
#include <cstdlib>
#include <vector>
#include <sstream>
@sthairno
sthairno / Main.cpp
Created August 2, 2020 07:34
S3D_NodeEditor
#include<Siv3D.hpp>
#include<any>
#include<typeinfo>
#include"SasaGUI.hpp"
/// <summary>
/// type_infoをコピー可能にするラッパクラス
/// </summary>
class Type
{
@sthairno
sthairno / HogeGUI.cpp
Last active March 22, 2020 05:38
Siv3D_Window
# include <Siv3D.hpp>
#include"HogeGUI.h"
namespace HogeGUI
{
struct IControl
{
ID id;
bool used;
RectF rect;