aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/org/openrndr/Preload.kt
blob: 42bab948bd1542b685ae08d3e3c9aaa0a931202e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package org.openrndr

import org.openrndr.draw.*
import org.openrndr.extensions.SingleScreenshot
import org.openrndr.extra.olive.*
import org.openrndr.ffmpeg.ScreenRecorder
import phenax.utils.*

class Preload : ApplicationPreload() {
  override fun onProgramSetup(program: Program) {
    println("Program: ${program.name}")
    if (recordingEnabled) {
      program.extend(ScreenRecorder()) {
        outputToVideo = true
        outputFile = "video/${program.name}.mp4"
        frameRate = 60
        maximumDuration = recordDuration()
        quitAfterMaximum = true
        multisample = BufferMultisample.SampleCount(16)
      }
    } else if (screenshotEnabled) {
      program.extend(SingleScreenshot()) {
        outputFile = "screenshot/${program.name}.png"
        async = false
        quitAfterScreenshot = true
      }
    }
  }
}