Skip to content

Commit

Permalink
Update examples
Browse files Browse the repository at this point in the history
  • Loading branch information
hamoid committed May 12, 2023
1 parent e940ac1 commit 46a7a40
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

package examples.`06_Advanced_drawing`

import org.intellij.lang.annotations.Language
import org.openrndr.application
import org.openrndr.color.ColorRGBa
import org.openrndr.draw.*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

package examples.`06_Advanced_drawing`

import org.intellij.lang.annotations.Language
import org.openrndr.application
import org.openrndr.color.ColorRGBa
import org.openrndr.draw.*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

package examples.`06_Advanced_drawing`

import org.intellij.lang.annotations.Language
import org.openrndr.application
import org.openrndr.color.ColorRGBa
import org.openrndr.draw.*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

package examples.`06_Advanced_drawing`

import org.intellij.lang.annotations.Language
import org.openrndr.application
import org.openrndr.color.ColorRGBa
import org.openrndr.draw.*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

package examples.`06_Advanced_drawing`

import org.intellij.lang.annotations.Language
import org.openrndr.application
import org.openrndr.color.ColorRGBa
import org.openrndr.draw.*
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@

package examples.`06_Advanced_drawing`

import org.intellij.lang.annotations.Language
import org.openrndr.application
import org.openrndr.color.ColorRGBa
import org.openrndr.draw.*
import org.openrndr.extra.camera.OrbitalCamera
import org.openrndr.extra.meshgenerators.sphereMesh
import org.openrndr.math.Vector3
import org.openrndr.shape.Circle
import kotlin.math.cos
import kotlin.math.sin

fun main() {
application {
program {
val style = shadeStyle {
// Define the `random` function and declare a `c`
// variable to pass to the fragment shader.
vertexPreamble = """
float random(vec2 st) {
return fract(sin(dot(st.xy,
vec2(12.9898, 78.233))) * 43758.5453123);
}
out vec3 c;
""".trimIndent()

// Calculate the value of `c` per vertex.
// It will get interpolated by the GPU.
vertexTransform = """
c.r = random(x_position.xy);
c.g = random(x_position.yx);
c.b = random(x_position.xy + 1.0);
""".trimIndent()

// Declare a `c` variable to receive from the vertex shader.
fragmentPreamble = "in vec3 c;"
// Use the value of `c` to set the color of a pixel.
fragmentTransform = "x_fill.rgb = c;"
}
extend {
drawer.shadeStyle = style
repeat(7) {
// Notice how we do not set `drawer.fill`.
drawer.rectangle(50.0 + it * 77, 50.0, 70.0, 390.0)
}
}
}
}
}

0 comments on commit 46a7a40

Please sign in to comment.