Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed #118: Added color constants #131

Merged
merged 1 commit into from
Dec 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Loading