Repository navigation
Colors and Gradients
Colors in different color spaces, gradients and brushes.
A color is a plain ARGB int, with no objects and no allocations.
Color.rgb(255, 128, 0); Color.rgba(255, 128, 0, 0.5f); Color.hex("#5B8CFF");
Color.hsv(200, 0.8f, 1f); Color.hsl(200, 0.8f, 0.6f); Color.oklch(0.7f, 0.15f, 250);
Color.parse("rgb(255 128 0 / 50%)"); Color.parse("hsl(200, 80%, 60%)"); Color.parse("tomato");
Color.rainbow(t); // rainbow for t ∈ [0, 1]Operations are computed in OKLCH, so "10% lighter" looks the same for any hue:
lighten, darken, saturate, desaturate, rotateHue, withHue, complement, grayscale, invert,
withAlpha, mulAlpha, luminance, contrast (WCAG), readableOn (black or white text on a background),
over (compositing). Mixing: Color.lerp(a, b, t) (sRGB), Color.mix(a, b, t) (OKLAB),
Color.lerp(a, b, t, ColorSpace.OKLCH).
The hex format matches a Java int: #AARRGGBB (or #RRGGBB).
| Brush | Example |
|---|---|
| Solid | Brush.solid(0xFF5B8CFF) |
| Linear |
Brush.linear(135, a, b, c), Brush.vertical(a, b), Brush.horizontal(a, b)
|
| Radial |
Brush.radial(center, edge), .at(0.3f, 0.3f), .withRadius(0.7f, 0.35f) (ellipse) |
| Conic |
Brush.conic(angle, colors...), Brush.rainbowWheel()
|
- Up to 8 colors, arbitrary positions and hard stops:
ColorStops.builder().add(0, a).hard(0.5f, a, b).add(1, b).build(). -
.withRepeating(true)repeats the pattern (stripes, rings),.withOffset(x)shifts it (moving stripes). -
.inSpace(ColorSpace.OKLAB / OKLCH / LINEAR / HSV / SRGB)picks the mixing color space. - Angles work as in CSS: 0° points up, 90° points right.
- Ready-made sets are in
Gradients: SUNSET, OCEAN, AURORA, NEON, FIRE, MINT, PEACH, NIGHT, GOLD, BERRY, LIME, RAINBOW.
Gradients are computed per pixel in the SDF shader, with dithering against banding. Simple two-color linear
gradients take a fast path through vertex colors. Brushes can be animated (Brush.lerp), including the
transition solid ↔ gradient.
Canvas also has drawArc (arcs with a gradient), fillCircle and strokeCircle, drawLine, fillTriangle,
fillQuad, drawTextureQuad (a texture on an arbitrary quad), drawItem("minecraft:tnt", x, y, size)
and setBlendMode(NORMAL | ADD | MULTIPLY | SCREEN).
← Styles and Themes · English home · Animations →
Начало работы: Установка · Первый экран
Основы: Раскладка · Стили и темы · Цвета и градиенты · Анимации · Данные и сигналы · События и ввод
Виджеты: Каталог виджетов · Всплывающие окна · Формы · Markdown и книги
Игра: Инвентарь и слоты · Окна-контейнеры · Мобы, предметы и 3D · HUD · Карты
Оформление: Эффекты · Размытие, обрезка и GIF
HTML и CSS: HTML и CSS
Возможности: Языки · Экран настроек · Доступность и звуки
Для продвинутых: Расширение · Отладка и советы · Архитектура
Getting started: Installation · Your First Screen
Basics: Layout · Styles and Themes · Colors and Gradients · Animations · Data and Signals · Events and Input
Widgets: Widget Catalog · Popups · Forms · Markdown and Books
Game: Inventory and Slots · Container Screens · Mobs, Items and 3D · HUD Overlay · Maps
Visuals: Effects · Blur, Clipping and GIF
HTML and CSS: HTML and CSS
Features: Languages · Config Screen · Accessibility and Sounds
Advanced: Extending · Debugging and Tips · Architecture