forked from Traewelldroid/traewelldroid
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- adds shared HexagonShape - adds shared TrapezoidShape - adds custom shapes to LineIcon Related: Traewelling/line-colors#27 Signed-off-by: The one with the braid <[email protected]>
- Loading branch information
1 parent
52b7337
commit ee46fb7
Showing
3 changed files
with
43 additions
and
0 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
app/src/main/kotlin/de/hbch/traewelling/shared/HexagonShape.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package de.hbch.traewelling.shared | ||
|
||
import androidx.compose.ui.geometry.Size | ||
import androidx.compose.ui.graphics.Outline | ||
import androidx.compose.ui.graphics.Path | ||
import androidx.compose.ui.graphics.Shape | ||
import androidx.compose.ui.unit.Density | ||
|
||
/** | ||
* Forms a hexagon shape with symmetric sides | ||
*/ | ||
open class HexagonShape(val intent: Float = 0.2f, val peek: Float = 0.5f) : Shape { | ||
|
||
|
||
override fun createOutline( | ||
size: Size, | ||
layoutDirection: androidx.compose.ui.unit.LayoutDirection, | ||
density: Density | ||
): Outline { | ||
val path = Path().apply { | ||
moveTo(size.width * intent, 0f) | ||
lineTo(size.width * (1 - intent), 0f) | ||
lineTo(size.width, size.height * peek) | ||
lineTo(size.width * (1 - intent), size.height) | ||
lineTo(size.width * intent, size.height) | ||
lineTo(0f, size.height * peek) | ||
close() | ||
} | ||
return Outline.Generic(path) | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
app/src/main/kotlin/de/hbch/traewelling/shared/TrapezoidShape.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package de.hbch.traewelling.shared | ||
|
||
/** | ||
* Forms a trapezoid shape with a broad top and a narrow bottom side | ||
*/ | ||
open class TrapezoidShape() : HexagonShape(peek = 0f) { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters