Home

Reputeless edited this page Jan 12, 2017 · 6 revisions

:jp: 日本語

About Siv3D

Supports

Tutorials

  1. Basic Concept
  2. Draw a Shape
  3. Draw a Texture
  4. Draw a Text
  5. Formatting
  6. Keyboard Input
  7. Mouse Input
  8. Audio Playback
  9. MIDI Playback
  10. Window and Background
  11. 2D Collision
  12. Random Number
  13. Dialog
  14. Drag and Drop
  15. Application State
  16. Text File
  17. INI, CSV, JSON
  18. Binary File
  19. GUI
  20. Asset Management
  21. Image Processing
  22. Webcam
  23. Audio Recording
  24. Stopwatch
  25. HSV Color
  26. HTTP Client
  27. 3D Rendering
  28. 2D Render States
  29. 3D Render States
  30. Particles
  31. Screen Capture
  32. Publish Your App
  33. Learn More

Reference

学習コース

表現テクニック集

Human Interface Devices

Examples

開発のヒント

管理用 [記事編集ガイドライン](https://github.com/Siv3D/Reference-JP/wiki/記事編集ガイドライン)
Clone this wiki locally

A free C++ library for games and interactive media

Siv3D is a C++ library for games and interactive media. It supports many input devices such as Kinect, Leap Motion, webcams and microphones, and complex interactions can be coded in a few lines.

Small, Modern, Functional

The best tool to enjoy application development.


SMALL CODE

数行~数十行のコードでインタラクティブなアプリケーションを開発できます。短時間で結果が得られるため、大学や専門学校のプログラミング教育でも活用されています。

IMAGE & AUDIO PROCESSING

音楽の再生や画像の表示、テンポやピッチの変更、波形編集、画像加工、AR マーカーの検出、Twitter への画像投稿といった様々な処理を易しいコードで実現します。

SUPPORTS 10+ INPUT DEVICES

Kinect, Leap Motion, マイク、Web カメラ、ペンタブ、ゲームコントローラ、マルチタッチ、Arduino など、10 種類以上の入力機器を、2, 3 行のコードの追加で活用できます。

STATE OF THE ART C++

すべてのコードが最新の C++11/14 規格で書かれているため、Siv3D を使うことで新しい C++ の書き方を学習できます。(最新の C++ について知りたい方は [こちら](http://www.slideshare.net/Reputeless/c11c14))

The shortest distance to completion

洗練されたコードで、あらゆるアイデアを明快に表現します。

Shape and text
```cpp # include

void Main() { const Font font(30);

while (System::Update())
{
    Circle(Mouse::Pos(), 100).draw();

    font(Mouse::Pos()).draw(50, 200, Palette::Orange);
}

}


<img src="https://github.com/Siv3D/Reference-JP/blob/master/resource/siv3d/top2.gif?raw=true" width="320" height="240" align="left">
Paint<br clear="left">
```cpp
# include <Siv3D.hpp>

void Main()
{
	Image image(Window::Size(), Palette::White);

	DynamicTexture texture(image);

	while (System::Update())
	{
		if (Input::MouseL.pressed)
		{
			Line(Mouse::PreviousPos(), Mouse::Pos()).overwrite(image, 8, Palette::Orange);

			texture.fill(image);
		}

		texture.draw();
	}
}
Breakout
```cpp # include

void Main() { const Size blockSize(40, 20); const double speed = 8.0; Rect wall(60, 10); Circle ball(320, 400, 8); Vec2 ballSpeed(0, -speed);

Array<Rect> blocks;
for (auto p : step({ Window::Width() / blockSize.x , 5 }))
{
	blocks.emplace_back((p*blockSize).moveBy(0, 60), blockSize);
}

while (System::Update())
{
	ball.moveBy(ballSpeed);
	wall.setCenter(Mouse::Pos().x, 420);

	for (auto it = blocks.begin(); it != blocks.end(); ++it)
	{
		if (it->intersects(ball))
		{
			(it->bottom.intersects(ball) || it->top.intersects(ball)
				? ballSpeed.y : ballSpeed.x) *= -1;

			blocks.erase(it);
			break;
		}
	}

	for (auto const& block : blocks)
	{
		block.stretched(-1).draw(HSV(block.y - 40));
	}

	if (ball.y < 0 && ballSpeed.y <  0)
	{
		ballSpeed.y *= -1;
	}

	if ((ball.x < 0 && ballSpeed.x < 0) || (Window::Width() < ball.x && ballSpeed.x > 0))
	{
		ballSpeed.x *= -1;
	}

	if (ballSpeed.y > 0 && wall.intersects(ball))
	{
		ballSpeed = Vec2((ball.x - wall.center.x) / 8, -ballSpeed.y).setLength(speed);
	}

	ball.draw();
	wall.draw();
}

}


<img src="https://github.com/Siv3D/Reference-JP/blob/master/resource/siv3d/top4.gif?raw=true" width="320" height="240" align="left">
Kaleidoscope<br clear="left">
```cpp
# include <Siv3D.hpp>

void Main()
{
	const int32 N = 12;

	Image image(Window::Size(), Color(20, 40, 60));

	DynamicTexture texture(image);

	Mouse::SetTransform(Mat3x2::Translate(Window::Center()));

	while (System::Update())
	{
		if (Input::MouseL.pressed)
		{
			for (auto i : step(N))
			{
				Circular cs[2] = { Input::MouseL.clicked ? Mouse::Pos() : Mouse::PreviousPos(), Mouse::Pos() };

				for (auto& c : cs)
				{
					c.theta = i % 2 ? -c.theta - TwoPi / N * (i - 1) : c.theta + TwoPi / N * i;
				}

				Line(cs[0], cs[1]).moveBy(Window::Center()).overwrite(image, 2, HSV(System::FrameCount(), 0.5, 1.0));
			}

			texture.tryFill(image);
		}
		else if (Input::MouseR.clicked)
		{
			image.fill(Color(20, 40, 60));

			texture.fill(image);
		}

		texture.draw();
	}
}
Face detection
Illustration by [古古米](http://www.pixiv.net/member.php?id=583587) ```cpp # include

void Main() { Texture texture;

Array<Rect> faces;

while (System::Update())
{
	if (Dragdrop::HasItems())
	{
		if (Image image{ Dragdrop::GetFilePaths()[0] })
		{
			faces = Imaging::DetectFaces(image, CascadeType::Anime);

			texture = Texture(image);

			Window::Resize(texture.size);
		}
	}

	texture.draw();

	const double a = Sin(Time::GetMillisec() * 0.005) * 0.5 + 0.5;

	for (const auto& face : faces)
	{
		face.drawFrame(3, 3, ColorF(Palette::Red, a));
	}
}

}


<img src="https://github.com/Siv3D/Reference-JP/blob/master/resource/siv3d/top6.gif?raw=true" width="320" height="240" align="left">
Audio spectrum<br clear="left">
```cpp
# include <Siv3D.hpp>

void Main()
{
	const Sound sound = Dialog::OpenSound();

	sound.play();

	while (System::Update())
	{
		const auto fft = FFT::Analyze(sound);

		for (auto i : step(320))
		{
			RectF(i * 2, Window::Height(), 2, -Pow(fft.buffer[i], 0.6) * 1000).draw(HSV(240 - i));
		}
	}
}
Kinect
```cpp # include

void Main() { KinectV2::Start();

DynamicTexture depthTexture;

std::array<Optional<KinectV2Body>, 6> bodies;

while (System::Update())
{
	if (KinectV2::HasNewDepthFrame())
	{
		KinectV2::GetDepthFrame(depthTexture);
	}

	if (KinectV2::HasNewBodyFrame())
	{
		KinectV2::GetBodyFrame(bodies);
	}

	depthTexture.draw();

	for (const auto& body : bodies)
	{
		if (body)
		{
			for (const auto& joint : body->joints)
			{
				Circle(joint.depthSpacePos, 15).drawFrame(6.0, 0.0, Palette::Red);
			}
		}
	}
}

}


<img src="https://github.com/Siv3D/Reference-JP/blob/master/resource/siv3d/top8.gif?raw=true" width="320" height="240" align="left">
Earth<br clear="left">
```cpp
# include <Siv3D.hpp>

void Main()
{
	const Texture texture(L"Example/Earth.jpg", TextureDesc::For3D);

	while (System::Update())
	{
		Graphics3D::FreeCamera();

		const double yaw = Time::GetMillisec() * -0.0001;

		Sphere(10, Quaternion::Yaw(yaw).roll(-23.4_deg)).draw(texture);
	}
}