Various shapes drawn with Jetpack Compose
![compose shapes thumbnail](https://private-user-images.githubusercontent.com/72340294/346328643-56357d3c-ad0a-4f15-94b0-f6ca07cc0082.gif?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQ1NzIwNzAsIm5iZiI6MTcyNDU3MTc3MCwicGF0aCI6Ii83MjM0MDI5NC8zNDYzMjg2NDMtNTYzNTdkM2MtYWQwYS00ZjE1LTk0YjAtZjZjYTA3Y2MwMDgyLmdpZj9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MjUlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODI1VDA3NDI1MFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWQ4YzZmODZmODM5YTZmODQzZDQ0OGE1NTUxNmVkM2Q1NmZmYzYwZTIzYzAwYWU0MTg4OGQ3ZDA4NjI5ZWJkZDgmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.8MbPetWYkCXGAHW720JrM9A3RpXiG0bq57U2cuRfQGk)
Name |
Screenshot |
Code |
---|
Rectangle |
![](https://github.com/user-attachments/assets/15a432e6-47a6-4c78-8cad-4e542e91c945) |
Box(
modifier = Modifier
.fillMaxSize()
.weight(0.3f)
.background(
color = Color.Gray,
shape = RectangleShape(
topStart = 12.dp,
topEnd = 12.dp,
bottomStart = 12.dp,
bottomEnd = 12.dp
)
)
) {
// Content goes here
}
|
Parallelogram |
![](https://github.com/user-attachments/assets/5c445573-09b1-4050-bfdf-15917061944c) |
Box(
modifier = Modifier
.fillMaxWidth()
.background(
Color.Gray,
shape = ParallelogramShape(
skewed = 0.3f,
topStart = 24.dp,
bottomEnd = 24.dp,
topEnd = 12.dp,
bottomStart = 12.dp
)
)
) {
// Content goes here
}
|
Rhombus |
![](https://github.com/user-attachments/assets/23fe6611-de19-4318-9030-fb1ced2abc0f) |
Box(
modifier = Modifier
.fillMaxSize()
.weight(0.5f)
.background(
Color.Gray,
shape = RhombusShape(
top = 24.dp,
start = 12.dp,
end = 12.dp,
bottom = 24.dp
)
)
) {
}
|
Trapezoid |
![](https://github.com/user-attachments/assets/9f7b62ef-fe0c-4cae-a715-53417e1bf697) |
Box(
modifier = Modifier
.fillMaxSize()
.weight(0.5f)
.background(
Color.Gray,
shape = TrapezoidShape(
startSkewed = 0.2f,
endSkewed = 0.4f,
topStart = 12.dp,
topEnd = 12.dp,
bottomStart = 12.dp,
bottomEnd = 12.dp
)
)
) {
}
|
Name |
Screenshot |
Code |
---|
Regular Polygons |
![](https://github.com/uuranus/compose-shapes/assets/72340294/99d054ab-d0f9-4040-8847-0e2fbf0b06ae) |
Box(
modifier = Modifier
.fillMaxWidth()
.background(
color = Color.Gray,
shape = PolygonShape(
numOfPoints = 5
)
)
) {
// Content goes here
}
|
Star Polygon |
![](https://github.com/user-attachments/assets/edc18908-705b-4334-b252-ad0dd6252f1a) |
Box(
modifier = Modifier
.fillMaxSize()
.weight(0.5f)
.background(
Color.Gray,
shape = StarPolygonShape(
numOfPoints = 5,
innerRadiusRatio = 0.5f, //0f .. 1f
outerCornerSize = 24.dp,
innerCornerSize = 12.dp
)
)
) {
}
|
You can customize corners using the CornerStyle enum class.
Rounded |
Inner Rounded |
Cut |
---|
![](https://github.com/user-attachments/assets/aec6cb51-2bce-4d26-8a4f-c4f522891475) |
![](https://github.com/user-attachments/assets/03ff4b40-ee07-4ea6-ba55-e0fa968ceb30) |
![](https://github.com/user-attachments/assets/377b0578-bb4d-4e73-8a1c-111a80e92232) |
Cloud |
Ring |
---|
![](https://github.com/user-attachments/assets/10875742-2277-45e5-b2a8-2dc3787a10c2) |
![](https://github.com/user-attachments/assets/dc5aea6f-69e2-4de8-8f73-16d0a6ebf227) |
Step 1. Add it in your root build.gradle at the end of repositories
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
maven(url = "https://jitpack.io")
}
}
Step 2. Add the dependency
dependencies {
implementation("com.github.uuranus:compose-shapes:latest-version")
}
Copyright 2024 uuranus All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.