
Offers customizable squircle shapes for UI components, integrating with themes for consistent styling. Features corner smoothing, multiplatform support, and canvas drawing capabilities for enhanced design flexibility.
A Compose Multiplatform library providing customizable Squircle shapes for UI components.
MaterialTheme: Use squircle shapes directly in Jetpack Compose themes.drawSquircle().Seamless MaterialTheme Integration:
SquircleBasedShape now extends CornerBasedShape, allowing you to use it directly in androidx.compose.material3.Shapes.
Corner Smoothing Support:
Added the cornerSmoothing parameter for effortless corner smoothing without extra overhead.
RTL Layout Support:
Fully compatible with both LayoutDirection.Ltr and LayoutDirection.Rtl, ensuring proper corner mapping.
Performance Enhancements:
Optimized corner clamping logic for improved rendering performance.
2.0.21
1.7.1
2.0.21
1.7.1
23
35
build.gradle.kts:sourceSets {
commonMain.dependencies{
implementation("com.composevisualeditor.apoloapps:squircle-shape:<version>")
}
}dependencies {
implementation("com.composevisualeditor.apoloapps:cve-squircle-shape-android:<version>")
}libs.versions.toml), declare it in the catalog instead.[versions]
squircle-shape = "<version>"
[libraries]
squircle-shape = { group = "com.composevisualeditor.apoloapps", name = "cve-squircle-shape-android", version.ref = "squircle-shape" }build.gradle.kts file.dependencies {
// ...
implementation(libs.squircle.shape)
}Define squircle shapes in your theme to use them consistently across your app:
val shapes = Shapes(
small = SquircleShape(radius = 16.dp, cornerSmoothing = CornerSmoothing.Medium),
medium = SquircleShape(radius = 32.dp, cornerSmoothing = CornerSmoothing.Medium),
large = SquircleShape(percent = 100, cornerSmoothing = CornerSmoothing.Medium)
)
MaterialTheme(
shapes = shapes
) {
// ...
Button(
onClick = { /* Action */ },
shape = MaterialTheme.shapes.large // Clipped to the provided `large` material theme shape.
) {
Text(text = "Full Squircle")
}
// ...
}Clip UI components separately by using a SquircleShape() function.
Image(
modifier = Modifier
.size(128.dp)
.clip(
shape = SquircleShape(
percent = 100,
cornerSmoothing = CornerSmoothing.Medium
)
), // Clipped to a fully rounded squircle shape.
painter = painterResource(R.drawable.mlbb_novaria),
contentDescription = "An image of Novaria.",
contentScale = ContentScale.Crop
)You can customize the radii for all corners, or for each corner independently. Supported corner values are:
Int for percent-based corner radius in range 0..100Float for pixel-based corner radius e.g. 50f
Dp for density pixel-based corner radius e.g. 16.dp
// Single-corner percent-based radius implementation.
SquircleShape(
percent = 100,
cornerSmoothing = .6f
)
// Single-corner pixel-based radius implementation.
SquircleShape(
radius = 32f,
cornerSmoothing = .6f
)
// Single-corner density pixel-based radius implementation.
SquircleShape(
radius = 32.dp,
cornerSmoothing = .6f
)
// Multi-corner percent-based radius implementation.
SquircleShape(
topStart = 25,
topEnd = 5,
bottomStart = 25,
bottomEnd = 5,
cornerSmoothing = .6f
)
// Multi-corner pixel-based radius implementation.
SquircleShape(
topStart = 32f,
topEnd = 8f,
bottomStart = 32f,
bottomEnd = 8f,
cornerSmoothing = .6f
)
// Multi-corner density pixel-based radius implementation.
SquircleShape(
topStart = 32.dp,
topEnd = 8.dp,
bottomStart = 32.dp,
bottomEnd = 8.dp,
cornerSmoothing = .6f
)You can draw squircle shapes on a canvas for custom graphics.
Note: currently drawSquircle only accepts pixel-based values for each corner:
Canvas(
modifier = Modifier.size(150.dp),
onDraw = {
drawSquircle(
color = Color.Blue,
topLeft = Offset.Zero,
size = this.size,
topLeftCorner = 32.dp.toPx(),
topRightCorner = 8.dp.toPx(),
bottomRightCorner = 32.dp.toPx(),
bottomLeftCorner = 8.dp.toPx(),
cornerSmoothing = .6f
)
}
)This project is open source and available under the MIT License.
MIT License
Copyright (c) 2023 Stoyan Vuchev / Copyright (c) 2024-2025 Apolo Apps
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Created by @stoyan-vuchev - feel free to contact me!
E-mail - contact@stoyanvuchev.com
Special thanks to @stoyan-vuchev
Forked by @ApoloApps
A Compose Multiplatform library providing customizable Squircle shapes for UI components.
MaterialTheme: Use squircle shapes directly in Jetpack Compose themes.drawSquircle().Seamless MaterialTheme Integration:
SquircleBasedShape now extends CornerBasedShape, allowing you to use it directly in androidx.compose.material3.Shapes.
Corner Smoothing Support:
Added the cornerSmoothing parameter for effortless corner smoothing without extra overhead.
RTL Layout Support:
Fully compatible with both LayoutDirection.Ltr and LayoutDirection.Rtl, ensuring proper corner mapping.
Performance Enhancements:
Optimized corner clamping logic for improved rendering performance.
2.0.21
1.7.1
2.0.21
1.7.1
23
35
build.gradle.kts:sourceSets {
commonMain.dependencies{
implementation("com.composevisualeditor.apoloapps:squircle-shape:<version>")
}
}dependencies {
implementation("com.composevisualeditor.apoloapps:cve-squircle-shape-android:<version>")
}libs.versions.toml), declare it in the catalog instead.[versions]
squircle-shape = "<version>"
[libraries]
squircle-shape = { group = "com.composevisualeditor.apoloapps", name = "cve-squircle-shape-android", version.ref = "squircle-shape" }build.gradle.kts file.dependencies {
// ...
implementation(libs.squircle.shape)
}Define squircle shapes in your theme to use them consistently across your app:
val shapes = Shapes(
small = SquircleShape(radius = 16.dp, cornerSmoothing = CornerSmoothing.Medium),
medium = SquircleShape(radius = 32.dp, cornerSmoothing = CornerSmoothing.Medium),
large = SquircleShape(percent = 100, cornerSmoothing = CornerSmoothing.Medium)
)
MaterialTheme(
shapes = shapes
) {
// ...
Button(
onClick = { /* Action */ },
shape = MaterialTheme.shapes.large // Clipped to the provided `large` material theme shape.
) {
Text(text = "Full Squircle")
}
// ...
}Clip UI components separately by using a SquircleShape() function.
Image(
modifier = Modifier
.size(128.dp)
.clip(
shape = SquircleShape(
percent = 100,
cornerSmoothing = CornerSmoothing.Medium
)
), // Clipped to a fully rounded squircle shape.
painter = painterResource(R.drawable.mlbb_novaria),
contentDescription = "An image of Novaria.",
contentScale = ContentScale.Crop
)You can customize the radii for all corners, or for each corner independently. Supported corner values are:
Int for percent-based corner radius in range 0..100Float for pixel-based corner radius e.g. 50f
Dp for density pixel-based corner radius e.g. 16.dp
// Single-corner percent-based radius implementation.
SquircleShape(
percent = 100,
cornerSmoothing = .6f
)
// Single-corner pixel-based radius implementation.
SquircleShape(
radius = 32f,
cornerSmoothing = .6f
)
// Single-corner density pixel-based radius implementation.
SquircleShape(
radius = 32.dp,
cornerSmoothing = .6f
)
// Multi-corner percent-based radius implementation.
SquircleShape(
topStart = 25,
topEnd = 5,
bottomStart = 25,
bottomEnd = 5,
cornerSmoothing = .6f
)
// Multi-corner pixel-based radius implementation.
SquircleShape(
topStart = 32f,
topEnd = 8f,
bottomStart = 32f,
bottomEnd = 8f,
cornerSmoothing = .6f
)
// Multi-corner density pixel-based radius implementation.
SquircleShape(
topStart = 32.dp,
topEnd = 8.dp,
bottomStart = 32.dp,
bottomEnd = 8.dp,
cornerSmoothing = .6f
)You can draw squircle shapes on a canvas for custom graphics.
Note: currently drawSquircle only accepts pixel-based values for each corner:
Canvas(
modifier = Modifier.size(150.dp),
onDraw = {
drawSquircle(
color = Color.Blue,
topLeft = Offset.Zero,
size = this.size,
topLeftCorner = 32.dp.toPx(),
topRightCorner = 8.dp.toPx(),
bottomRightCorner = 32.dp.toPx(),
bottomLeftCorner = 8.dp.toPx(),
cornerSmoothing = .6f
)
}
)This project is open source and available under the MIT License.
MIT License
Copyright (c) 2023 Stoyan Vuchev / Copyright (c) 2024-2025 Apolo Apps
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Created by @stoyan-vuchev - feel free to contact me!
E-mail - contact@stoyanvuchev.com
Special thanks to @stoyan-vuchev
Forked by @ApoloApps