File tree Expand file tree Collapse file tree 10 files changed +1598
-1
lines changed Expand file tree Collapse file tree 10 files changed +1598
-1
lines changed Original file line number Diff line number Diff line change 1
1
package glm_.func
2
2
3
+ import glm_.d
4
+ import glm_.i
3
5
import glm_.vec2.Vec2
4
6
import glm_.vec2.Vec2d
5
7
import glm_.vec3.Vec3
@@ -212,6 +214,7 @@ interface func_exponential {
212
214
213
215
fun log2 (a : Double ) = _log2 (a)
214
216
fun log2 (a : Float ) = _log2 (a)
217
+ fun log2 (a : Int ) = _log2 (a.d).i
215
218
216
219
fun log2 (a : Vec2 , res : Vec2 = Vec2 ()) {
217
220
res.x = log2(a.x)
Original file line number Diff line number Diff line change @@ -58,7 +58,11 @@ object glm :
58
58
packing,
59
59
func_packing,
60
60
61
- random {
61
+ random,
62
+
63
+ optimumPow,
64
+
65
+ gradientPaint {
62
66
63
67
@JvmField
64
68
val detail = Detail
Original file line number Diff line number Diff line change
1
+ package glm_
2
+
3
+ import glm_.vec2.Vec2
4
+
5
+ interface gradientPaint {
6
+
7
+ fun radialGradient (
8
+ center : Vec2 ,
9
+ radius : Float ,
10
+ focal : Vec2 ,
11
+ position : Vec2
12
+ ): Float {
13
+ val fX = focal.x - center.x
14
+ val fY = focal.y - center.y
15
+ val dX = position.x - focal.x
16
+ val dY = position.y - focal.y
17
+ val radius2 = glm.pow2(radius)
18
+ val fX2 = glm.pow2(fX)
19
+ val fY2 = glm.pow2(fY)
20
+
21
+ val numerator = (dX * fX + dY * fY) + glm.sqrt(radius2 * (glm.pow2(dX) + glm.pow2(dY)) - glm.pow2(dX * fY - dY * fX))
22
+ val denominator = radius2 - (fX2 + fY2)
23
+ return numerator / denominator
24
+ }
25
+
26
+ fun linearGradient (
27
+ point0 : Vec2 ,
28
+ point1 : Vec2 ,
29
+ position : Vec2
30
+ ): Float {
31
+ val distX = point1.x - point0.x
32
+ val distY = point1.y - point0.y
33
+ val dot = distX * distX + distY * distY
34
+ return (distX * (position.x - point0.x) + distY * (position.y - point0.y)) / dot
35
+ }
36
+ }
Original file line number Diff line number Diff line change
1
+ package glm_
2
+
3
+ interface optimumPow {
4
+
5
+ fun pow2 (x : Float ) = x * x
6
+
7
+ fun pow3 (x : Float ) = x * x * x
8
+
9
+ fun pow4 (x : Float ) = (x * x) * (x * x)
10
+ }
Original file line number Diff line number Diff line change @@ -8,6 +8,13 @@ import glm_.vec3.Vec3i
8
8
9
9
interface round {
10
10
11
+ fun floorMultiple (source : Int , multiple : Int ) = when {
12
+ source > 0 -> source - source % multiple
13
+ else -> {
14
+ val tmp = source + 1
15
+ tmp - tmp % multiple - multiple
16
+ }
17
+ }
11
18
12
19
fun ceilMultiple (source : Float , multiple : Float ) =
13
20
if (source > 0 ) source + (multiple - source % multiple)
You can’t perform that action at this time.
0 commit comments