Line data Source code
1 : /* File: geometry_h_align.inl; Copyright and License: see below */
2 :
3 : #include "u8/u8_trace.h"
4 : #include "u8/u8_log.h"
5 : #include <assert.h>
6 :
7 645 : static inline double geometry_h_align_get_left ( const geometry_h_align_t *this_, double width, double reference_left, double reference_width )
8 : {
9 645 : assert( ( *this_ == GEOMETRY_H_ALIGN_LEFT )||( *this_ == GEOMETRY_H_ALIGN_CENTER )||( *this_ == GEOMETRY_H_ALIGN_RIGHT ) );
10 : double left;
11 :
12 645 : switch ( *this_ )
13 : {
14 3 : case GEOMETRY_H_ALIGN_LEFT:
15 : {
16 3 : left = reference_left;
17 : }
18 3 : break;
19 :
20 641 : case GEOMETRY_H_ALIGN_CENTER:
21 : {
22 641 : left = reference_left + 0.5 * ( reference_width - width );
23 : }
24 641 : break;
25 :
26 1 : default:
27 : case GEOMETRY_H_ALIGN_RIGHT:
28 : {
29 1 : left = reference_left + reference_width - width;
30 : }
31 1 : break;
32 : }
33 :
34 645 : return left;
35 : }
36 :
37 :
38 : /*
39 : Copyright 2017-2025 Andreas Warnke
40 :
41 : Licensed under the Apache License, Version 2.0 (the "License");
42 : you may not use this file except in compliance with the License.
43 : You may obtain a copy of the License at
44 :
45 : http://www.apache.org/licenses/LICENSE-2.0
46 :
47 : Unless required by applicable law or agreed to in writing, software
48 : distributed under the License is distributed on an "AS IS" BASIS,
49 : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
50 : See the License for the specific language governing permissions and
51 : limitations under the License.
52 : */
|