Skip to content

Commit

Permalink
Add fps to gart
Browse files Browse the repository at this point in the history
  • Loading branch information
igr committed Mar 17, 2024
1 parent 8342e42 commit df3b087
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions gartwork/src/main/kotlin/dev/oblac/gart/Gart.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,14 @@ data class Gart(
* The name of the Gart.
*/
val name: String,
/**
* The default dimension of the Gart.
*/
val d: Dimension,
/**
* The default frames per second of the Gart.
*/
val fps: Int,
) {

fun gartvas(dimension: Dimension = this.d) = Gartvas(dimension)
Expand All @@ -19,15 +26,15 @@ data class Gart(

fun dimension(width: Int, height: Int) = Dimension(width, height)

fun window(d: Dimension = this.d, fps: Int = 60, printFps: Boolean = true) = Window(d, fps, printFps)
fun window(d: Dimension = this.d, fps: Int = this.fps, printFps: Boolean = true) = Window(d, fps, printFps)

fun movie(d: Dimension = this.d, name: String = "${this.name}.mp4") = Movie(d, name)

fun saveImage(gartvas: Gartvas, name: String = "${this.name}.png") = saveImageToFile(gartvas, name)

fun saveImage(canvas: Canvas, d: Dimension = this.d, name: String = "${this.name}.png") = saveImageToFile(canvas, d, name)

fun saveMovie(movie: Movie, fps: Int, name: String = "${this.name}.mp4") = saveMovieToFile(movie, fps, name)
fun saveMovie(movie: Movie, fps: Int = this.fps, name: String = "${this.name}.mp4") = saveMovieToFile(movie, fps, name)

fun showImage(gartvas: Gartvas) {
window(gartvas.d).show { c, _, _ ->
Expand All @@ -40,6 +47,6 @@ data class Gart(
}

companion object {
fun of(name: String, width: Int, height: Int) = Gart(name, Dimension(width, height))
fun of(name: String, width: Int, height: Int, fps: Int = 60) = Gart(name, Dimension(width, height), fps)
}
}

0 comments on commit df3b087

Please sign in to comment.