Skip to content

dtl::shape::BorderOdd (形状クラス)

Kasugaccho edited this page Apr 12, 2019 · 17 revisions

バージョン:0.4.X以降

<Shape/BorderOdd.hpp>

namespace dtl::shape {
  template <typename T>
  class BorderOdd;
}

T は1bit以上の型

概要

BorderOddとは "Matrixの描画範囲の周囲1マスに描画値を設置し、描画範囲の列数が偶数の時[列数-2列目]のマスに描画値を設置し、行数が偶数の時[行数-2行目]のマスに描画値を設置する(※行/列は0から数える)" 機能を持つクラスである。

描画範囲の全てを必ず塗りつぶすとは限らない (Matrixの初期化が必要)

例 (C++17)

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

int main() {

	using shape_t = std::uint_fast8_t;
	std::array<std::array<shape_t, 16>, 12> matrix{ {} };

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

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

	return 0;
}

出力

1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,
1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,
1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,
1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,
1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,
1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,
1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,
1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,
1,0,0,0,0,0,0,0,0,0,0,0,0,0,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,
################################
##//////////////////////////####
##//////////////////////////####
##//////////////////////////####
##//////////////////////////####
##//////////////////////////####
##//////////////////////////####
##//////////////////////////####
##//////////////////////////####
##//////////////////////////####
################################
################################

画像

bo border

Clone this wiki locally