aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/play/PlayShowProgram.kt
blob: 4107cd7da3be2eaa8175f316ea7d7210963eed7c (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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package play

import org.openrndr.application
import org.openrndr.draw.*
import org.openrndr.extra.olive.oliveProgram
import phenax.utils.*

fun main() = application {
  recordDuration(10)

  configure {
    width = 640
    height = 480
    windowResizable = false
  }

  oliveProgram {
    // val image = loadImage("data/images/pm5544.png")
    // val font = loadFont("data/fonts/default.otf", 64.0)

    val cs = computeStyle {
      computeTransform =
              """
          ivec2 coords = ivec2(gl_GlobalInvocationID.xy);
          ivec2 resolution = imageSize(p_outputImg).xy;
          float aspect_ratio = resolution.y*1.0 / resolution.x;

          vec2 uv = vec2(1.0, aspect_ratio) * (coords - 0.5*resolution)/resolution;
          float dist = length(uv) - 0.1;
          float step = step(0.0, dist);

          vec4 color = vec4(step, 0.0, 0.0, 1.0);
          imageStore(p_outputImg, coords, color);
      """.trimIndent()
    }

    // val inputBuffer = colorBuffer(width, height, type = ColorType.UINT8)

    val outputBuffer = colorBuffer(width, height, type = ColorType.UINT8)

    extend {
      // drawer.drawStyle.colorMatrix = tint(ColorRGBa.WHITE.shade(0.2))
      // drawer.image(image)

      // drawer.fill = ColorRGBa.PINK
      // drawer.circle(
      //         cos(seconds) * width / 2.0 + width / 2.0,
      //         sin(0.5 * seconds) * height / 2.0 + height / 2.0,
      //         140.0
      // )

      // drawer.fontMap = font
      // drawer.fill = ColorRGBa.WHITE
      // drawer.text("OPENRNDR", width / 2.0, height / 2.0)

      cs.parameter("seconds", seconds)
      cs.image("outputImg", outputBuffer.imageBinding(0, ImageAccess.WRITE))
      cs.execute(outputBuffer.width, outputBuffer.height, 1)
      drawer.image(outputBuffer)
    }
  }
}