OpenTTD Source  1.11.2
zoom_func.h
Go to the documentation of this file.
1 /*
2  * This file is part of OpenTTD.
3  * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4  * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5  * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
6  */
7 
10 #ifndef ZOOM_FUNC_H
11 #define ZOOM_FUNC_H
12 
13 #include "zoom_type.h"
14 
22 static inline int ScaleByZoom(int value, ZoomLevel zoom)
23 {
24  return value << zoom;
25 }
26 
34 static inline int UnScaleByZoom(int value, ZoomLevel zoom)
35 {
36  return (value + (1 << zoom) - 1) >> zoom;
37 }
38 
45 static inline int ScaleByZoomLower(int value, ZoomLevel zoom)
46 {
47  return value << zoom;
48 }
49 
56 static inline int UnScaleByZoomLower(int value, ZoomLevel zoom)
57 {
58  return value >> zoom;
59 }
60 
66 static inline int UnScaleGUI(int value)
67 {
68  return UnScaleByZoom(value, ZOOM_LVL_GUI);
69 }
70 
76 static inline int ScaleGUITrad(int value)
77 {
78  return UnScaleGUI(value * ZOOM_LVL_BASE);
79 }
80 
86 static inline int UnScaleFont(int value)
87 {
88  return UnScaleByZoom(value, ZOOM_LVL_FONT);
89 }
90 
96 static inline int ScaleFontTrad(int value)
97 {
98  return UnScaleFont(value * ZOOM_LVL_BASE);
99 }
100 
101 #endif /* ZOOM_FUNC_H */
UnScaleFont
static int UnScaleFont(int value)
Short-hand to apply font zoom level.
Definition: zoom_func.h:86
UnScaleByZoomLower
static int UnScaleByZoomLower(int value, ZoomLevel zoom)
Scale by zoom level, usually shift right (when zoom > ZOOM_LVL_NORMAL)
Definition: zoom_func.h:56
ScaleFontTrad
static int ScaleFontTrad(int value)
Scale traditional pixel dimensions to Font zoom level.
Definition: zoom_func.h:96
ScaleByZoomLower
static int ScaleByZoomLower(int value, ZoomLevel zoom)
Scale by zoom level, usually shift left (when zoom > ZOOM_LVL_NORMAL)
Definition: zoom_func.h:45
UnScaleGUI
static int UnScaleGUI(int value)
Short-hand to apply GUI zoom level.
Definition: zoom_func.h:66
ZoomLevel
ZoomLevel
All zoom levels we know.
Definition: zoom_type.h:21
UnScaleByZoom
static int UnScaleByZoom(int value, ZoomLevel zoom)
Scale by zoom level, usually shift right (when zoom > ZOOM_LVL_NORMAL) When shifting right,...
Definition: zoom_func.h:34
ScaleByZoom
static int ScaleByZoom(int value, ZoomLevel zoom)
Scale by zoom level, usually shift left (when zoom > ZOOM_LVL_NORMAL) When shifting right,...
Definition: zoom_func.h:22
ScaleGUITrad
static int ScaleGUITrad(int value)
Scale traditional pixel dimensions to GUI zoom level.
Definition: zoom_func.h:76
zoom_type.h