This repository has been archived by the owner on Jun 27, 2023. It is now read-only.
forked from iTaysonLab/jetispot
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Custom shapes: added blob shape
- Loading branch information
DotsTeaLab
committed
Dec 5, 2022
1 parent
2070786
commit 5f26065
Showing
1 changed file
with
59 additions
and
0 deletions.
There are no files selected for viewing
59 changes: 59 additions & 0 deletions
59
app/src/main/java/bruhcollective/itaysonlab/jetispot/ui/theme/CustomShapes.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,59 @@ | ||
package bruhcollective.itaysonlab.jetispot.ui.theme | ||
|
||
import android.graphics.Matrix | ||
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.graphics.asAndroidPath | ||
import androidx.compose.ui.graphics.asComposePath | ||
import androidx.compose.ui.unit.Density | ||
import androidx.compose.ui.unit.LayoutDirection | ||
|
||
class CustomShapes { | ||
val BlobShape: Shape = object: Shape { | ||
override fun createOutline( | ||
size: Size, | ||
layoutDirection: LayoutDirection, | ||
density: Density | ||
): Outline { | ||
val baseWidth = 184f | ||
val baseHeight = 184f | ||
|
||
val path = Path().apply { | ||
moveTo(92f, 12f) | ||
cubicTo(80.568f, 12f, 69.9033f, 6.6281f, 59.1725f, 2.686f) | ||
cubicTo(54.4428f, 0.9485f, 49.3322f, 0f, 44f, 0f) | ||
cubicTo(19.6995f, 0f, 0f, 19.6995f, 0f, 44f) | ||
cubicTo(0f, 49.3322f, 0.9485f, 54.4428f, 2.686f, 59.1725f) | ||
cubicTo(6.6281f, 69.9033f, 12f, 80.568f, 12f, 92f) | ||
cubicTo(12f, 103.432f, 6.6281f, 114.0967f, 2.686f, 124.8275f) | ||
cubicTo(0.9485f, 129.5572f, 0f, 134.6678f, 0f, 140f) | ||
cubicTo(0f, 164.3005f, 19.6995f, 184f, 44f, 184f) | ||
cubicTo(49.3322f, 184f, 54.4428f, 183.0515f, 59.1724f, 181.314f) | ||
cubicTo(69.9033f, 177.372f, 80.568f, 172f, 92f, 172f) | ||
cubicTo(103.432f, 172f, 114.0967f, 177.372f, 124.8276f, 181.314f) | ||
cubicTo(129.5572f, 183.0515f, 134.6678f, 184f, 140f, 184f) | ||
cubicTo(164.3005f, 184f, 184f, 164.3005f, 184f, 140f) | ||
cubicTo(184f, 134.6678f, 183.0515f, 129.5572f, 181.314f, 124.8276f) | ||
cubicTo(177.372f, 114.0967f, 172f, 103.432f, 172f, 92f) | ||
cubicTo(172f, 80.568f, 177.372f, 69.9033f, 181.314f, 59.1724f) | ||
cubicTo(183.0515f, 54.4428f, 184f, 49.3322f, 184f, 44f) | ||
cubicTo(184f, 19.6995f, 164.3005f, 0f, 140f, 0f) | ||
cubicTo(134.6678f, 0f, 129.5572f, 0.9485f, 124.8275f, 2.686f) | ||
cubicTo(114.0967f, 6.6281f, 103.432f, 12f, 92f, 12f) | ||
close() | ||
} | ||
return Outline.Generic( | ||
path | ||
.asAndroidPath() | ||
.apply { | ||
transform(Matrix().apply { | ||
setScale(size.width / baseWidth, size.height / baseHeight) | ||
}) | ||
} | ||
.asComposePath() | ||
) | ||
} | ||
} | ||
} |