Divide Framework
0.1
A free and open-source 3D Framework under heavy development
Loading...
Searching...
No Matches
Dimension.h
Go to the documentation of this file.
1
/*
2
Copyright (c) 2018 DIVIDE-Studio
3
Copyright (c) 2009 Ionut Cava
4
5
This file is part of DIVIDE Framework.
6
7
Permission is hereby granted, free of charge, to any person obtaining a copy
8
of this software
9
and associated documentation files (the "Software"), to deal in the Software
10
without restriction,
11
including without limitation the rights to use, copy, modify, merge, publish,
12
distribute, sublicense,
13
and/or sell copies of the Software, and to permit persons to whom the
14
Software is furnished to do so,
15
subject to the following conditions:
16
17
The above copyright notice and this permission notice shall be included in
18
all copies or substantial portions of the Software.
19
20
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
IMPLIED,
22
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
23
PARTICULAR PURPOSE AND NONINFRINGEMENT.
24
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
25
DAMAGES OR OTHER LIABILITY,
26
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
27
IN CONNECTION WITH THE SOFTWARE
28
OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29
30
*/
31
32
#pragma once
33
#ifndef DVD_CORE_MATH_DIMENSION_H
34
#define DVD_CORE_MATH_DIMENSION_H
35
36
namespace
Divide
{
37
struct
RelativeValue
38
{
39
F32
_scale
{0.f};
40
F32
_offset
{0.f};
41
};
42
43
struct
RelativeSize
44
{
45
F32
_width
{0.f};
46
F32
_height
{0.f};
47
};
48
struct
RelativePosition2D
49
{
50
RelativeValue
_x
;
51
RelativeValue
_y
;
52
};
53
54
struct
RelativeScale2D
55
{
56
RelativeSize
_x
;
57
RelativeSize
_y
;
58
};
59
60
61
inline
RelativePosition2D
pixelPosition
(
const
I32
x,
const
I32
y)
62
{
63
// ToDo: Remove these and use proper offsets from the start -Ionut"
64
return
RelativePosition2D
65
{
66
.
_x
=
RelativeValue
{ .
_offset
=
to_F32
(x) },
67
._y =
RelativeValue
{ .
_offset
=
to_F32
(y) }
68
};
69
}
70
71
inline
RelativePosition2D
pixelPosition
(
const
vec2<I32>
offset)
72
{
73
return
pixelPosition
(offset.
x
, offset.
y
);
74
}
75
76
inline
RelativeScale2D
pixelScale
(
const
I32
x,
const
I32
y)
77
{
78
return
RelativeScale2D
79
{
80
.
_x
=
RelativeSize
{.
_width
=
to_F32
( x ) },
81
._y =
RelativeSize
{.
_height
=
to_F32
( y ) }
82
};
83
}
84
85
inline
RelativeScale2D
pixelScale
(
const
vec2<I32>
scale)
86
{
87
return
pixelScale
(scale.
x
, scale.
y
);
88
}
89
90
}
//namespace Divide
91
92
#endif
//DVD_CORE_MATH_DIMENSION_H
Divide::vec2
Definition:
MathVectors.h:130
Divide::vec2::x
T x
Definition:
MathVectors.h:427
Divide::vec2::y
T y
Definition:
MathVectors.h:427
Divide
Handle console commands that start with a forward slash.
Definition:
AIProcessor.cpp:7
Divide::I32
int32_t I32
Definition:
PlatformDataTypes.h:50
Divide::to_F32
constexpr F32 to_F32(const T value)
Definition:
PlatformDataTypes.h:318
Divide::F32
float F32
Definition:
PlatformDataTypes.h:82
Divide::pixelPosition
RelativePosition2D pixelPosition(const I32 x, const I32 y)
Definition:
Dimension.h:61
Divide::pixelScale
RelativeScale2D pixelScale(const I32 x, const I32 y)
Definition:
Dimension.h:76
Divide::RelativePosition2D
Definition:
Dimension.h:49
Divide::RelativePosition2D::_x
RelativeValue _x
Definition:
Dimension.h:50
Divide::RelativePosition2D::_y
RelativeValue _y
Definition:
Dimension.h:51
Divide::RelativeScale2D
Definition:
Dimension.h:55
Divide::RelativeScale2D::_x
RelativeSize _x
Definition:
Dimension.h:56
Divide::RelativeScale2D::_y
RelativeSize _y
Definition:
Dimension.h:57
Divide::RelativeSize
Definition:
Dimension.h:44
Divide::RelativeSize::_height
F32 _height
Definition:
Dimension.h:46
Divide::RelativeSize::_width
F32 _width
Definition:
Dimension.h:45
Divide::RelativeValue
Definition:
Dimension.h:38
Divide::RelativeValue::_offset
F32 _offset
Definition:
Dimension.h:40
Divide::RelativeValue::_scale
F32 _scale
Definition:
Dimension.h:39
Source
Core
Math
Headers
Dimension.h
Generated on Fri May 17 2024 16:59:49 for Divide Framework by
1.9.6