Created
February 8, 2020 01:51
-
-
Save dmitrykolesnikovich/23ba87ce6ab1fb87222ee90d73dd1576 to your computer and use it in GitHub Desktop.
How to create GLSL bindings for Kotlin.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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