-
-
Notifications
You must be signed in to change notification settings - Fork 87
Expand file tree
/
Copy pathSimpleTruncatedSquarePyramid.hpp
More file actions
113 lines (93 loc) · 5.23 KB
/
SimpleTruncatedSquarePyramid.hpp
File metadata and controls
113 lines (93 loc) · 5.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
/*#######################################################################################
Copyright (c) 2017-2019 Kasugaccho
Copyright (c) 2018-2019 As Project
https://github.com/Kasugaccho/DungeonTemplateLibrary
wanotaitei@gmail.com
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#######################################################################################*/
#ifndef INCLUDED_DUNGEON_TEMPLATE_LIBRARY_DTL_SHAPE_SIMPLE_TRUNCATED_SQUARE_PYRAMID_HPP
#define INCLUDED_DUNGEON_TEMPLATE_LIBRARY_DTL_SHAPE_SIMPLE_TRUNCATED_SQUARE_PYRAMID_HPP
/*#######################################################################################
日本語リファレンス (Reference-JP)
https://github.com/Kasugaccho/DungeonTemplateLibrary/wiki/dtl::shape::SimpleTruncatedSquarePyramid-(形状クラス)/
#######################################################################################*/
#include <DTL/Base/Struct.hpp>
#include <DTL/Macros/constexpr.hpp>
#include <DTL/Macros/nodiscard.hpp>
#include <DTL/Type/Forward.hpp>
#include <DTL/Type/Min.hpp>
#include <DTL/Type/SizeT.hpp>
#include <DTL/Range/RectBaseWithValueMaxMin.hpp>
#include <DTL/Utility/DrawJagged.hpp>
/*#######################################################################################
[概要] "dtl名前空間"とは"DungeonTemplateLibrary"の全ての機能が含まれる名前空間である。
[Summary] The "dtl" is a namespace that contains all the functions of "DungeonTemplateLibrary".
#######################################################################################*/
namespace dtl {
inline namespace shape { //"dtl::shape"名前空間に属する
/*#######################################################################################
[概要] SimpleTruncatedSquarePyramidとは "Matrixの描画範囲に描画値を設置する" 機能を持つクラスである。
[Summary] SimpleTruncatedSquarePyramid is a class that sets drawing values in the drawing range of Matrix.
#######################################################################################*/
template<typename Matrix_Var_>
class SimpleTruncatedSquarePyramid : public ::dtl::range::RectBaseWithValueMaxMin<SimpleTruncatedSquarePyramid<Matrix_Var_>, Matrix_Var_>,
public ::dtl::utility::DrawJagged<SimpleTruncatedSquarePyramid<Matrix_Var_>, Matrix_Var_> {
private:
///// エイリアス (Alias) /////
using Index_Size = ::dtl::type::size;
using ShapeBase_t = ::dtl::range::RectBaseWithValueMaxMin<SimpleTruncatedSquarePyramid, Matrix_Var_>;
using DrawBase_t = ::dtl::utility::DrawJagged<SimpleTruncatedSquarePyramid, Matrix_Var_>;
friend DrawBase_t;
///// 基本処理 /////
//STL
template<typename Matrix_, typename ...Args_>
DTL_VERSIONING_CPP14_CONSTEXPR
typename DTL_TYPE_ENABLE_IF<Matrix_::is_jagged::value, bool>::DTL_TYPE_EITYPE
drawNormal(Matrix_&& matrix_, Args_&& ... args_) const noexcept {
const Index_Size end_y_{ this->calcEndY(matrix_.getY()) - this->start_y };
const Index_Size mid_y_{ end_y_ / 2 };
for (Index_Size row{}; row < end_y_; ++row) {
Index_Size row2{ (row > mid_y_) ? end_y_ - row - 1 : row };
const Index_Size end_x_{ this->calcEndX(matrix_.getX()) - this->start_x };
const Index_Size mid_x_{ end_x_ / 2 };
for (Index_Size col{}; col < end_x_; ++col) {
Index_Size col2{ (col > mid_x_) ? end_x_ - col - 1 : col };
const Matrix_Var_ set_value{ static_cast<Matrix_Var_>(this->min_value +
static_cast<Matrix_Var_>(DTL_TYPE_MIN(
static_cast<double>(this->max_value - this->min_value) * row2 / mid_y_,
static_cast<double>(this->max_value - this->min_value) * col2 / mid_x_))) };
matrix_.set(col + this->start_x, row + this->start_y, (set_value > this->draw_value) ? this->draw_value : set_value, args_...);
}
}
return true;
}
//Normal
template<typename Matrix_, typename ...Args_>
DTL_VERSIONING_CPP14_CONSTEXPR
typename DTL_TYPE_ENABLE_IF<!Matrix_::is_jagged::value, bool>::DTL_TYPE_EITYPE
drawNormal(Matrix_&& matrix_, Args_&& ... args_) const noexcept {
const Index_Size end_x_{ this->calcEndX(matrix_.getX()) - this->start_x };
const Index_Size end_y_{ this->calcEndY(matrix_.getY()) - this->start_y };
const Index_Size mid_x_{ end_x_ / 2 };
const Index_Size mid_y_{ end_y_ / 2 };
for (Index_Size row{}; row < end_y_; ++row) {
Index_Size row2{ (row > mid_y_) ? end_y_ - row - 1 : row };
for (Index_Size col{}; col < end_x_; ++col) {
Index_Size col2{ (col > mid_x_) ? end_x_ - col - 1 : col };
const Matrix_Var_ set_value{ static_cast<Matrix_Var_>(this->min_value +
static_cast<Matrix_Var_>(DTL_TYPE_MIN(
(static_cast<double>(this->max_value) - static_cast<double>(this->min_value)) * row2 / mid_y_,
(static_cast<double>(this->max_value) - static_cast<double>(this->min_value)) * col2 / mid_x_))) };
matrix_.set(col + this->start_x, row + this->start_y, (set_value > this->draw_value) ? this->draw_value : set_value, args_...);
}
}
return true;
}
public:
///// コンストラクタ (Constructor) /////
using ShapeBase_t::ShapeBase_t;
};
}
}
#endif //Included Dungeon Template Library