Skip to content

最速入門

Kasugaccho edited this page May 13, 2019 · 3 revisions

DTLをインクルード

ソースコード

#include <DTL.hpp>

int main() {}

出力結果


配列の値を数値出力

ソースコード

#include <DTL.hpp>

int main() {

	int matrix[11][15]{};
	dtl::OutputNumber<int>(",").draw(matrix, 15, 11);

}

出力結果

0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,

長方形の生成

ソースコード

#include <DTL.hpp>

int main() {

	int matrix[11][15]{};
	dtl::Rect<int>(1).draw(matrix, 15, 11);
	dtl::OutputNumber<int>(",").draw(matrix, 15, 11);

}

出力結果

1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,

点グリッドの生成

ソースコード

#include <DTL.hpp>

int main() {

	int matrix[11][15]{};
	dtl::PointGrid<int>(1).draw(matrix, 15, 11);
	dtl::OutputNumber<int>(",").draw(matrix, 15, 11);

}

出力結果

1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,

枠付き点グリッドの生成

ソースコード

#include <DTL.hpp>

int main() {

	int matrix[11][15]{};
	dtl::PointGridWithBorder<int>(1, 2).draw(matrix, 15, 11);
	dtl::OutputNumber<int>(",").draw(matrix, 15, 11);

}

出力結果

2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
2,0,0,0,0,0,0,0,0,0,0,0,0,0,2,
2,0,1,0,1,0,1,0,1,0,1,0,1,0,2,
2,0,0,0,0,0,0,0,0,0,0,0,0,0,2,
2,0,1,0,1,0,1,0,1,0,1,0,1,0,2,
2,0,0,0,0,0,0,0,0,0,0,0,0,0,2,
2,0,1,0,1,0,1,0,1,0,1,0,1,0,2,
2,0,0,0,0,0,0,0,0,0,0,0,0,0,2,
2,0,1,0,1,0,1,0,1,0,1,0,1,0,2,
2,0,0,0,0,0,0,0,0,0,0,0,0,0,2,
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,

文字出力

ソースコード

#include <DTL.hpp>

int main() {

	int matrix[11][15]{};
	dtl::PointGridWithBorder<int>(1, 2).draw(matrix, 15, 11);
	dtl::OutputString<int>("  ", "##", "%%").draw(matrix, 15, 11);

}

出力結果

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%                          %%
%%  ##  ##  ##  ##  ##  ##  %%
%%                          %%
%%  ##  ##  ##  ##  ##  ##  %%
%%                          %%
%%  ##  ##  ##  ##  ##  ##  %%
%%                          %%
%%  ##  ##  ##  ##  ##  ##  %%
%%                          %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

生配列からstd::arrayへ変更

ソースコード

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

int main() {

	std::array<std::array<int, 15>, 11> matrix{ {} };
	dtl::PointGridWithBorder<int>(1, 2).draw(matrix, 15, 11);
	dtl::OutputString<int>("  ", "##", "%%").draw(matrix, 15, 11);

}

出力結果

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%                          %%
%%  ##  ##  ##  ##  ##  ##  %%
%%                          %%
%%  ##  ##  ##  ##  ##  ##  %%
%%                          %%
%%  ##  ##  ##  ##  ##  ##  %%
%%                          %%
%%  ##  ##  ##  ##  ##  ##  %%
%%                          %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

intからchar(1バイト)へ変更

ソースコード

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

int main() {

	std::array<std::array<char, 15>, 11> matrix{ {} };
	dtl::PointGridWithBorder<char>(1, 2).draw(matrix, 15, 11);
	dtl::OutputString<char>("  ", "##", "%%").draw(matrix, 15, 11);

}

出力結果

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%                          %%
%%  ##  ##  ##  ##  ##  ##  %%
%%                          %%
%%  ##  ##  ##  ##  ##  ##  %%
%%                          %%
%%  ##  ##  ##  ##  ##  ##  %%
%%                          %%
%%  ##  ##  ##  ##  ##  ##  %%
%%                          %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

2値化文字出力

ソースコード

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

int main() {

	std::array<std::array<char, 15>, 11> matrix{ {} };
	dtl::Border<char>(1).draw(matrix, 15, 11);
	dtl::OutputStringBool<char>("##", "  ").draw(matrix, 15, 11);

}

出力結果

##############################
##                          ##
##                          ##
##                          ##
##                          ##
##                          ##
##                          ##
##                          ##
##                          ##
##                          ##
##############################
Clone this wiki locally