Fix fragmentTransform of linearGradient

This commit is contained in:
Edwin Jakobs
2020-02-14 14:31:26 +01:00
parent 2e1431ad9f
commit c2791fb851
2 changed files with 24 additions and 7 deletions

View File

@@ -97,8 +97,20 @@ class GUI : Extension {
this.height = 100.percent
}
styleSheet(has class_ "collapse-border") {
this.display = Display.FLEX
this.flexDirection = FlexDirection.Column
this.height = 5.px
this.width = 100.percent
this.background = Color.RGBa(ColorRGBa.GRAY.shade(0.9))
and(has state "hover") {
this.background = Color.RGBa(ColorRGBa.GRAY.shade(1.1))
}
}
styleSheet(has class_ "toolbar") {
this.height = 50.px
this.height = 42.px
this.width = 100.percent
this.display = Display.FLEX
this.flexDirection = FlexDirection.Row
@@ -124,6 +136,7 @@ class GUI : Extension {
this.background = Color.RGBa(ColorRGBa.GRAY.copy(a = 0.99))
this.overflow = Overflow.Scroll
/* 1) setup control style */
descendant(has type "colorpicker-button") {
this.width = 175.px
@@ -178,6 +191,9 @@ class GUI : Extension {
}
}
}
val collapseBorder = div("collapse-border") {
}
val collapsibles = mutableSetOf<Div>()
val sidebar = div("sidebar") {
@@ -230,11 +246,11 @@ class GUI : Extension {
}
}
}
header.mouse.pressed.subscribe {
collapseBorder.mouse.pressed.subscribe {
it.cancelPropagation()
}
header.mouse.clicked.subscribe {
collapseBorder.mouse.clicked.subscribe {
val collapsed = ElementClass("collapsed")
if (collapsed in sidebar.classes) {
sidebar.classes.remove(collapsed)

View File

@@ -8,7 +8,7 @@ import org.openrndr.math.Vector2
fun linearGradient(color0: ColorRGBa, color1: ColorRGBa, offset : Vector2 = Vector2.ZERO, rotation:Double = 0.0) : ShadeStyle {
return shadeStyle {
fragmentTransform = """
vec2 coord = (c_boundsPosition.xy - vec2(0.5) + offset);
vec2 coord = (c_boundsPosition.xy - vec2(0.5) + p_offset);
float cr = cos(p_rotation);
float sr = sin(p_rotation);
mat2 rm = mat2(cr, -sr, sr, cr);
@@ -30,7 +30,7 @@ fun linearGradient(color0: ColorRGBa, color1: ColorRGBa, offset : Vector2 = Vect
}
}
fun radialGradient(color0: ColorRGBa, color1: ColorRGBa, offset: Vector2 = Vector2.ZERO, rotation:Double = 0.0) : ShadeStyle {
fun radialGradient(color0: ColorRGBa, color1: ColorRGBa, offset: Vector2 = Vector2.ZERO, rotation:Double = 0.0, length: Double = 1.0) : ShadeStyle {
return shadeStyle {
fragmentTransform = """
vec2 coord = (c_boundsPosition.xy - vec2(0.5) + p_offset/2.0) * 2.0;
@@ -38,7 +38,7 @@ fun radialGradient(color0: ColorRGBa, color1: ColorRGBa, offset: Vector2 = Vecto
float cr = cos(p_rotation);
float sr = sin(p_rotation);
mat2 rm = mat2(cr, -sr, sr, cr);
float f = clamp(length(rm * coord), 0.0, 1.0);
float f = clamp(p_length * length(rm * coord), 0.0, 1.0);
vec4 gradient = p_color0 * (1.0-f) + p_color1 * f;
@@ -52,7 +52,8 @@ fun radialGradient(color0: ColorRGBa, color1: ColorRGBa, offset: Vector2 = Vecto
parameter("offset", offset)
parameter("color0", color0.alphaMultiplied)
parameter("color1", color1.alphaMultiplied)
parameter("rotation", Math.toRadians(rotation) )
parameter("rotation", Math.toRadians(rotation))
parameter("length", length)
}
}