dymokomi/luced-2d
Source of release 0.5.0
## The look: brutalist, grey, one orange, square. Values are eleusis-layout's,
## authored in sRGB bytes and converted to the linear light the GPU blends in.
from luce_ui.ui import Theme
from luce_gpu.gpu import Color
from hex_color import parse_hex
from luce_color import transfer
func linear(byte: float) -> float:
return transfer.srgb_decode(byte / 255.0)
pub func grey(byte: float) -> Color:
return Color(linear(byte), linear(byte), linear(byte))
pub func srgb(red: float, green: float, blue: float) -> Color:
return Color(linear(red), linear(green), linear(blue))
## The part of the look Settings can change: the accent, as sRGB hex, and the
## control radius. The unfocused selection is the accent at about half its
## light, as eleusis's is. An invalid hex keeps the orange.
pub class Look:
pub var accent: Color = Color(0.0, 0.0, 0.0)
pub var selection_inactive: Color = Color(0.0, 0.0, 0.0)
pub var control_radius: float = 5.0
pub func init(self, hex: str = "#e7a03f", radius: float = 5.0) -> unit!:
# The default accent is #E7A03F, everything the eye is meant to go to; text on it is black.
let components = parse_hex(hex) else [231.0 / 255.0, 160.0 / 255.0, 63.0 / 255.0]
let channel = [components[0] * 255.0, components[1] * 255.0, components[2] * 255.0]
self.accent = srgb(channel[0], channel[1], channel[2])
self.selection_inactive = srgb(channel[0] * 0.52, channel[1] * 0.525, channel[2] * 0.635)
self.control_radius = radius
## eleusis-layout's greys, darkest to lightest where they stack: the window
## backdrop, the tab strip, a pane's surface, a raised surface and a border.
pub func backdrop() -> Color:
return grey(26.0)
pub func tab_strip() -> Color:
return grey(38.0)
pub func surface() -> Color:
return grey(50.0)
pub func surface_raised() -> Color:
return grey(46.0)
pub func border() -> Color:
return grey(58.0)
## Text on the accent: black on the orange.
pub func on_accent() -> Color:
return grey(0.0)
pub func text() -> Color:
return grey(217.0)
pub func text_muted() -> Color:
return grey(140.0)
pub func checker_light() -> Color:
return grey(70.0)
pub func checker_dark() -> Color:
return grey(56.0)
pub func editor_theme(look: Look) -> Theme!:
var theme = Theme()
theme.background = backdrop()
theme.panel = surface()
theme.gutter = tab_strip()
theme.foreground = text()
theme.muted = text_muted()
theme.selection = look.accent
theme.accent = look.accent
theme.button = grey(41.0)
theme.button_hover = grey(58.0)
theme.pressed = grey(72.0)
theme.menu = surface_raised()
theme.menu_hover = grey(64.0)
theme.strip = tab_strip()
theme.sunken = grey(41.0)
theme.raised = surface_raised()
theme.accent_text = grey(0.0)
theme.menu_selection = look.accent
theme.border = border()
theme.active_border = grey(150.0)
theme.shadow_offset = 0.0
theme.shadow_opacity = 0.0
theme.control_radius = look.control_radius
return theme