extent: add rotate90
This commit is contained in:
parent
8eca4175ec
commit
38e1ce63fd
19
extent.cpp
19
extent.cpp
@ -76,6 +76,25 @@ extent<S,T>::empty (void) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
template <typename T>
|
||||||
|
cruft::extent2<T>
|
||||||
|
cruft::rotate90 (cruft::extent2<T> obj, int steps)
|
||||||
|
{
|
||||||
|
if (steps % 2) {
|
||||||
|
return { obj.h, obj.w };
|
||||||
|
} else {
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
template cruft::extent2<i32> cruft::rotate90 (cruft::extent2<i32>, int);
|
||||||
|
template cruft::extent2<i64> cruft::rotate90 (cruft::extent2<i64>, int);
|
||||||
|
template cruft::extent2<f32> cruft::rotate90 (cruft::extent2<f32>, int);
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
namespace cruft::debug {
|
namespace cruft::debug {
|
||||||
template <size_t S, typename T>
|
template <size_t S, typename T>
|
||||||
|
53
extent.hpp
53
extent.hpp
@ -3,11 +3,10 @@
|
|||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
*
|
*
|
||||||
* Copyright 2010-2017 Danny Robson <danny@nerdcruft.net>
|
* Copyright 2010-2020, Danny Robson <danny@nerdcruft.net>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef CRUFT_UTIL_EXTENT_HPP
|
#pragma once
|
||||||
#define CRUFT_UTIL_EXTENT_HPP
|
|
||||||
|
|
||||||
#include "coord/fwd.hpp"
|
#include "coord/fwd.hpp"
|
||||||
#include "coord/base.hpp"
|
#include "coord/base.hpp"
|
||||||
@ -158,6 +157,28 @@ namespace cruft {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
// convenience typedefs
|
||||||
|
template <typename T> using extent2 = extent<2,T>;
|
||||||
|
template <typename T> using extent3 = extent<3,T>;
|
||||||
|
|
||||||
|
template <size_t S> using extentu = extent<S,unsigned>;
|
||||||
|
template <size_t S> using extenti = extent<S,int>;
|
||||||
|
template <size_t S> using extentf = extent<S,float>;
|
||||||
|
template <size_t S> using extentd = extent<S,double>;
|
||||||
|
|
||||||
|
|
||||||
|
typedef extent2<int> extent2i;
|
||||||
|
typedef extent2<unsigned> extent2u;
|
||||||
|
typedef extent2<float> extent2f;
|
||||||
|
typedef extent2<double> extent2d;
|
||||||
|
|
||||||
|
|
||||||
|
typedef extent3<unsigned> extent3u;
|
||||||
|
typedef extent3<float> extent3f;
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
template <size_t S, typename T>
|
template <size_t S, typename T>
|
||||||
cruft::point<S,T>
|
cruft::point<S,T>
|
||||||
sample (cruft::extent<S,T> shape)
|
sample (cruft::extent<S,T> shape)
|
||||||
@ -181,26 +202,8 @@ namespace cruft {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
//-------------------------------------------------------------------------
|
||||||
// convenience typedefs
|
template <typename T>
|
||||||
template <typename T> using extent2 = extent<2,T>;
|
extent2<T>
|
||||||
template <typename T> using extent3 = extent<3,T>;
|
rotate90 (extent2<T> val, int steps);
|
||||||
|
|
||||||
template <size_t S> using extentu = extent<S,unsigned>;
|
|
||||||
template <size_t S> using extenti = extent<S,int>;
|
|
||||||
template <size_t S> using extentf = extent<S,float>;
|
|
||||||
template <size_t S> using extentd = extent<S,double>;
|
|
||||||
|
|
||||||
|
|
||||||
typedef extent2<int> extent2i;
|
|
||||||
typedef extent2<unsigned> extent2u;
|
|
||||||
typedef extent2<float> extent2f;
|
|
||||||
typedef extent2<double> extent2d;
|
|
||||||
|
|
||||||
|
|
||||||
typedef extent3<unsigned> extent3u;
|
|
||||||
typedef extent3<float> extent3f;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
Loading…
Reference in New Issue
Block a user