FastUIDraw
fastuidraw_spread.glsl.hpp
Go to the documentation of this file.
1 /*!
2  * \file fastuidraw_spread.glsl.hpp
3  * \brief file fastuidraw_spread.glsl.hpp
4  *
5  * Copyright 2018 by Intel.
6  *
7  * Contact: kevin.rogovin@gmail.com
8  *
9  * This Source Code Form is subject to the
10  * terms of the Mozilla Public License, v. 2.0.
11  * If a copy of the MPL was not distributed with
12  * this file, You can obtain one at
13  * http://mozilla.org/MPL/2.0/.
14  *
15  * \author Kevin Rogovin <kevin.rogovin@gmail.com>
16  *
17  */
18 
19 /*!\addtogroup GLSLVertFragCode
20  * @{
21  */
22 
23 /*! \brief compute mirror spread pattern on [0, 1] */
24 float
26 {
27  return clamp(abs(t), 0.0, 1.0);
28 }
29 
30 /*! \brief compute repeat spread pattern on [0, 1] */
31 float
33 {
34  return fract(t);
35 }
36 
37 /*! \brief compute mirror-repeat spread pattern on [0, 1] */
38 float
40 {
41  return 1.0 - abs(mod(t, 2.0) - 1.0);
42 }
43 
44 /*! \brief compute clamp spread pattern on [0, 1] */
45 float
47 {
48  return clamp(t, 0.0, 1.0);
49 }
50 
51 /*! \brief compute mirror spread pattern on [0, range] */
52 float
53 fastuidraw_compute_mirror_spread(float t, float range)
54 {
55  return clamp(abs(t), 0.0, range);
56 }
57 
58 /*! \brief compute repeat spread pattern on [0, range] */
59 float
60 fastuidraw_compute_repeat_spread(float t, float range)
61 {
62  return mod(t, range);
63 }
64 
65 /*! \brief compute mirror-repeat spread pattern on [0, range] */
66 float
68 {
69  return range - abs(mod(t, 2.0 * range) - range);
70 }
71 
72 /*! \brief compute clamp spread pattern on [0, range] */
73 float
74 fastuidraw_compute_clamp_spread(float t, float range)
75 {
76  return clamp(t, 0.0, range);
77 }
78 
79 /*! \brief compute mirror spread pattern on [begin_range, end_range] */
80 float
81 fastuidraw_compute_mirror_spread(float t, float begin_range, float end_range)
82 {
83  return begin_range + fastuidraw_compute_mirror_spread(t - begin_range, end_range - begin_range);
84 }
85 
86 /*! \brief compute repeat spread pattern on [begin_range, end_range] */
87 float
88 fastuidraw_compute_repeat_spread(float t, float begin_range, float end_range)
89 {
90  return begin_range + fastuidraw_compute_repeat_spread(t - begin_range, end_range - begin_range);
91 }
92 
93 /*! \brief compute mirror-repeat spread pattern on [begin_range, end_range] */
94 float
95 fastuidraw_compute_mirror_repeat_spread(float t, float begin_range, float end_range)
96 {
97  return begin_range + fastuidraw_compute_mirror_repeat_spread(t - begin_range, end_range - begin_range);
98 }
99 
100 /*! \brief compute clamp spread pattern on [begin_range, end_range] */
101 float
102 fastuidraw_compute_clamp_spread(float t, float begin_range, float end_range)
103 {
104  return clamp(t, begin_range, end_range);
105 }
106 /*! @} */
float fastuidraw_compute_mirror_repeat_spread(float t)
compute mirror-repeat spread pattern on [0, 1]
float fastuidraw_compute_repeat_spread(float t)
compute repeat spread pattern on [0, 1]
float fastuidraw_compute_mirror_spread(float t)
compute mirror spread pattern on [0, 1]
float fastuidraw_compute_clamp_spread(float t)
compute clamp spread pattern on [0, 1]