Skip to content

Instantly share code, notes, and snippets.

@dmitrykolesnikovich
Created February 8, 2020 01:51
Show Gist options
  • Save dmitrykolesnikovich/23ba87ce6ab1fb87222ee90d73dd1576 to your computer and use it in GitHub Desktop.
Save dmitrykolesnikovich/23ba87ce6ab1fb87222ee90d73dd1576 to your computer and use it in GitHub Desktop.
How to create GLSL bindings for Kotlin.
import java.lang.Math.*
val t: Double = 0.0
data class vec2(var x: Double = 0.0, var y: Double = 0.0)
open class Pixel {
val uv: vec2 = vec2()
}
data class Circle(var position: vec2, var radius: Double) : Pixel()
operator fun vec2.plusAssign(value: Double) {
this.x += value.toInt()
this.y += value.toInt()
}
fun drawCircle(position: vec2 = vec2(), radius: Double, init: Circle.() -> Unit) = Circle(position, radius).init()
fun main() {
drawCircle(vec2(0.1, 0.1), 0.2) {
radius -= cos(t * PI)
position += sin(uv.x * PI)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment