Update demos to use MouseTracker (#303)
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
import org.openrndr.MouseTracker
|
||||||
import org.openrndr.application
|
import org.openrndr.application
|
||||||
import org.openrndr.color.ColorRGBa
|
import org.openrndr.color.ColorRGBa
|
||||||
import org.openrndr.draw.*
|
import org.openrndr.draw.*
|
||||||
@@ -37,6 +38,7 @@ fun main() = application {
|
|||||||
//x_fill.rgb = vec3(1.0 / (x_fill.r + x_fill.g));
|
//x_fill.rgb = vec3(1.0 / (x_fill.r + x_fill.g));
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
|
val mouseTracker = MouseTracker(mouse)
|
||||||
|
|
||||||
extend {
|
extend {
|
||||||
// Draw moving white shapes on a black background
|
// Draw moving white shapes on a black background
|
||||||
@@ -68,7 +70,7 @@ fun main() = application {
|
|||||||
directionalField.apply(rt.colorBuffer(0), result)
|
directionalField.apply(rt.colorBuffer(0), result)
|
||||||
|
|
||||||
drawer.isolated {
|
drawer.isolated {
|
||||||
if (mouse.pressedButtons.isEmpty()) {
|
if (mouseTracker.pressedButtons.isEmpty()) {
|
||||||
shadeStyle = shader
|
shadeStyle = shader
|
||||||
image(result)
|
image(result)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import org.openrndr.MouseTracker
|
||||||
import org.openrndr.application
|
import org.openrndr.application
|
||||||
import org.openrndr.color.ColorRGBa
|
import org.openrndr.color.ColorRGBa
|
||||||
import org.openrndr.draw.*
|
import org.openrndr.draw.*
|
||||||
@@ -42,6 +43,7 @@ fun main() = application {
|
|||||||
vec3(1.0, 0.0, 0.0) : vec3(0.0, 1.0, 1.0));
|
vec3(1.0, 0.0, 0.0) : vec3(0.0, 1.0, 1.0));
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
|
val mouseTracker = MouseTracker(mouse)
|
||||||
|
|
||||||
extend {
|
extend {
|
||||||
// Draw moving white shapes on a black background
|
// Draw moving white shapes on a black background
|
||||||
@@ -73,7 +75,7 @@ fun main() = application {
|
|||||||
distanceField.apply(rt.colorBuffer(0), result)
|
distanceField.apply(rt.colorBuffer(0), result)
|
||||||
|
|
||||||
drawer.isolated {
|
drawer.isolated {
|
||||||
if (mouse.pressedButtons.isEmpty()) {
|
if (mouseTracker.pressedButtons.isEmpty()) {
|
||||||
shadeStyle = shader
|
shadeStyle = shader
|
||||||
image(result)
|
image(result)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import org.openrndr.MouseTracker
|
||||||
import org.openrndr.application
|
import org.openrndr.application
|
||||||
import org.openrndr.draw.ColorFormat
|
import org.openrndr.draw.ColorFormat
|
||||||
import org.openrndr.draw.ColorType
|
import org.openrndr.draw.ColorType
|
||||||
@@ -19,8 +20,10 @@ fun main() {
|
|||||||
sdf.setShapes(shapes)
|
sdf.setShapes(shapes)
|
||||||
sdf.apply(emptyArray(), df)
|
sdf.apply(emptyArray(), df)
|
||||||
|
|
||||||
|
val mouseTracker = MouseTracker(mouse)
|
||||||
|
|
||||||
extend {
|
extend {
|
||||||
if(mouse.pressedButtons.isEmpty())
|
if(mouseTracker.pressedButtons.isEmpty())
|
||||||
drawer.image(df)
|
drawer.image(df)
|
||||||
else
|
else
|
||||||
drawer.shapes(shapes)
|
drawer.shapes(shapes)
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import ddf.minim.ugens.Oscil
|
import ddf.minim.ugens.Oscil
|
||||||
import ddf.minim.ugens.Pan
|
import ddf.minim.ugens.Pan
|
||||||
|
import org.openrndr.MouseTracker
|
||||||
import org.openrndr.application
|
import org.openrndr.application
|
||||||
import org.openrndr.color.rgb
|
import org.openrndr.color.rgb
|
||||||
import org.openrndr.extra.minim.minim
|
import org.openrndr.extra.minim.minim
|
||||||
@@ -31,7 +32,7 @@ fun main() {
|
|||||||
// and the current amplitude defined by the lfo (low frequency
|
// and the current amplitude defined by the lfo (low frequency
|
||||||
// oscillator).
|
// oscillator).
|
||||||
val synths = List(20) {
|
val synths = List(20) {
|
||||||
// By default Oscil creates sine waves, but it can be changed.
|
// By default, Oscil creates sine waves, but it can be changed.
|
||||||
val lfo = Oscil(
|
val lfo = Oscil(
|
||||||
Random.nextFloat() * 0.1f + 0.005f,
|
Random.nextFloat() * 0.1f + 0.005f,
|
||||||
0.05f
|
0.05f
|
||||||
@@ -56,6 +57,7 @@ fun main() {
|
|||||||
}
|
}
|
||||||
val bgColor = rgb(0.094, 0.188, 0.349)
|
val bgColor = rgb(0.094, 0.188, 0.349)
|
||||||
val lineColor = rgb(0.992, 0.918, 0.671)
|
val lineColor = rgb(0.992, 0.918, 0.671)
|
||||||
|
val mouseTracker = MouseTracker(mouse)
|
||||||
|
|
||||||
extend {
|
extend {
|
||||||
drawer.clear(bgColor)
|
drawer.clear(bgColor)
|
||||||
@@ -78,7 +80,7 @@ fun main() {
|
|||||||
circle(pos, 500 * lfo.lastValues.last().toDouble())
|
circle(pos, 500 * lfo.lastValues.last().toDouble())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (mouse.pressedButtons.isNotEmpty()) {
|
if (mouseTracker.pressedButtons.isNotEmpty()) {
|
||||||
synths.random().first.setFrequency(randomFreq())
|
synths.random().first.setFrequency(randomFreq())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import org.openrndr.MouseButton
|
import org.openrndr.MouseButton
|
||||||
|
import org.openrndr.MouseTracker
|
||||||
import org.openrndr.application
|
import org.openrndr.application
|
||||||
import org.openrndr.color.ColorHSVa
|
import org.openrndr.color.ColorHSVa
|
||||||
import org.openrndr.color.ColorRGBa
|
import org.openrndr.color.ColorRGBa
|
||||||
@@ -41,6 +42,7 @@ fun main() {
|
|||||||
100.0 + it * 10.0),
|
100.0 + it * 10.0),
|
||||||
Polar(Random.double(-1.0, 1.0), 0.0))
|
Polar(Random.double(-1.0, 1.0), 0.0))
|
||||||
}
|
}
|
||||||
|
val mouseTracker = MouseTracker(mouse)
|
||||||
|
|
||||||
extend {
|
extend {
|
||||||
drawer.isolatedWithTarget(dry) {
|
drawer.isolatedWithTarget(dry) {
|
||||||
@@ -61,7 +63,7 @@ fun main() {
|
|||||||
|
|
||||||
// draw dark gray window border.
|
// draw dark gray window border.
|
||||||
// hold mouse button to fade in.
|
// hold mouse button to fade in.
|
||||||
borderOpacity += if (MouseButton.LEFT in mouse.pressedButtons) 0.01 else -0.01
|
borderOpacity += if (MouseButton.LEFT in mouseTracker.pressedButtons) 0.01 else -0.01
|
||||||
borderOpacity = borderOpacity.clamp(0.0, 1.0)
|
borderOpacity = borderOpacity.clamp(0.0, 1.0)
|
||||||
stroke = rgb(0.2).opacify(borderOpacity)
|
stroke = rgb(0.2).opacify(borderOpacity)
|
||||||
fill = null
|
fill = null
|
||||||
|
|||||||
Reference in New Issue
Block a user