
2D physics layout container turning UI elements into simulated rigid bodies with fixed-timestep JBox2D simulation, shapes, boundaries, pointer dragging modes, collision/drag/step events.
PhysicsBox is a Compose Multiplatform physics layout container for Android and Desktop (JVM). It turns composables into 2D physics bodies and renders their motion by applying translation and rotation during layout.
The runtime uses JBox2D on JVM platforms, giving you stable rigid-body simulation with fixed-timestep stepping, boundaries, dragging, and collision callbacks.
Inspired by PhysicsLayout.
kotlin {
sourceSets {
val commonMain by getting {
dependencies {
implementation("io.github.zinchenko-dev:physicsbox:<latest_release>")
}
}
}
}@Composable
fun PhysicsDemo() {
PhysicsBox(modifier = Modifier.fillMaxSize()) {
Box(
modifier = Modifier
.size(72.dp)
.background(Color.Red)
.physicsBody(key = "ball")
)
}
}API docs: https://goetzdebouville.github.io/PhysicsBox/api/
Short user guide on medium
Add Maven Central:
repositories {
mavenCentral()
}KMP (commonMain):
kotlin {
sourceSets {
val commonMain by getting {
dependencies {
implementation("io.github.zinchenko-dev:physicsbox:<latest_release>")
}
}
}
}Android-only:
dependencies {
implementation("io.github.zinchenko-dev:physicsbox-android:<latest_release>")
}Desktop-only:
dependencies {
implementation("io.github.zinchenko-dev:physicsbox-desktop:<latest_release>")
}PhysicsBox) with fixed-timestep simulation.Modifier.physicsBody.Read the full documentation at https://goetzdebouville.github.io/PhysicsBox/.
runtime, ui, foundation).Android:
./gradlew :androidApp:assembleDebug
androidApp/build/outputs/apk/debug/androidApp-debug.apk
Desktop:
./gradlew :desktopApp:run
./gradlew :desktopApp:hotRun --auto
PhysicsBox is a Compose Multiplatform physics layout container for Android and Desktop (JVM). It turns composables into 2D physics bodies and renders their motion by applying translation and rotation during layout.
The runtime uses JBox2D on JVM platforms, giving you stable rigid-body simulation with fixed-timestep stepping, boundaries, dragging, and collision callbacks.
Inspired by PhysicsLayout.
kotlin {
sourceSets {
val commonMain by getting {
dependencies {
implementation("io.github.zinchenko-dev:physicsbox:<latest_release>")
}
}
}
}@Composable
fun PhysicsDemo() {
PhysicsBox(modifier = Modifier.fillMaxSize()) {
Box(
modifier = Modifier
.size(72.dp)
.background(Color.Red)
.physicsBody(key = "ball")
)
}
}API docs: https://goetzdebouville.github.io/PhysicsBox/api/
Short user guide on medium
Add Maven Central:
repositories {
mavenCentral()
}KMP (commonMain):
kotlin {
sourceSets {
val commonMain by getting {
dependencies {
implementation("io.github.zinchenko-dev:physicsbox:<latest_release>")
}
}
}
}Android-only:
dependencies {
implementation("io.github.zinchenko-dev:physicsbox-android:<latest_release>")
}Desktop-only:
dependencies {
implementation("io.github.zinchenko-dev:physicsbox-desktop:<latest_release>")
}PhysicsBox) with fixed-timestep simulation.Modifier.physicsBody.Read the full documentation at https://goetzdebouville.github.io/PhysicsBox/.
runtime, ui, foundation).Android:
./gradlew :androidApp:assembleDebug
androidApp/build/outputs/apk/debug/androidApp-debug.apk
Desktop:
./gradlew :desktopApp:run
./gradlew :desktopApp:hotRun --auto