From f11cdfb50e6b1f407c6cd69dc9193641d9cdf287 Mon Sep 17 00:00:00 2001 From: davesmith00000 Date: Sat, 21 Dec 2024 16:06:29 +0000 Subject: [PATCH] Fixed #118: Added color constants --- .../sandbox/shaders/ShaderPrograms.scala | 3 +- .../src/main/scala/ultraviolet/colors.scala | 33 +++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 ultraviolet/shared/src/main/scala/ultraviolet/colors.scala diff --git a/sandbox/uvsandbox/src/main/scala/com/example/sandbox/shaders/ShaderPrograms.scala b/sandbox/uvsandbox/src/main/scala/com/example/sandbox/shaders/ShaderPrograms.scala index e68bbb2..b989d83 100644 --- a/sandbox/uvsandbox/src/main/scala/com/example/sandbox/shaders/ShaderPrograms.scala +++ b/sandbox/uvsandbox/src/main/scala/com/example/sandbox/shaders/ShaderPrograms.scala @@ -157,8 +157,9 @@ object TriangleShader: object FillColorHelper: import ultraviolet.syntax.* + import ultraviolet.colors.* inline def fill(uv: vec2, sdf: Float): vec4 = - val fill = vec4(uv, 0.0f, 1.0f) + val fill = vec4(uv, Blue.z, 1.0f) val fillAmount = (1.0f - step(0.0f, sdf)) * fill.w vec4(fill.xyz * fillAmount, fillAmount) diff --git a/ultraviolet/shared/src/main/scala/ultraviolet/colors.scala b/ultraviolet/shared/src/main/scala/ultraviolet/colors.scala new file mode 100644 index 0000000..f4d2979 --- /dev/null +++ b/ultraviolet/shared/src/main/scala/ultraviolet/colors.scala @@ -0,0 +1,33 @@ +package ultraviolet + +import ultraviolet.syntax.* + +// https://en.wikipedia.org/wiki/X11_color_names + +object colors: + + inline def Red: vec4 = vec4(1.0f, 0.0f, 0.0f, 1.0f) + inline def Green: vec4 = vec4(0.0f, 1.0f, 0.0f, 1.0f) + inline def Blue: vec4 = vec4(0.0f, 0.0f, 1.0f, 1.0f) + inline def Yellow: vec4 = vec4(1.0f, 1.0f, 0.0f, 1.0f) + inline def Magenta: vec4 = vec4(1.0f, 0.0f, 1.0f, 1.0f) + inline def Cyan: vec4 = vec4(0.0f, 1.0f, 1.0f, 1.0f) + inline def White: vec4 = vec4(1.0f, 1.0f, 1.0f, 1.0f) + inline def Black: vec4 = vec4(0.0f, 0.0f, 0.0f, 1.0f) + inline def Coral: vec4 = vec4(1.0f, 0.498f, 0.314f, 1.0f) + inline def Crimson: vec4 = vec4(0.863f, 0.078f, 0.235f, 1.0f) + inline def DarkBlue: vec4 = vec4(0.0f, 0.0f, 0.545f, 1.0f) + inline def Indigo: vec4 = vec4(0.294f, 0.0f, 0.510f, 1.0f) + inline def Olive: vec4 = vec4(0.502f, 0.502f, 0.0f, 1.0f) + inline def Orange: vec4 = vec4(1.0f, 0.647f, 0.0f, 1.0f) + inline def Pink: vec4 = vec4(1.0f, 0.753f, 0.796f, 1.0f) + inline def Plum: vec4 = vec4(0.867f, 0.627f, 0.867f, 1.0f) + inline def Purple: vec4 = vec4(0.627f, 0.125f, 0.941f, 1.0f) + inline def Salmon: vec4 = vec4(0.980f, 0.502f, 0.447f, 1.0f) + inline def SeaGreen: vec4 = vec4(0.180f, 0.545f, 0.341f, 1.0f) + inline def Silver: vec4 = vec4(0.753f, 0.753f, 0.753f, 1.0f) + inline def SlateGray: vec4 = vec4(0.439f, 0.502f, 0.565f, 1.0f) + inline def SteelBlue: vec4 = vec4(0.275f, 0.510f, 0.706f, 1.0f) + inline def Teal: vec4 = vec4(0.0f, 0.502f, 0.502f, 1.0f) + inline def Thistle: vec4 = vec4(0.847f, 0.749f, 0.847f, 1.0f) + inline def Tomato: vec4 = vec4(1.0f, 0.388f, 0.278f, 1.0f)