Skip to content

dtl::XX::YY::drawAdd (形状描画)

Kasugaccho edited this page Aug 12, 2019 · 2 revisions

Select Language 🌐

English 🇬🇧 / 日本語 🇯🇵


// (1) STL
template<typename Matrix_>
constexpr bool drawAdd(Matrix_&& matrix_) const noexcept;

// (2) LayerSTL
template<typename Matrix_>
constexpr bool drawAdd(Matrix_&& matrix_, const std::size_t layer_) const noexcept;

// (3) Normal
template<typename Matrix_>
constexpr bool drawAdd(Matrix_&& matrix_, const std::size_t max_x_, const std::size_t max_y_) const noexcept;

// (4) LayerNormal
template<typename Matrix_>
constexpr bool drawAdd(Matrix_&& matrix_, const std::size_t layer_, const std::size_t max_x_, const std::size_t max_y_) const noexcept;

概要

Matrixに描画する。

戻り値

戻り値の型は全てにおいて bool である。

戻り値 説明
false 描画に失敗したことを示す
true 描画に成功したことを示す

例外

投げない

計算量

基本的にはO(n^2)である。 ※一部、例外がある。

(1) STL の例

#include <DTL.hpp>
#include <cstddef>
#include <cstdint>
#include <array>

int main() {

	using shape_t = std::uint_fast8_t;
	constexpr std::size_t width{ 16 };
	constexpr std::size_t height{ 8 };

	std::array<std::array<shape_t, width>, height> matrix{ {} };

	dtl::shape::Rect<shape_t>(1).draw(matrix);
	dtl::shape::Rect<shape_t>(1).drawAdd(matrix);

	dtl::console::OutputNumber<shape_t>(",").draw(matrix);
	dtl::console::OutputString<shape_t>("//", "##", "%%").draw(matrix);

	return 0;
}

出力

2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

(2) LayerSTL の例

#include <DTL.hpp>
#include <cstddef>
#include <cstdint>
#include <array>

int main() {

	using shape_t = std::uint_fast8_t;
	constexpr std::size_t width{ 16 };
	constexpr std::size_t height{ 8 };
	constexpr std::size_t layer_max{ 2 };
	constexpr std::size_t draw_layer{ 1 };

	std::array<std::array<std::array<shape_t, layer_max>, width>, height> matrix{ {} };

	dtl::shape::Rect<shape_t>(1).draw(matrix, draw_layer);
	dtl::shape::Rect<shape_t>(1).drawAdd(matrix, draw_layer);

	dtl::console::OutputNumber<shape_t>(",").draw(matrix, draw_layer);
	dtl::console::OutputString<shape_t>("//", "##", "%%").draw(matrix, draw_layer);

	return 0;
}

出力

2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

(3) Normal の例

#include <DTL.hpp>
#include <cstddef>
#include <cstdint>
#include <array>

int main() {

	using shape_t = std::uint_fast8_t;
	constexpr std::size_t width{ 16 };
	constexpr std::size_t height{ 8 };

	shape_t matrix[height][width]{};

	dtl::shape::Rect<shape_t>(1).draw(matrix, width, height);
	dtl::shape::Rect<shape_t>(1).drawAdd(matrix, width, height);

	dtl::console::OutputNumber<shape_t>(",").draw(matrix, width, height);
	dtl::console::OutputString<shape_t>("//", "##", "%%").draw(matrix, width, height);

	return 0;
}

出力

2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

(4) LayerNormal の例

#include <DTL.hpp>
#include <cstddef>
#include <cstdint>
#include <array>

int main() {

	using shape_t = std::uint_fast8_t;
	constexpr std::size_t width{ 16 };
	constexpr std::size_t height{ 8 };
	constexpr std::size_t layer_max{ 2 };
	constexpr std::size_t draw_layer{ 1 };

	shape_t matrix[height][width][layer_max]{};

	dtl::shape::Rect<shape_t>(1).draw(matrix, draw_layer, width, height);
	dtl::shape::Rect<shape_t>(1).drawAdd(matrix, draw_layer, width, height);

	dtl::console::OutputNumber<shape_t>(",").draw(matrix, draw_layer, width, height);
	dtl::console::OutputString<shape_t>("//", "##", "%%").draw(matrix, draw_layer, width, height);

	return 0;
}

出力

2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Clone this wiki locally