Skip to content

dtl::XX::YY::setRange

Kasugaccho edited this page Aug 13, 2019 · 1 revision

Select Language ๐ŸŒ

English ๐Ÿ‡ฌ๐Ÿ‡ง / ๆ—ฅๆœฌ่ชž ๐Ÿ‡ฏ๐Ÿ‡ต


// (1)
constexpr auto setRange(const std::size_t point_x_, const std::size_t point_y_, const std::size_t length_) noexcept;

// (2)
constexpr auto setRange(const std::size_t point_x_, const std::size_t point_y_, const std::size_t width_, const std::size_t height_) noexcept;

// (3)
constexpr auto setRange(const dtl::base::MatrixRange& matrix_range_) noexcept;

Overview

Set the drawing range (X, Y, W, H).

Return Value

The return type is a reference value of this class.

Exception

Don't throw exception.

Computational Complexity

Constant time.

Example

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

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::Border<shape_t> border(1);

	border.setRange(2, 1, 8, 5).drawArray(matrix, width, height);

	std::cout << "PointX:" << border.getPointX() << '\n';
	std::cout << "PointY:" << border.getPointY() << '\n';
	std::cout << "Width:" << border.getWidth() << '\n';
	std::cout << "Height:" << border.getHeight() << '\n';

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

	return 0;
}

Output

PointX:2
PointY:1
Width:8
Height:5
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,1,1,1,1,1,1,1,1,0,0,0,0,0,0,
0,0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,
0,0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,
0,0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,
0,0,1,1,1,1,1,1,1,1,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,
////////////////////////////////
////################////////////
////##////////////##////////////
////##////////////##////////////
////##////////////##////////////
////################////////////
////////////////////////////////
////////////////////////////////
Clone this wiki locally