Skip to content

Instantly share code, notes, and snippets.

@sknjpn
sknjpn / gist:21ffa1d4c73865fc55488e9aa0cd1265
Created September 8, 2019 05:29
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);
@sknjpn
sknjpn / OutlineDetector.h
Last active September 23, 2019 07:06
OutlineDetector
#pragma once
Array<Array<Vec2>> GetOutlines(const Image& image, function<bool(Color)> judge)
{
const Point directions[8] = { { 1, 0 }, { 1, 1 }, { 0, 1 }, { -1, 1 }, { -1, 0 }, { -1, -1 }, { 0, -1 }, { 1, -1 } };
const Rect rect(image.size());
const int width = image.width();
const int height = image.height();
Grid<bool> map(width, height, false);
Array<Point> startPositions;
#pragma once
# include <Siv3D.hpp>
class TileMap;
class Tile
{
friend TileMap;
# include <Siv3D.hpp> // OpenSiv3D v0.2.7
class WatchfulEye
{
Vec2 m_position;
Vec2 m_aimed;
Vec2 m_target;
double m_degree;
double m_timer;
double m_size;
# pragma once
# include <Siv3D.hpp> // OpenSiv3D v0.2.6
class BasicCamera2D
{
protected:
Vec2 m_center = Window::BaseSize() * 0.5;
double m_magnification = 1.0;
public:
# include <Siv3D.hpp> // OpenSiv3D v0.2.5
class Node
{
Vec2 m_position; //物理的な座標
Point m_point; //仮想上の座標
double m_height; //高度
double m_radius; //半径
Polygon m_polygon; //形状
Array<Node*> m_near_nodes;
# include <Siv3D.hpp> // OpenSiv3D v0.2.5
class Node
{
Vec2 m_position; //物理的な座標
Point m_point; //仮想上の座標
public:
Node(Point point)
: m_point(point)
#include<Siv3D.hpp>
struct Unit
{
bool enabled;
Point pos;
Unit()
: enabled(true)
, pos(Random(640), Random(480))
//Export
for (int i = 0; i < 2; i++)
{
auto t = tinyCamera.createTransformer(i);
for (auto& e : exports)
{
if ((ui.drawExportLineEnabled && (ui.selectedItemType == -1 || ui.selectedItemType == e.itemType)) || (ui.selectedUrbanID != -1 && (e.from->id() == ui.selectedUrbanID || e.to->id() == ui.selectedUrbanID)))
{
double width = 0.005*e.numItemPerDay;
@sknjpn
sknjpn / TinyCamera2D
Created July 10, 2017 14:28
Camera2Dと同様に使えるカメラ。サンプル付き。
# include <Siv3D.hpp> // OpenSiv3D v0.1.5
struct TinyCamera2D
{
TinyCamera2D() = default;
void update()
{
const Transformer2D t1(Mat3x2::Translate(-sRegion.pos).scale(Window::Size().y / sRegion.size.y), true);
//描画領域をマウスホイールで操作する
dRegion = dRegion.scaledAt(Cursor::PosF(), 1 + Mouse::Wheel() / 10.0);