File tree Expand file tree Collapse file tree 3 files changed +51
-1
lines changed Expand file tree Collapse file tree 3 files changed +51
-1
lines changed 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
+ }
You can’t perform that action at this time.
0 commit comments