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/*
2Copyright (c) 2018 DIVIDE-Studio
3Copyright (c) 2009 Ionut Cava
4
5This file is part of DIVIDE Framework.
6
7Permission is hereby granted, free of charge, to any person obtaining a copy
8of this software
9and associated documentation files (the "Software"), to deal in the Software
10without restriction,
11including without limitation the rights to use, copy, modify, merge, publish,
12distribute, sublicense,
13and/or sell copies of the Software, and to permit persons to whom the
14Software is furnished to do so,
15subject to the following conditions:
16
17The above copyright notice and this permission notice shall be included in
18all copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21IMPLIED,
22INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
23PARTICULAR PURPOSE AND NONINFRINGEMENT.
24IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
25DAMAGES OR OTHER LIABILITY,
26WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
27IN CONNECTION WITH THE SOFTWARE
28OR 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
36namespace Divide {
38 {
39 F32 _scale {0.f};
41 };
42
44 {
45 F32 _width{0.f};
47 };
49 {
52 };
53
55 {
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"
65 {
66 ._x = RelativeValue{ ._offset = to_F32(x) },
67 ._y = RelativeValue{ ._offset = to_F32(y) }
68 };
69 }
70
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
86 {
87 return pixelScale(scale.x, scale.y);
88 }
89
90} //namespace Divide
91
92#endif //DVD_CORE_MATH_DIMENSION_H
Handle console commands that start with a forward slash.
Definition: AIProcessor.cpp:7
int32_t I32
constexpr F32 to_F32(const T value)
RelativePosition2D pixelPosition(const I32 x, const I32 y)
Definition: Dimension.h:61
RelativeScale2D pixelScale(const I32 x, const I32 y)
Definition: Dimension.h:76