Skip to content

Tool to create, preview, and save GIFs using Compose Desktop

License

Notifications You must be signed in to change notification settings

vitorhugods/Camcorder

Repository files navigation

Camcorder

Tool to create, preview and save GIF animations use Compose Desktop.

You can use both frame count and/or elapsed time to draw the frames.

How to use

  1. Add the dependency to your Compose Desktop project:
val jvmMain by getting {
    dependencies {
        implementation("xyz.schwaab:camcorder:0.0.1-beta")
    }
}

It should look similar to this:

plugins {
    kotlin("multiplatform")
    id("org.jetbrains.compose")
}

kotlin {
    sourceSets {
        val jvmMain by getting {
            dependencies {
                implementation("xyz.schwaab:camcorder:0.0.1-beta")
                implementation(compose.desktop.currentOs)
            }
        }
    }
}
  1. Call camcorderPreviewApplication passing AnimationSpecs, an output file and a FrameRenderer lambda:
@ExperimentalUnitApi
fun main() {
    camcorderPreviewApplication(AnimationSpecs(width, heigth, 1.seconds), "timeCounter.gif") { frame, timeInMillis: Long ->
        Box(modifier = Modifier.background(Color.Green).fillMaxSize()) {
            Text(
                "Time: ${timeInMillis}ms",
                color = bleuDeFrance,
                modifier = Modifier.align(Alignment.Center)
            )
        }
    }
}
  1. Run the application, and you can preview the animation:

Preview

  1. Click on Render to GIF, and the file will be saved:

Time-based sample

See samples for more examples on how to use. For a more complicated example, see Explosions.kt:

Explosions sample

About

Tool to create, preview, and save GIFs using Compose Desktop

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages