diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index c05910d..e5a7b0d 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -9,140 +9,10 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
@@ -151,44 +21,12 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
-
+
+
+
@@ -255,6 +93,13 @@
"state": "OPEN"
}
}
+
+
+
{
"selectedUrlAndAccountId": {
"url": "https://github.com/stoyan-vuchev/squircle-shape.git",
@@ -262,8 +107,8 @@
}
}
-
-
+
+
@@ -272,23 +117,23 @@
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
@@ -335,13 +180,13 @@
"cf.first.check.clang-format": "false",
"cidr.known.project.marker": "true",
"dart.analysis.tool.window.visible": "false",
- "git-widget-placeholder": "2.1.0",
+ "git-widget-placeholder": "3.0.0/corner-based-shape",
"iOS Application.iosApp.executor": "Run",
"ignore.virus.scanning.warn.message": "true",
"kotlin-language-version-configured": "true",
"last_opened_file_path": "D:/AndroidStudioProjects/squircle-shape/application/src/wasmJsMain/kotlin/com/stoyanvuchev/squircleshape/app",
"recommended.upgrade.do.not.ask.for.project": "true",
- "settings.editor.selected.configurable": "reference.settingsdialog.project.gradle",
+ "settings.editor.selected.configurable": "editor.preferences.fonts.default",
"show.migrate.to.gradle.popup": "false"
},
"keyToStringList": {
@@ -588,7 +433,15 @@
1714166522696
-
+
+
+ 1732411828636
+
+
+
+ 1732411828636
+
+
@@ -605,6 +458,7 @@
-
+
+
\ No newline at end of file
diff --git a/README.md b/README.md
index 583f6d7..f5e852b 100644
--- a/README.md
+++ b/README.md
@@ -14,6 +14,7 @@
* [Why Squircle?](#why-squircle)
* [Requirements](#requirements)
+* [Supported Platforms](#supported-platforms)
* [Gradle Kotlin DSL Setup (For Multiplatform projects).](#gradle-kotlin-dsl-setup-for-multiplatform-projects)
* [Gradle Kotlin DSL Setup (For Android-only projects).](#gradle-kotlin-dsl-setup-for-android-only-projects)
* [Gradle Groovy Setup (For Android-only projects).](#gradle-groovy-setup-for-android-only-projects)
@@ -34,7 +35,6 @@
---
## Requirements
-
##### Base requirements (For Multiplatform projects):
@@ -43,8 +43,6 @@
----
-
##### Base requirements (For Android-only projects):
- Kotlin version - `2.0.21`
@@ -56,6 +54,19 @@
---
+## Supported Platforms
+
+##### List of currently supported platforms:
+
+- Android
+- iOS
+- Desktop (JVM)
+- Web (WasmJS)
+
+
+
+---
+
## Gradle Kotlin DSL Setup (For Multiplatform projects).
##### Step 1
diff --git a/composeApp/src/commonMain/kotlin/App.kt b/composeApp/src/commonMain/kotlin/App.kt
index 6df34b5..648b32b 100644
--- a/composeApp/src/commonMain/kotlin/App.kt
+++ b/composeApp/src/commonMain/kotlin/App.kt
@@ -1,5 +1,6 @@
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.material3.MaterialTheme
+import androidx.compose.material3.Shapes
import androidx.compose.material3.darkColorScheme
import androidx.compose.material3.lightColorScheme
import androidx.compose.runtime.Composable
@@ -14,27 +15,38 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import sv.lib.squircleshape.CornerSmoothing
+import sv.lib.squircleshape.SquircleShape
import kotlin.math.roundToInt
import kotlin.random.Random
@Composable
fun App() {
+ var aspectRatio by remember { mutableFloatStateOf(1f) }
+ var cornerRadius by remember { mutableIntStateOf(100) }
+ var cornerSmoothing by remember { mutableFloatStateOf(CornerSmoothing.Medium) }
+ val state by rememberUpdatedState(
+ PreviewScreenState(
+ aspectRatio = aspectRatio,
+ cornerRadius = cornerRadius,
+ cornerSmoothing = cornerSmoothing
+ )
+ )
+
+ val shapes by rememberUpdatedState(
+ Shapes(
+ large = SquircleShape(
+ percent = state.cornerRadius,
+ cornerSmoothing = state.cornerSmoothing
+ )
+ )
+ )
+
MaterialTheme(
+ shapes = shapes,
colorScheme = if (isSystemInDarkTheme()) darkColorScheme() else lightColorScheme(),
content = {
- var aspectRatio by remember { mutableFloatStateOf(1f) }
- var cornerRadius by remember { mutableIntStateOf(100) }
- var cornerSmoothing by remember { mutableFloatStateOf(CornerSmoothing.Medium) }
- val state by rememberUpdatedState(
- PreviewScreenState(
- aspectRatio = aspectRatio,
- cornerRadius = cornerRadius,
- cornerSmoothing = cornerSmoothing
- )
- )
-
val scope = rememberCoroutineScope()
val onUiAction = remember<(PreviewScreenUiAction) -> Unit> {
{ uiAction ->
diff --git a/composeApp/src/commonMain/kotlin/PreviewScreen.kt b/composeApp/src/commonMain/kotlin/PreviewScreen.kt
index e58c0bd..5faee4c 100644
--- a/composeApp/src/commonMain/kotlin/PreviewScreen.kt
+++ b/composeApp/src/commonMain/kotlin/PreviewScreen.kt
@@ -19,12 +19,12 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.derivedStateOf
import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
-import androidx.compose.runtime.rememberUpdatedState
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.geometry.Offset
+import androidx.compose.ui.geometry.Size
+import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.unit.dp
-import sv.lib.squircleshape.SquircleShape
import sv.lib.squircleshape.drawSquircle
@Composable
@@ -54,6 +54,8 @@ fun PreviewScreen(
) {
val color = MaterialTheme.colorScheme.primary
+ val shape = MaterialTheme.shapes.large
+ val density = LocalDensity.current
Canvas(
modifier = Modifier
@@ -63,18 +65,19 @@ fun PreviewScreen(
val landscapeSquircleSize = this.size
val landscapeSquircleOffset = Offset.Zero
- val landscapeSquircleCorner = (
- landscapeSquircleSize.minDimension / 2f
- ) * (state.cornerRadius.toFloat() / 100f)
+ val shapeSize = Size(
+ width = landscapeSquircleSize.width / 2,
+ height = landscapeSquircleSize.height / 2
+ )
drawSquircle(
color = color,
topLeft = landscapeSquircleOffset,
size = landscapeSquircleSize,
- topLeftCorner = landscapeSquircleCorner,
- topRightCorner = landscapeSquircleCorner,
- bottomLeftCorner = landscapeSquircleCorner,
- bottomRightCorner = landscapeSquircleCorner,
+ topLeftCorner = shape.topStart.toPx(shapeSize, density),
+ topRightCorner = shape.topEnd.toPx(shapeSize, density),
+ bottomLeftCorner = shape.bottomStart.toPx(shapeSize, density),
+ bottomRightCorner = shape.bottomEnd.toPx(shapeSize, density),
cornerSmoothing = state.cornerSmoothing
)
@@ -119,6 +122,7 @@ fun PreviewScreen(
.padding(horizontal = 24.dp),
title = cornerRadiusSliderTitle,
value = cornerRadiusSliderValue,
+ valueRange = 0f..1f,
onValueChange = remember {
{ onUiAction(PreviewScreenUiAction.SetCornerRadius(it)) }
}
@@ -154,24 +158,17 @@ fun PreviewScreen(
horizontalArrangement = Arrangement.spacedBy(8.dp)
) {
- val buttonShape by rememberUpdatedState(
- SquircleShape(
- percent = state.cornerRadius,
- cornerSmoothing = state.cornerSmoothing
- )
- )
-
TextButton(
onClick = remember { { onUiAction(PreviewScreenUiAction.Reset) } },
modifier = Modifier.weight(1f),
- shape = buttonShape,
+ shape = MaterialTheme.shapes.large,
content = { Text(text = "Reset") }
)
TextButton(
onClick = remember { { onUiAction(PreviewScreenUiAction.Random) } },
modifier = Modifier.weight(1f),
- shape = buttonShape,
+ shape = MaterialTheme.shapes.large,
content = { Text(text = "Random") }
)
diff --git a/library/build.gradle.kts b/library/build.gradle.kts
index 4e133f0..1c3fb46 100644
--- a/library/build.gradle.kts
+++ b/library/build.gradle.kts
@@ -93,7 +93,7 @@ mavenPublishing {
coordinates(
groupId = "io.github.stoyan-vuchev",
artifactId = "squircle-shape",
- version = "2.1.0"
+ version = "3.0.0"
)
pom {
diff --git a/library/src/commonMain/kotlin/sv/lib/squircleshape/SquircleBasedShape.kt b/library/src/commonMain/kotlin/sv/lib/squircleshape/SquircleBasedShape.kt
index 6ee0bb3..774b0a6 100644
--- a/library/src/commonMain/kotlin/sv/lib/squircleshape/SquircleBasedShape.kt
+++ b/library/src/commonMain/kotlin/sv/lib/squircleshape/SquircleBasedShape.kt
@@ -21,16 +21,13 @@
package sv.lib.squircleshape
+import androidx.compose.foundation.shape.CornerBasedShape
import androidx.compose.foundation.shape.CornerSize
-import androidx.compose.ui.geometry.Size
-import androidx.compose.ui.graphics.Outline
-import androidx.compose.ui.graphics.Shape
-import androidx.compose.ui.unit.Density
-import androidx.compose.ui.unit.LayoutDirection
/**
*
- * Base class for creating a Squircle based [Shape] defined by four corners and smoothing factor.
+ * Base class for creating a Squircle shape derived from a [CornerBasedShape]
+ * defined by four corners and a corner smoothing.
*
* @param topStart The top start corner radius defined as [CornerSize].
* @param topEnd The top end corner radius defined as [CornerSize].
@@ -40,107 +37,14 @@ import androidx.compose.ui.unit.LayoutDirection
*
**/
abstract class SquircleBasedShape(
- val topStart: CornerSize,
- val topEnd: CornerSize,
- val bottomStart: CornerSize,
- val bottomEnd: CornerSize,
+ topStart: CornerSize,
+ topEnd: CornerSize,
+ bottomStart: CornerSize,
+ bottomEnd: CornerSize,
val cornerSmoothing: Float
-) : Shape {
-
- final override fun createOutline(
- size: Size,
- layoutDirection: LayoutDirection,
- density: Density
- ): Outline {
-
- var topStart = topStart.toPx(size, density)
- var topEnd = topEnd.toPx(size, density)
- var bottomEnd = bottomEnd.toPx(size, density)
- var bottomStart = bottomStart.toPx(size, density)
- val minDimension = size.minDimension
-
- if (topStart + bottomStart > minDimension) {
- val scale = minDimension / (topStart + bottomStart)
- topStart *= scale
- bottomStart *= scale
- }
-
- if (topEnd + bottomEnd > minDimension) {
- val scale = minDimension / (topEnd + bottomEnd)
- topEnd *= scale
- bottomEnd *= scale
- }
-
- require(topStart >= 0.0f && topEnd >= 0.0f && bottomEnd >= 0.0f && bottomStart >= 0.0f) {
- "Corner size in Px can't be negative(topStart = $topStart, topEnd = $topEnd, " +
- "bottomEnd = $bottomEnd, bottomStart = $bottomStart)!"
- }
-
- return createOutline(
- size = size,
- topStart = topStart,
- topEnd = topEnd,
- bottomEnd = bottomEnd,
- bottomStart = bottomStart,
- cornerSmoothing = cornerSmoothing,
- layoutDirection = layoutDirection
- )
-
- }
-
- /**
- *
- * Creates [Outline] of this shape for the given [size].
- *
- * @param size the size of the shape boundary.
- * @param topStart the resolved size of the top start corner
- * @param topEnd the resolved size for the top end corner
- * @param bottomEnd the resolved size for the bottom end corner
- * @param bottomStart the resolved size for the bottom start corner
- * @param cornerSmoothing the resolved smoothing factor for all corners
- * @param layoutDirection the current layout direction.
- *
- */
- abstract fun createOutline(
- size: Size,
- topStart: Float,
- topEnd: Float,
- bottomEnd: Float,
- bottomStart: Float,
- cornerSmoothing: Float,
- layoutDirection: LayoutDirection
- ): Outline
-
- /**
- *
- * Creates a copy of this Shape with a new corner sizes.
- *
- * @param topStart a size of the top start corner
- * @param topEnd a size of the top end corner
- * @param bottomEnd a size of the bottom end corner
- * @param bottomStart a size of the bottom start corner
- * @param cornerSmoothing a factor for smoothing all corners
- *
- */
- abstract fun copy(
- topStart: CornerSize = this.topStart,
- topEnd: CornerSize = this.topEnd,
- bottomEnd: CornerSize = this.bottomEnd,
- bottomStart: CornerSize = this.bottomStart,
- cornerSmoothing: Float = this.cornerSmoothing
- ): SquircleBasedShape
-
- /**
- *
- * Creates a copy of this Shape with a new corner size.
- *
- * @param all a size to apply for all four corners
- * @param cornerSmoothing a factor for smoothing all corners
- *
- */
- fun copy(
- all: CornerSize,
- cornerSmoothing: Float = this.cornerSmoothing
- ): SquircleBasedShape = copy(all, all, all, all, cornerSmoothing)
-
-}
\ No newline at end of file
+) : CornerBasedShape(
+ topStart = topStart,
+ topEnd = topEnd,
+ bottomStart = bottomStart,
+ bottomEnd = bottomEnd
+)
\ No newline at end of file
diff --git a/library/src/commonMain/kotlin/sv/lib/squircleshape/SquircleShape.kt b/library/src/commonMain/kotlin/sv/lib/squircleshape/SquircleShape.kt
index b23542e..c4eeaeb 100644
--- a/library/src/commonMain/kotlin/sv/lib/squircleshape/SquircleShape.kt
+++ b/library/src/commonMain/kotlin/sv/lib/squircleshape/SquircleShape.kt
@@ -23,105 +23,10 @@ package sv.lib.squircleshape
import androidx.compose.foundation.shape.CornerSize
import androidx.compose.ui.geometry.Size
-import androidx.compose.ui.geometry.toRect
-import androidx.compose.ui.graphics.Outline
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.LayoutDirection
import androidx.compose.ui.unit.dp
-/**
- *
- * Creates a [SquircleBasedShape].
- *
- * @param topStartCorner The top start corner radius defined as [CornerSize].
- * @param topEndCorner The top end corner radius defined as [CornerSize].
- * @param bottomStartCorner The bottom start corner radius defined as [CornerSize].
- * @param bottomEndCorner The bottom end corner radius defined as [CornerSize].
- * @param cornerSmoothing (0.55f - rounded corner shape, 1f - fully pronounced squircle).
- *
- **/
-class SquircleShape(
- topStartCorner: CornerSize,
- topEndCorner: CornerSize,
- bottomStartCorner: CornerSize,
- bottomEndCorner: CornerSize,
- cornerSmoothing: Float
-) : SquircleBasedShape(
- topStartCorner,
- topEndCorner,
- bottomStartCorner,
- bottomEndCorner,
- cornerSmoothing
-) {
-
- override fun createOutline(
- size: Size,
- topStart: Float,
- topEnd: Float,
- bottomEnd: Float,
- bottomStart: Float,
- cornerSmoothing: Float,
- layoutDirection: LayoutDirection
- ): Outline = if (topStart + topEnd + bottomEnd + bottomStart == 0.0f) {
- Outline.Rectangle(size.toRect())
- } else {
- val isLtr = layoutDirection == LayoutDirection.Ltr
- Outline.Generic(
- path = squircleShapePath(
- size = size,
- topLeftCorner = clampedCornerRadius(if (isLtr) topStart else topEnd, size),
- topRightCorner = clampedCornerRadius(if (isLtr) topEnd else topStart, size),
- bottomLeftCorner = clampedCornerRadius(if (isLtr) bottomStart else bottomEnd, size),
- bottomRightCorner = clampedCornerRadius(
- if (isLtr) bottomEnd else bottomStart,
- size
- ),
- cornerSmoothing = clampedCornerSmoothing(cornerSmoothing)
- )
- )
- }
-
- override fun copy(
- topStart: CornerSize,
- topEnd: CornerSize,
- bottomEnd: CornerSize,
- bottomStart: CornerSize,
- cornerSmoothing: Float
- ) = SquircleShape(
- topStartCorner = topStart,
- topEndCorner = topEnd,
- bottomStartCorner = bottomStart,
- bottomEndCorner = bottomEnd,
- cornerSmoothing = cornerSmoothing
- )
-
- override fun toString(): String {
- return "RoundedCornerShape(topStart = $topStart, topEnd = $topEnd, bottomStart = " +
- "$bottomStart, bottomEnd = $bottomEnd, cornerSmoothing = $cornerSmoothing)"
- }
-
- override fun equals(other: Any?): Boolean {
- if (this === other) return true
- if (other !is SquircleShape) return false
- if (topStart != other.topStart) return false
- if (topEnd != other.topEnd) return false
- if (bottomStart != other.bottomStart) return false
- if (bottomEnd != other.bottomEnd) return false
- if (cornerSmoothing != other.cornerSmoothing) return false
- return true
- }
-
- override fun hashCode(): Int {
- var result = topStart.hashCode()
- result = 31 * result + topEnd.hashCode()
- result = 31 * result + bottomStart.hashCode()
- result = 31 * result + bottomEnd.hashCode()
- result = 31 * result + cornerSmoothing.hashCode()
- return result
- }
-
-}
-
/**
*
* Creates a [SquircleShape] with corner radius percent defined as [Int] value.
@@ -252,4 +157,91 @@ fun SquircleShape(
bottomStartCorner = CornerSize(bottomStart),
bottomEndCorner = CornerSize(bottomEnd),
cornerSmoothing = cornerSmoothing
-)
\ No newline at end of file
+)
+
+/**
+ *
+ * Creates a [SquircleBasedShape].
+ *
+ * @param topStartCorner The top start corner radius defined as [CornerSize].
+ * @param topEndCorner The top end corner radius defined as [CornerSize].
+ * @param bottomStartCorner The bottom start corner radius defined as [CornerSize].
+ * @param bottomEndCorner The bottom end corner radius defined as [CornerSize].
+ * @param cornerSmoothing (0.55f - rounded corner shape, 1f - fully pronounced squircle).
+ *
+ **/
+class SquircleShape(
+ topStartCorner: CornerSize,
+ topEndCorner: CornerSize,
+ bottomStartCorner: CornerSize,
+ bottomEndCorner: CornerSize,
+ cornerSmoothing: Float
+) : SquircleBasedShape(
+ topStartCorner,
+ topEndCorner,
+ bottomStartCorner,
+ bottomEndCorner,
+ cornerSmoothing
+) {
+
+ override fun copy(
+ topStart: CornerSize,
+ topEnd: CornerSize,
+ bottomEnd: CornerSize,
+ bottomStart: CornerSize
+ ) = SquircleShape(
+ topStartCorner = topStart,
+ topEndCorner = topEnd,
+ bottomStartCorner = bottomStart,
+ bottomEndCorner = bottomEnd,
+ cornerSmoothing = cornerSmoothing
+ )
+
+ override fun createOutline(
+ size: Size,
+ topStart: Float,
+ topEnd: Float,
+ bottomEnd: Float,
+ bottomStart: Float,
+ layoutDirection: LayoutDirection
+ ) = createSquircleShapeOutline(
+ size = size,
+ topStart = topStart,
+ topEnd = topEnd,
+ bottomEnd = bottomEnd,
+ bottomStart = bottomStart,
+ cornerSmoothing = cornerSmoothing,
+ layoutDirection = layoutDirection
+ )
+
+ override fun toString(): String {
+ return "SquircleShape(" +
+ "topStart = $topStart, " +
+ "topEnd = $topEnd, " +
+ "bottomStart = $bottomStart, " +
+ "bottomEnd = $bottomEnd, " +
+ "cornerSmoothing = $cornerSmoothing" +
+ ")"
+ }
+
+ override fun equals(other: Any?): Boolean {
+ if (this === other) return true
+ if (other !is SquircleShape) return false
+ if (topStart != other.topStart) return false
+ if (topEnd != other.topEnd) return false
+ if (bottomStart != other.bottomStart) return false
+ if (bottomEnd != other.bottomEnd) return false
+ if (cornerSmoothing != other.cornerSmoothing) return false
+ return true
+ }
+
+ override fun hashCode(): Int {
+ var result = topStart.hashCode()
+ result = 31 * result + topEnd.hashCode()
+ result = 31 * result + bottomStart.hashCode()
+ result = 31 * result + bottomEnd.hashCode()
+ result = 31 * result + cornerSmoothing.hashCode()
+ return result
+ }
+
+}
\ No newline at end of file
diff --git a/library/src/commonMain/kotlin/sv/lib/squircleshape/SquircleShapeHelperFunctions.kt b/library/src/commonMain/kotlin/sv/lib/squircleshape/SquircleShapeHelperFunctions.kt
index 4339904..2f0314f 100644
--- a/library/src/commonMain/kotlin/sv/lib/squircleshape/SquircleShapeHelperFunctions.kt
+++ b/library/src/commonMain/kotlin/sv/lib/squircleshape/SquircleShapeHelperFunctions.kt
@@ -23,6 +23,62 @@ package sv.lib.squircleshape
import androidx.compose.runtime.Stable
import androidx.compose.ui.geometry.Size
+import androidx.compose.ui.geometry.toRect
+import androidx.compose.ui.graphics.Outline
+import androidx.compose.ui.unit.LayoutDirection
+
+/**
+ * Creates an outline for a [SquircleShape], considering corner radii, smoothing, and layout direction.
+ *
+ * @param size The overall size of the shape as a [Size] object.
+ * @param topStart The radius of the top-start corner in pixels. In left-to-right layouts, this corresponds to the top-left corner.
+ * @param topEnd The radius of the top-end corner in pixels. In left-to-right layouts, this corresponds to the top-right corner.
+ * @param bottomEnd The radius of the bottom-end corner in pixels. In left-to-right layouts, this corresponds to the bottom-right corner.
+ * @param bottomStart The radius of the bottom-start corner in pixels. In left-to-right layouts, this corresponds to the bottom-left corner.
+ * @param cornerSmoothing A float value between 0 and 1 that determines the smoothing of the corners.
+ * A value of 0 represents sharp corners, while 1 represents fully rounded transitions.
+ * @param layoutDirection The layout direction of the shape, specified as [LayoutDirection.Ltr] or [LayoutDirection.Rtl].
+ * This affects how the corner radii are applied.
+ * @return An [Outline] object representing the shape's boundary:
+ * - Returns a rectangle if all corner radii are zero.
+ * - Returns a generic path representing the squircle shape if any corner radius is non-zero.
+ *
+ * ##### Behavior:
+ * - Clamps the corner radii to ensure they fit within the size of the shape.
+ * - Adjusts corner radii based on the layout direction, swapping left and right corners in RTL layouts.
+ * - Applies corner smoothing using the provided `cornerSmoothing` parameter to create a squircle-like effect.
+ */
+@Stable
+internal fun createSquircleShapeOutline(
+ size: Size,
+ topStart: Float,
+ topEnd: Float,
+ bottomEnd: Float,
+ bottomStart: Float,
+ cornerSmoothing: Float,
+ layoutDirection: LayoutDirection
+): Outline = if (topStart + topEnd + bottomEnd + bottomStart == 0.0f) {
+ Outline.Rectangle(size.toRect())
+} else {
+
+ val isLtr = layoutDirection == LayoutDirection.Ltr
+ val topLeftCorner = clampedCornerRadius(if (isLtr) topStart else topEnd, size)
+ val topRightCorner = clampedCornerRadius(if (isLtr) topEnd else topStart, size)
+ val bottomLeftCorner = clampedCornerRadius(if (isLtr) bottomStart else bottomEnd, size)
+ val bottomRightCorner = clampedCornerRadius(if (isLtr) bottomEnd else bottomStart, size)
+
+ Outline.Generic(
+ path = squircleShapePath(
+ size = size,
+ topLeftCorner = topLeftCorner,
+ topRightCorner = topRightCorner,
+ bottomLeftCorner = bottomLeftCorner,
+ bottomRightCorner = bottomRightCorner,
+ cornerSmoothing = clampedCornerSmoothing(cornerSmoothing)
+ )
+ )
+
+}
/**
*