1

GitHub - vitorhugods/Camcorder: Tool to create, preview, and save GIFs using Com...

 7 months ago
source link: https://github.com/vitorhugods/camcorder
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

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:

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


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK