Skip to content

Commit

Permalink
Fixed #118: Added color constants
Browse files Browse the repository at this point in the history
  • Loading branch information
davesmith00000 committed Dec 21, 2024
1 parent 039671b commit f11cdfb
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
33 changes: 33 additions & 0 deletions ultraviolet/shared/src/main/scala/ultraviolet/colors.scala
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit f11cdfb

Please sign in to comment.