app: cherry-pick rune's pause and sound fixes onto the checkout
Rune comes from app/vendor/rune now, a checkout of 63ad0209 on branch ported, carrying the four commits of upstream issues 1320 (a pause while a clip is layered holds the layer's picture and time) and 1325 (a video's sound is read ahead of the clock and leads it). Both were written against eb9f1104 and ported across the refactors since. The faults are the first two and the third in docs/rune-upstream.md; the app's workarounds in review.rs stay until the fixes arrive upstream.
This commit is contained in:
1 parent
80fef698ce
commit
5bf262b82b
3795 files changed
+663463
-28
No files matched your search
+27
@@ -0,0 +1,27 @@
|
||||
[package]
|
||||
name = "showreel"
|
||||
version = "0.0.1"
|
||||
edition.workspace = true
|
||||
license.workspace = true
|
||||
publish = false
|
||||
|
||||
[dependencies]
|
||||
rune = { workspace = true, default-features = true, features = ["keys-overlay"] }
|
||||
rune-motion = { workspace = true }
|
||||
rune-fx = { workspace = true }
|
||||
wgpu = { workspace = true, features = ["std", "parking_lot", "wgsl"] }
|
||||
|
||||
[target.'cfg(target_vendor = "apple")'.dependencies]
|
||||
wgpu = { workspace = true, features = ["metal"] }
|
||||
|
||||
[target.'cfg(target_os = "windows")'.dependencies]
|
||||
wgpu = { workspace = true, features = ["dx12"] }
|
||||
|
||||
[target.'cfg(all(not(target_vendor = "apple"), not(target_arch = "wasm32"), not(target_os = "windows")))'.dependencies]
|
||||
wgpu = { workspace = true, features = ["vulkan"] }
|
||||
|
||||
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
||||
wgpu = { workspace = true, features = ["webgpu"] }
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
# showreel
|
||||
|
||||
The scene set behind Rune's README video.
|
||||
|
||||
Run one scene with `cargo run --release -p showreel -- --scene <name>`; record it with `--video out.mp4 --size 960x540 --scale 2 --fps 60 --duration D`.
|
||||
|
||||
Scenes: `word`, `card`, `deploy`, `glass`, `fire`, `pricing`, `ask`, `shock`, `keys`, `tabs`.
|
||||
+188
@@ -0,0 +1,188 @@
|
||||
//! The compositor: every `El::effect` slot becomes one rune-fx layer. The slot's mark says which
|
||||
//! effect, its `effect_data` carries the effect's few live numbers, and its presented rect and
|
||||
//! radius are the shape. Glass, lenses and shockwaves read a backdrop copy taken at their slot.
|
||||
|
||||
use rune::compose::{Compositor, Frame};
|
||||
use rune::render::{EffectPhase, EffectSite, KIND_EFFECT};
|
||||
use rune_fx::*;
|
||||
|
||||
use crate::State;
|
||||
|
||||
pub const CHROME: u32 = 1;
|
||||
pub const MESH: u32 = 2;
|
||||
pub const FLUTED: u32 = 3;
|
||||
pub const FIRE: u32 = 4;
|
||||
pub const ELECTRIC: u32 = 5;
|
||||
pub const ARC: u32 = 6;
|
||||
pub const GLOW: u32 = 7;
|
||||
pub const SPARKLES: u32 = 8;
|
||||
pub const SHOCK: u32 = 9;
|
||||
pub const LENS: u32 = 10;
|
||||
pub const PLASTIC: u32 = 11;
|
||||
pub const PULSE: u32 = 12;
|
||||
pub const SHIMMER: u32 = 13;
|
||||
pub const GRAIN: u32 = 14;
|
||||
pub const AURORA: u32 = 15;
|
||||
pub const HAZE: u32 = 16;
|
||||
pub const GRAIN_GRADIENT: u32 = 17;
|
||||
|
||||
/// Effect colours, by index (effect data carries the index).
|
||||
pub const COLORS: [u32; 14] = [
|
||||
0xffffff, 0x4f8dff, 0x22d3ee, 0x7c5cff, 0x34d399, 0xffb547, 0xff5ca8, 0xff4d4d, 0xff7a1a, 0xf1ece1, 0x2e3036, 0xe8552b,
|
||||
0x3d6bff, 0x54b3fd,
|
||||
];
|
||||
|
||||
fn col(i: f32) -> Rgb {
|
||||
rgb(COLORS[(i.max(0.0) as usize).min(COLORS.len() - 1)])
|
||||
}
|
||||
|
||||
fn layer(kind: u32, d: [f32; 4], shape: Shape, t: f32) -> Option<FxLayer> {
|
||||
let fx = match kind {
|
||||
CHROME => {
|
||||
let mut p = match d[0] as u32 {
|
||||
1 => LiquidMetalParams::gold(),
|
||||
2 => LiquidMetalParams::rose(),
|
||||
3 => LiquidMetalParams::gunmetal(),
|
||||
4 => LiquidMetalParams { light: rgb(0xd6e8ff), iridescence: 0.3, scale: 240.0, bevel: 3.5, dome: 0.2, contrast: 1.15, ..LiquidMetalParams::chrome() },
|
||||
5 => LiquidMetalParams { scale: 360.0, flow: 0.5, speed: 0.6, dome: 0.8, contrast: 0.85, bevel: 12.0, angle: 0.45, ..LiquidMetalParams::chrome() },
|
||||
_ => LiquidMetalParams::chrome(),
|
||||
};
|
||||
if d[2] > 0.0 {
|
||||
p.flow *= d[2];
|
||||
}
|
||||
if d[3] > 0.5 {
|
||||
p = p.anchor(FillAnchor::Element);
|
||||
}
|
||||
if d[1] > 0.0 { Fx::fill(p.border(d[1])) } else { Fx::fill(p) }
|
||||
}
|
||||
MESH => {
|
||||
let mut p = match d[0] as u32 {
|
||||
1 => MeshGradientParams::lagoon(),
|
||||
2 => MeshGradientParams::orchid(),
|
||||
3 => MeshGradientParams::graphite(),
|
||||
4 => MeshGradientParams { colors: Stops::hex(&[0x0d1b4c, 0x3d6bff, 0x9b5cff, 0x22d3ee, 0x101030]), ..MeshGradientParams::dusk() },
|
||||
5 => MeshGradientParams { colors: Stops::hex(&[0x2a0a12, 0xff4d4d, 0xffb547, 0x7a1640, 0xff7a1a]), ..MeshGradientParams::dusk() },
|
||||
6 => MeshGradientParams { colors: Stops::hex(&[0x062a24, 0x34d399, 0xd9f99d, 0x0f766e]), ..MeshGradientParams::dusk() },
|
||||
7 => MeshGradientParams { colors: Stops::hex(&[0x1a1033, 0xff5ca8, 0x7c5cff, 0xffd1e8, 0x2b1b5a]), ..MeshGradientParams::dusk() },
|
||||
_ => MeshGradientParams::dusk(),
|
||||
};
|
||||
if d[1] > 0.0 {
|
||||
p.speed = d[1];
|
||||
}
|
||||
if d[3] > 0.0 {
|
||||
p.drift = d[3];
|
||||
}
|
||||
return Some(Fx::fill(p).on(shape).at(t).seed(d[2] as u32 + 1));
|
||||
}
|
||||
FLUTED => Fx::fill(FlutedGlassParams { rib: d[0], refraction: d[1], frost: d[2], dispersion: d[3], highlight: 0.55, ..FlutedGlassParams::reeded() }),
|
||||
FIRE => {
|
||||
let style = match d[2] as u32 {
|
||||
1 => FireStyle::Border,
|
||||
2 => FireStyle::Heat,
|
||||
3 => FireStyle::Embers,
|
||||
_ => FireStyle::Top,
|
||||
};
|
||||
Fx::fire(FireParams { style, height: d[0], intensity: d[1], smoke: d[3], embers: 24, scale: 26.0, ..FireParams::default() })
|
||||
}
|
||||
ELECTRIC => {
|
||||
let base = if d[2] > 0.5 { ElectricParams::charged() } else { ElectricParams::default() };
|
||||
Fx::electric(ElectricParams { intensity: d[0], amplitude: if d[1] > 0.0 { d[1] } else { base.amplitude }, color: col(d[3]), ..base })
|
||||
}
|
||||
ARC => Fx::electric(ElectricParams { style: ElectricStyle::Arc { a: [d[0], d[1]], b: [d[2], d[3]] }, amplitude: 9.0, glow: 7.0, intensity: 1.2, ..Default::default() }),
|
||||
GLOW => {
|
||||
let style = match d[0] as u32 {
|
||||
1 => GlowStyle::Neon,
|
||||
2 => GlowStyle::Aura,
|
||||
_ => GlowStyle::Soft,
|
||||
};
|
||||
Fx::glow(GlowParams { style, color: col(d[1]), intensity: d[2], radius: if d[3] > 0.0 { d[3] } else { 14.0 }, aura_speed: 0.35, ..Default::default() })
|
||||
}
|
||||
SPARKLES => Fx::sparkles(SparkleParams { burst: (d[0] >= 0.0).then_some(d[0]), count: d[1] as u32, size: d[2], color: col(d[3]), margin: 26.0, ..Default::default() }),
|
||||
SHOCK => Fx::distort(DistortParams::Shockwave { at: [d[0], d[1]], reach: 1100.0, width: 90.0, amount: d[3], chroma: 0.6, t0: d[2], duration: 1.1 }),
|
||||
LENS => Fx::lens(LensParams {
|
||||
second: (d[2] > 0.0).then(|| Shape::circle(d[0], d[1], d[2])),
|
||||
frost: d[3],
|
||||
bevel: 16.0,
|
||||
depth: 20.0,
|
||||
dispersion: 0.18,
|
||||
magnification: 1.06,
|
||||
union_k: 26.0,
|
||||
..Default::default()
|
||||
}),
|
||||
PLASTIC => Fx::fill(PlasticParams { color: col(d[0]), roughness: d[1], dome: d[2], bevel: if d[3] > 0.0 { d[3] } else { 6.0 }, angle: -0.6 }),
|
||||
PULSE => {
|
||||
let style = match d[0] as u32 {
|
||||
1 => PulseStyle::Breathe,
|
||||
2 => PulseStyle::Heartbeat,
|
||||
_ => PulseStyle::Radar,
|
||||
};
|
||||
Fx::pulse(PulseParams { style, color: col(d[1]), reach: d[3], period: if d[2] > 0.0 { d[2] } else { 2.4 }, ..Default::default() })
|
||||
}
|
||||
SHIMMER => Fx::shimmer(ShimmerParams { intensity: d[0], period: d[1], band: d[2], ..Default::default() }),
|
||||
GRAIN => Fx::grain(GrainParams { amount: d[0], fps: d[1], ..Default::default() }),
|
||||
AURORA => Fx::aurora(AuroraParams { intensity: d[0], speed: d[1], ..Default::default() }),
|
||||
HAZE => Fx::distort(DistortParams::HeatHaze { height: d[0], scale: 14.0, speed: 1.4, amount: d[1], whole_shape: d[2] > 0.5 }),
|
||||
GRAIN_GRADIENT => Fx::fill(GrainGradientParams { kind: GradientKind::Radial, colors: Stops::hex(&[0x1b1530, 0x0a0a0c]), amount: 0.12, ..GrainGradientParams::default() }),
|
||||
_ => return None,
|
||||
};
|
||||
Some(fx.on(shape).at(t))
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct Gfx {
|
||||
fx: Option<FxRenderer>,
|
||||
}
|
||||
|
||||
impl Compositor<State> for Gfx {
|
||||
fn animating(&self) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
fn render(&mut self, f: &mut Frame<'_, State>) {
|
||||
let (device, queue, size) = (f.device, f.queue, f.size);
|
||||
let t = f.rt.t as f32;
|
||||
let marks = &f.rt.marks;
|
||||
let mut at: Vec<u32> = Vec::new();
|
||||
let mut layers: Vec<FxLayer> = Vec::new();
|
||||
let mut placements: Vec<FxSlot> = Vec::new();
|
||||
let mut fire = false;
|
||||
for (n, i) in f.rt.instances.iter().enumerate() {
|
||||
if i.params[1] != KIND_EFFECT {
|
||||
continue;
|
||||
}
|
||||
let kind = marks.get(n).copied().unwrap_or(0) & 0xff;
|
||||
let k = i.params[3];
|
||||
let [x, y, w, h] = i.rect.map(|v| v / k);
|
||||
let r = i.radii.iter().fold(0.0f32, |a, v| a.max(v.abs())) / k;
|
||||
let Some(l) = layer(kind, i.uv, Shape::rounded(x, y, w, h, r), t) else { continue };
|
||||
fire |= kind == FIRE;
|
||||
at.push(n as u32);
|
||||
layers.push(l);
|
||||
placements.push(FxSlot::default().scale(k).clip(i.clip, i.fade));
|
||||
}
|
||||
let fx = self.fx.get_or_insert_with(|| {
|
||||
let mut fx = FxRenderer::new(device, f.format, FxOptions { dither: true });
|
||||
fx.set_fire_sim(device, true);
|
||||
fx
|
||||
});
|
||||
fx.set_srgb_blend(f.srgb_blend());
|
||||
fx.add_format(device, wgpu::TextureFormat::Rgba16Float);
|
||||
fx.prepare_with_slots(device, queue, &FxFrame { viewport: [size.0, size.1], scale: 1.0, layers: &layers, backdrop: None, sources: &[] }, &placements);
|
||||
if fire {
|
||||
fx.simulate(queue, f.encoder, None);
|
||||
}
|
||||
let clear = f.rt.clear_color();
|
||||
f.ui.prepare(device, queue, &mut f.rt.text.atlas, &f.rt.instances, size);
|
||||
f.ui.draw_with_backdrop(f.encoder, f.target, clear, &mut |phase, s: &EffectSite<'_>| {
|
||||
let Some(k) = at.iter().position(|n| *n == s.index) else { return };
|
||||
match phase {
|
||||
EffectPhase::Backdrop(enc) => {
|
||||
if let Some(bd) = s.backdrop {
|
||||
fx.blur_backdrop(device, queue, enc, bd, k);
|
||||
}
|
||||
}
|
||||
EffectPhase::Draw(pass) => fx.draw_layer_in(pass, s.format, s.origin, k),
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
+118
@@ -0,0 +1,118 @@
|
||||
//! Shared look and motion helpers for the scenes.
|
||||
|
||||
use rune::color::Color;
|
||||
use rune::{El, TextStyle, el, text};
|
||||
use rune_motion::Spring;
|
||||
|
||||
pub const W: f32 = 960.0;
|
||||
pub const H: f32 = 540.0;
|
||||
|
||||
/// An sRGB hex colour.
|
||||
pub fn c(hex: u32) -> Color {
|
||||
let ch = |shift: u32| rune::color::srgb_decode(((hex >> shift) & 0xff) as f32 / 255.0);
|
||||
Color { r: ch(16), g: ch(8), b: ch(0), a: 1.0 }
|
||||
}
|
||||
|
||||
pub fn ca(hex: u32, a: f32) -> Color {
|
||||
c(hex).alpha(a)
|
||||
}
|
||||
|
||||
pub const BG: u32 = 0x0b0b0d;
|
||||
pub const PANEL: u32 = 0x141417;
|
||||
pub const RAISED: u32 = 0x1b1b1f;
|
||||
pub const TEXT: u32 = 0xededef;
|
||||
pub const MUTED: u32 = 0x9a9aa3;
|
||||
pub const FAINT: u32 = 0x5f5f68;
|
||||
|
||||
pub fn hair() -> Color {
|
||||
ca(0xffffff, 0.08)
|
||||
}
|
||||
|
||||
pub fn t(s: impl Into<String>, size: f32, weight: f32, color: u32) -> El {
|
||||
text(s).font(TextStyle::new(size, weight)).color(c(color))
|
||||
}
|
||||
|
||||
pub fn ta(s: impl Into<String>, size: f32, weight: f32, color: u32, alpha: f32) -> El {
|
||||
text(s).font(TextStyle::new(size, weight)).color(ca(color, alpha.clamp(0.0, 1.0)))
|
||||
}
|
||||
|
||||
pub fn mono_a(s: impl Into<String>, size: f32, color: u32, alpha: f32) -> El {
|
||||
text(s).font(TextStyle::new(size, 500.0).mono()).color(ca(color, alpha.clamp(0.0, 1.0)))
|
||||
}
|
||||
|
||||
pub fn mono(s: impl Into<String>, size: f32, color: u32) -> El {
|
||||
text(s).font(TextStyle::new(size, 500.0).mono()).color(c(color))
|
||||
}
|
||||
|
||||
/// An effect slot: `kind` is a `gfx` constant, `data` its numbers.
|
||||
pub fn fx(kind: u32, data: [f32; 4]) -> El {
|
||||
rune::effect(kind).effect_data(data)
|
||||
}
|
||||
|
||||
/// 0 → 1 between `t0` and `t0 + dur`, smoothstep.
|
||||
pub fn ease(t: f64, t0: f64, dur: f64) -> f32 {
|
||||
let x = ((t - t0) / dur).clamp(0.0, 1.0) as f32;
|
||||
x * x * (3.0 - 2.0 * x)
|
||||
}
|
||||
|
||||
/// A value that starts at `from` and springs to each key's target at its time, carrying velocity
|
||||
/// across retargets (as an interrupted Rune spring does).
|
||||
pub fn track(t: f64, from: f32, keys: &[(f64, f32, Spring)]) -> f32 {
|
||||
let (mut x, mut v, mut target, mut t0, mut spring) = (from, 0.0f32, from, 0.0f64, Spring::new(0.3, 0.0));
|
||||
for &(tk, to, sp) in keys {
|
||||
if t < tk {
|
||||
break;
|
||||
}
|
||||
let (nx, nv) = spring.sample(x, v, target, (tk - t0) as f32);
|
||||
x = nx;
|
||||
v = nv;
|
||||
target = to;
|
||||
t0 = tk;
|
||||
spring = sp;
|
||||
}
|
||||
spring.sample(x, v, target, (t - t0) as f32).0
|
||||
}
|
||||
|
||||
pub const fn sp(duration: f32, bounce: f32) -> Spring {
|
||||
Spring::new(duration, bounce)
|
||||
}
|
||||
|
||||
/// An iPad-style round pointer at (x, y), centred, squeezed while pressed.
|
||||
pub fn pointer(x: f32, y: f32, press: f32) -> El {
|
||||
let r = 9.0 * (1.0 - 0.22 * press);
|
||||
el().key("pointer")
|
||||
.absolute(x - r, y - r)
|
||||
.size(2.0 * r, 2.0 * r)
|
||||
.radius(r)
|
||||
.fill(ca(0xf4f4f6, 0.92))
|
||||
.border(1.0, ca(0x000000, 0.35))
|
||||
.shadow(2.0, 8.0, ca(0x000000, 0.45))
|
||||
}
|
||||
|
||||
/// A pointer that follows `path` (time, x, y) on springs and presses at each time in `taps`.
|
||||
pub fn pointer_at(t: f64, start: [f32; 2], path: &[(f64, f32, f32)], taps: &[f64]) -> El {
|
||||
let s = sp(0.55, 0.0);
|
||||
let kx: Vec<(f64, f32, Spring)> = path.iter().map(|&(tk, x, _)| (tk, x, s)).collect();
|
||||
let ky: Vec<(f64, f32, Spring)> = path.iter().map(|&(tk, _, y)| (tk, y, s)).collect();
|
||||
let x = track(t, start[0], &kx);
|
||||
let y = track(t, start[1], &ky);
|
||||
let k: Vec<(f64, f32, Spring)> = taps.iter().flat_map(|&tp| [(tp, 1.0, sp(0.12, 0.0)), (tp + 0.14, 0.0, sp(0.3, 0.4))]).collect();
|
||||
pointer(x, y, track(t, 0.0, &k))
|
||||
}
|
||||
|
||||
/// Press depth (0 → 1 → 0) for a tap at `tp`: down fast, back on a bouncy spring.
|
||||
pub fn pressed(t: f64, tp: f64) -> f32 {
|
||||
track(t, 0.0, &[(tp, 1.0, sp(0.12, 0.0)), (tp + 0.14, 0.0, sp(0.35, 0.45))])
|
||||
}
|
||||
|
||||
pub fn avatar(letter: &str, color: u32, size: f32) -> El {
|
||||
el().size(size, size)
|
||||
.radius(size / 2.0)
|
||||
.fill(c(color))
|
||||
.center()
|
||||
.child(t(letter, size * 0.42, 600.0, 0x0b0b0d))
|
||||
}
|
||||
|
||||
pub fn dot(color: u32, size: f32) -> El {
|
||||
el().size(size, size).radius(size / 2.0).fill(c(color))
|
||||
}
|
||||
+83
@@ -0,0 +1,83 @@
|
||||
//! Showreel: purpose-made 960×540 scenes for Rune's showcase video. Each scene animates itself from
|
||||
//! the (virtual) clock, so a headless `--video` run records it frame-exact:
|
||||
//!
|
||||
//! showreel --scene deploy --video deploy.mp4 --size 960x540 --scale 2 --duration 4
|
||||
|
||||
#![forbid(unsafe_code)]
|
||||
|
||||
mod gfx;
|
||||
mod kit;
|
||||
mod scenes;
|
||||
|
||||
use rune::{AppSpec, Cx, El};
|
||||
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Debug, Default)]
|
||||
pub enum Scene {
|
||||
#[default]
|
||||
Word,
|
||||
Card,
|
||||
Deploy,
|
||||
Glass,
|
||||
Fire,
|
||||
Pricing,
|
||||
Ask,
|
||||
Shock,
|
||||
Keys,
|
||||
Tabs,
|
||||
Type,
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct State {
|
||||
pub scene: Scene,
|
||||
/// Seconds since the scene started (Rune's virtual clock when headless).
|
||||
pub t: f64,
|
||||
}
|
||||
|
||||
fn view(s: &State, cx: &mut Cx<State>) -> El {
|
||||
match s.scene {
|
||||
Scene::Word => scenes::word::view(s, cx, false),
|
||||
Scene::Card => scenes::word::view(s, cx, true),
|
||||
Scene::Deploy => scenes::deploy::view(s, cx),
|
||||
Scene::Glass => scenes::glass::view(s, cx),
|
||||
Scene::Fire => scenes::fire::view(s, cx),
|
||||
Scene::Pricing => scenes::pricing::view(s, cx),
|
||||
Scene::Ask => scenes::ask::view(s, cx),
|
||||
Scene::Shock => scenes::shock::view(s, cx),
|
||||
Scene::Keys => scenes::keys::view(s, cx),
|
||||
Scene::Tabs => scenes::tabs::view(s, cx),
|
||||
Scene::Type => scenes::type_::view(s, cx),
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let app = rune::App::new(AppSpec::<State> {
|
||||
scenes: &[
|
||||
("word", |s| s.scene = Scene::Word),
|
||||
("card", |s| s.scene = Scene::Card),
|
||||
("deploy", |s| s.scene = Scene::Deploy),
|
||||
("glass", |s| s.scene = Scene::Glass),
|
||||
("fire", |s| s.scene = Scene::Fire),
|
||||
("pricing", |s| s.scene = Scene::Pricing),
|
||||
("ask", |s| s.scene = Scene::Ask),
|
||||
("shock", |s| s.scene = Scene::Shock),
|
||||
("keys", |s| s.scene = Scene::Keys),
|
||||
("tabs", |s| s.scene = Scene::Tabs),
|
||||
("type", |s| s.scene = Scene::Type),
|
||||
],
|
||||
fonts: &[
|
||||
include_bytes!("../../../crates/rune/assets/Inter-Regular.ttf"),
|
||||
include_bytes!("../../../crates/rune/assets/Inter-Medium.ttf"),
|
||||
include_bytes!("../../../crates/rune/assets/Inter-SemiBold.ttf"),
|
||||
include_bytes!("../../../themes/opencode/assets/fonts/IBMPlexMono-Medium.ttf"),
|
||||
],
|
||||
families: ("Inter", "IBM Plex Mono"),
|
||||
poll: Some(|s, t, _| {
|
||||
s.t = t;
|
||||
true
|
||||
}),
|
||||
..AppSpec::new("Showreel", (960.0, 540.0), State::default, view)
|
||||
})
|
||||
.compositor(gfx::Gfx::default());
|
||||
app.run();
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
//! An assistant's composer wrapped in a flowing aura. A prompt types itself, send flares the glow,
|
||||
//! the composer drops to the bottom and the reply streams in under a shimmer.
|
||||
|
||||
use rune::{Cx, El, col, el, row, spacer};
|
||||
|
||||
use crate::gfx::{GLOW, PULSE, SHIMMER};
|
||||
use crate::kit::*;
|
||||
use crate::State;
|
||||
|
||||
const PROMPT: &str = "make the settings page feel alive";
|
||||
const TYPE_FROM: f64 = 0.3;
|
||||
const TYPE_RATE: f64 = 30.0;
|
||||
const SEND: f64 = 1.55;
|
||||
|
||||
fn chip(s: &str, a: f32) -> El {
|
||||
row().h(32.0).px(14.0).radius(16.0).center().fill(ca(0xffffff, 0.05 * a)).border(1.0, ca(0xffffff, 0.08 * a)).child(ta(s, 13.0, 500.0, MUTED, a))
|
||||
}
|
||||
|
||||
pub fn view(s: &State, _: &mut Cx<State>) -> El {
|
||||
let t_ = s.t;
|
||||
let n = (((t_ - TYPE_FROM) * TYPE_RATE).max(0.0) as usize).min(PROMPT.len());
|
||||
let sent = t_ >= SEND;
|
||||
let press = pressed(t_, SEND);
|
||||
let flare = if sent { 1.6 * (-(t_ - SEND) as f32 * 2.2).exp() } else { 0.0 };
|
||||
let drop = track(t_, 0.0, &[(SEND + 0.08, 1.0, sp(0.6, 0.12))]);
|
||||
let (cw, ch) = (640.0, 128.0);
|
||||
let cx0 = (W - cw) / 2.0;
|
||||
let cy0 = 214.0 + (382.0 - 214.0) * drop;
|
||||
|
||||
let caret_on = ((t_ * 2.0) as i64) % 2 == 0 || n < PROMPT.len();
|
||||
let typed = if sent { String::new() } else { PROMPT[..n].to_string() };
|
||||
let field = row().gap(1.0).center_y()
|
||||
.child(if typed.is_empty() && !sent && n == 0 { t("Ask anything…", 17.0, 400.0, FAINT) } else { t(typed, 17.0, 400.0, TEXT) })
|
||||
.child(el().w(2.0).h(22.0).radius(1.0).fill(ca(0x9fd4ff, if caret_on { 1.0 } else { 0.0 })));
|
||||
|
||||
let send = el().size(36.0, 36.0).radius(18.0).scale(1.0 - 0.12 * press).fill(if n > 0 { c(0xf4f6fb) } else { ca(0xffffff, 0.15) }).center().child(t("↑", 18.0, 600.0, 0x0b0b0d));
|
||||
let composer = col().key("composer").absolute(cx0, cy0).size(cw, ch).padding(20.0).radius(24.0).fill(c(0x131317)).border(1.0, ca(0xffffff, 0.1))
|
||||
.child(field)
|
||||
.child(spacer())
|
||||
.child(
|
||||
row().w_full().center_y().gap(8.0)
|
||||
.child(row().h(30.0).px(12.0).radius(15.0).center().gap(6.0).fill(ca(0xffffff, 0.06)).child(dot(0x54b3fd, 6.0)).child(t("Build", 12.5, 500.0, 0xc9c9d0)))
|
||||
.child(row().h(30.0).px(12.0).radius(15.0).center().fill(ca(0xffffff, 0.06)).child(t("opus", 12.5, 500.0, 0xc9c9d0)))
|
||||
.child(spacer())
|
||||
.child(send),
|
||||
);
|
||||
|
||||
let greet = 1.0 - ease(t_, SEND, 0.25);
|
||||
let mut root = el().w(W).h(H).fill(c(0x09090b))
|
||||
.child(col().key("greet").absolute(0.0, 150.0 - 20.0 * (1.0 - greet)).w(W).items_center().child(ta("What should we build?", 30.0, 600.0, TEXT, greet)))
|
||||
.child(
|
||||
row().key("chips").absolute(0.0, 214.0 + ch + 22.0).w(W).justify_center().gap(10.0)
|
||||
.child(chip("A springy toggle", greet))
|
||||
.child(chip("Liquid metal button", greet))
|
||||
.child(chip("Glass sidebar", greet)),
|
||||
)
|
||||
.child(fx(GLOW, [2.0, 3.0, 1.0 + flare, 22.0]).key("aura").absolute(cx0, cy0).size(cw, ch).radius(24.0).effect_bleed(70.0))
|
||||
.child(composer);
|
||||
|
||||
if sent {
|
||||
let k = track(t_, 0.0, &[(SEND + 0.12, 1.0, sp(0.45, 0.25))]);
|
||||
let a = k.clamp(0.0, 1.0);
|
||||
let bubble = row().h(42.0).px(16.0).radius(16.0).center().fill(ca(0x1f2633, a)).child(ta(PROMPT, 15.0, 400.0, 0xe6ecf7, a));
|
||||
root = root.child(row().key("bubble").absolute(0.0, 58.0 + 14.0 * (1.0 - k)).w(W - 160.0).justify_end().child(bubble));
|
||||
let r = ease(t_, SEND + 0.4, 0.3);
|
||||
let mut reply = col().key("reply").absolute(160.0, 132.0).w(640.0).gap(12.0)
|
||||
.child(row().gap(10.0).center_y()
|
||||
.child(el().size(10.0 * r, 10.0 * r).child(fx(PULSE, [1.0, 13.0, 1.2, 10.0]).absolute(0.0, 0.0).size(10.0, 10.0).radius(5.0).effect_bleed(16.0)).child(dot(0x54b3fd, 10.0).absolute(0.0, 0.0)))
|
||||
.child(ta("Thinking", 14.0, 500.0, MUTED, r)));
|
||||
for (i, w) in [600.0, 540.0, 580.0, 360.0].iter().enumerate() {
|
||||
let k2 = ease(t_, SEND + 0.55 + i as f64 * 0.12, 0.25);
|
||||
reply = reply.child(
|
||||
el().w(*w * (0.6 + 0.4 * k2)).h(12.0).radius(6.0).fill(ca(0xffffff, 0.07 * k2))
|
||||
.child(fx(SHIMMER, [0.35 * k2, 1.3, 60.0, 0.0]).absolute(0.0, 0.0).w(*w * (0.6 + 0.4 * k2)).h(12.0).radius(6.0)),
|
||||
);
|
||||
}
|
||||
root = root.child(reply);
|
||||
}
|
||||
root.child(pointer_at(t_, [760.0, 470.0], &[(0.9, cx0 + cw - 38.0, 214.0 + ch - 38.0), (SEND + 0.25, 860.0, 520.0)], &[SEND]))
|
||||
}
|
||||
@@ -0,0 +1,168 @@
|
||||
//! A deploy dashboard whose Deploy button is liquid metal. The pointer comes in, presses it, a new
|
||||
//! deployment springs into the list, builds and goes live.
|
||||
|
||||
use rune::{Cx, El, Transition, col, el, row, spacer};
|
||||
|
||||
use crate::gfx::{CHROME, GLOW, PULSE, SHIMMER, SPARKLES};
|
||||
use crate::kit::*;
|
||||
use crate::State;
|
||||
|
||||
/// The toolbar's Deploy, then the confirm sheet's.
|
||||
const TAP: f64 = 0.7;
|
||||
const CONFIRM: f64 = 1.6;
|
||||
const DISMISS: f64 = 2.3;
|
||||
const INSERT: f64 = 2.4;
|
||||
const READY: f64 = 3.4;
|
||||
|
||||
const ROWS: [(&str, &str, &str, &str, u32); 5] = [
|
||||
("overlay: motion started while hidden plays on show", "f6d096b", "38s", "12m", 0x7c5cff),
|
||||
("text: a span keeps the paragraph's leading ratio", "4112cac", "41s", "1h", 0xff7a1a),
|
||||
("text: snap the pen to 1/256 px before flooring", "bac9e90", "40s", "2h", 0x34d399),
|
||||
("rune-mermaid: hover settings keep their style", "c83aa06", "44s", "3h", 0x54b3fd),
|
||||
("fx: frosted glass reads a blurred backdrop", "9e1d4b2", "39s", "5h", 0xff5ca8),
|
||||
];
|
||||
|
||||
fn status(label: &str, color: u32, pulse: Option<u32>) -> El {
|
||||
let mut d = el().size(8.0, 8.0);
|
||||
if let Some(p) = pulse {
|
||||
d = d.child(fx(PULSE, [1.0, p as f32, 1.2, 9.0]).absolute(0.0, 0.0).size(8.0, 8.0).radius(4.0).effect_bleed(14.0));
|
||||
}
|
||||
d = d.child(dot(color, 8.0).absolute(0.0, 0.0));
|
||||
row().w(118.0).gap(9.0).center_y().child(d).child(t(label, 13.0, 500.0, TEXT))
|
||||
}
|
||||
|
||||
fn list_row(msg: &str, sha: &str, dur: &str, ago: &str, who: u32, st: El, extra: Option<El>) -> El {
|
||||
let mut info = col().gap(5.0).child(t(msg, 13.5, 500.0, TEXT)).child(
|
||||
row().gap(8.0).center_y().child(
|
||||
el().px(6.0).py(1.0).radius(5.0).fill(ca(0xffffff, 0.06)).child(mono("dev", 11.0, MUTED)),
|
||||
)
|
||||
.child(mono(sha, 11.0, FAINT)),
|
||||
);
|
||||
if let Some(e) = extra {
|
||||
info = info.child(e);
|
||||
}
|
||||
row().key(format!("row-{sha}"))
|
||||
.w_full()
|
||||
.h(62.0)
|
||||
.px(20.0)
|
||||
.center_y()
|
||||
.child(st)
|
||||
.child(info.grow(1.0))
|
||||
.child(t(dur, 13.0, 400.0, MUTED).w(60.0))
|
||||
.child(t(ago, 13.0, 400.0, MUTED).w(54.0))
|
||||
.child(avatar("", who, 22.0))
|
||||
}
|
||||
|
||||
pub fn view(s: &State, _: &mut Cx<State>) -> El {
|
||||
let t_ = s.t;
|
||||
let hover = track(t_, 0.0, &[(0.5, 1.0, sp(0.35, 0.3))]);
|
||||
let press = pressed(t_, TAP);
|
||||
let scale = 1.0 + 0.05 * hover - 0.08 * press;
|
||||
let flow = 1.0 + 1.2 * (if t_ > TAP { (-(t_ - TAP) as f32 * 1.5).exp() } else { 0.0 });
|
||||
|
||||
// The Deploy button: liquid metal under the label, a soft glow while hovered.
|
||||
let button = el().key("deploy")
|
||||
.size(132.0, 40.0)
|
||||
.radius(20.0)
|
||||
.scale(scale)
|
||||
.child(fx(GLOW, [0.0, 0.0, 0.22 * hover, 12.0]).absolute(0.0, 0.0).size(132.0, 40.0).radius(20.0).effect_bleed(40.0))
|
||||
.child(fx(CHROME, [5.0, 0.0, flow, 0.0]).absolute(0.0, 0.0).size(132.0, 40.0).radius(20.0))
|
||||
.child(row().absolute(0.0, 0.0).size(132.0, 40.0).center().child(t("Deploy", 15.0, 600.0, 0x0e0f12)))
|
||||
;
|
||||
|
||||
let logo = el().size(26.0, 26.0).radius(7.0).linear_gradient(2.3, [(0.0, c(0x54b3fd)), (1.0, c(0x3d6bff))]);
|
||||
let top = row().w_full()
|
||||
.h(64.0)
|
||||
.px(24.0)
|
||||
.center_y()
|
||||
.gap(12.0)
|
||||
.child(logo)
|
||||
.child(t("anomaly", 14.0, 500.0, MUTED))
|
||||
.child(t("/", 14.0, 400.0, FAINT))
|
||||
.child(t("rune", 14.0, 600.0, TEXT))
|
||||
.child(
|
||||
row().ml(6.0).px(10.0).py(4.0).gap(6.0).radius(10.0).center_y().fill(ca(0x34d399, 0.12))
|
||||
.child(dot(0x34d399, 6.0))
|
||||
.child(t("Production", 12.0, 500.0, 0x6ee7b7)),
|
||||
)
|
||||
.child(spacer())
|
||||
.child(row().child(avatar("", 0xff7a1a, 26.0).border(2.0, c(BG))).child(avatar("", 0x7c5cff, 26.0).border(2.0, c(BG)).ml(-7.0)).child(avatar("", 0x34d399, 26.0).border(2.0, c(BG)).ml(-7.0)))
|
||||
.child(el().w(10.0))
|
||||
.child(button);
|
||||
|
||||
let tabs = ["Overview", "Deployments", "Analytics", "Logs", "Storage", "Settings"];
|
||||
let mut tab_row = row().w_full().h(42.0).px(24.0).gap(26.0).center_y();
|
||||
for (i, name) in tabs.iter().enumerate() {
|
||||
let on = i == 1;
|
||||
tab_row = tab_row.child(
|
||||
col().h(42.0).justify_center().child(t(*name, 13.5, if on { 600.0 } else { 450.0 }, if on { TEXT } else { MUTED })).child(
|
||||
el().absolute(0.0, 40.0).h(2.0).w_full().fill(if on { c(TEXT) } else { ca(0, 0.0) }),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// The new deployment springs in at the top of the list once Deploy is pressed.
|
||||
let grow = track(t_, 0.0, &[(INSERT, 1.0, sp(0.5, 0.18))]);
|
||||
let ready = t_ >= READY;
|
||||
let mut list = col().w_full().radius(14.0).fill(c(PANEL)).border(1.0, hair()).clip_rounded(14.0);
|
||||
if grow > 0.001 {
|
||||
let progress = ease(t_, INSERT + 0.1, READY - INSERT - 0.15);
|
||||
let fade = 1.0 - ease(t_, READY, 0.3);
|
||||
let bar = el().mt(4.0).w(260.0).h(3.0).radius(2.0).fill(ca(0xffffff, 0.08 * fade)).child(
|
||||
el().absolute(0.0, 0.0).h(3.0).w(260.0 * progress).radius(2.0).fill(ca(0xffb547, fade))
|
||||
.child(fx(SHIMMER, [0.5 * fade, 0.9, 40.0, 0.0]).absolute(0.0, 0.0).h(3.0).w(260.0 * progress).radius(2.0)),
|
||||
);
|
||||
let st = if ready { status("Ready", 0x34d399, Some(4)) } else { status("Building", 0xffb547, Some(5)) };
|
||||
let fresh = list_row("README: a 30 second showcase, cut from real renders", "ba5b054", if ready { "1m 39s" } else { "…" }, "now", 0x54b3fd, st, Some(bar));
|
||||
list = list.child(
|
||||
el().key("fresh").w_full().h(62.0 * grow + 9.0 * grow).clip_rounded(0.0).child(
|
||||
el().absolute(0.0, -62.0 * (1.0 - grow)).w_full().fill(ca(0xffffff, 0.025 + 0.03 * (1.0 - ease(t_, READY, 0.8)))).child(fresh),
|
||||
),
|
||||
);
|
||||
}
|
||||
for (i, (msg, sha, dur, ago, who)) in ROWS.iter().enumerate() {
|
||||
if i > 0 || grow > 0.001 {
|
||||
list = list.child(el().key(format!("sep-{i}")).w_full().h(1.0).fill(hair()));
|
||||
}
|
||||
list = list.child(list_row(msg, sha, dur, ago, *who, status("Ready", 0x34d399, None), None));
|
||||
}
|
||||
|
||||
let header = row().w_full().items_end().child(
|
||||
col().gap(6.0).child(t("Deployments", 26.0, 600.0, TEXT)).child(t("Every push to dev ships to production.", 13.5, 400.0, MUTED)),
|
||||
)
|
||||
.child(spacer())
|
||||
.child(row().w(230.0).h(36.0).px(12.0).radius(10.0).center_y().fill(c(PANEL)).border(1.0, hair()).child(t("Search deployments…", 13.0, 400.0, FAINT)))
|
||||
.child(el().w(10.0))
|
||||
.child(row().h(36.0).px(14.0).radius(10.0).center_y().fill(c(PANEL)).border(1.0, hair()).child(t("All environments", 13.0, 500.0, MUTED)));
|
||||
|
||||
let page = col().w(960.0).h(540.0).fill(c(BG))
|
||||
.child(top)
|
||||
.child(tab_row)
|
||||
.child(el().w_full().h(1.0).fill(hair()))
|
||||
.child(col().w_full().px(32.0).pt(26.0).gap(20.0).child(header).child(list));
|
||||
|
||||
// The confirm sheet: a big liquid-metal button, centred, over the dimmed page.
|
||||
let dim = ease(t_, TAP + 0.05, 0.3) * (1.0 - ease(t_, DISMISS, 0.3));
|
||||
let mut root = el().w(960.0).h(540.0)
|
||||
.child(page.absolute(0.0, 0.0))
|
||||
.child(el().key("dim").absolute(0.0, 0.0).size(960.0, 540.0).backdrop_blur(10.0 * dim).fill(ca(0x000000, 0.68 * dim)));
|
||||
if t_ >= TAP + 0.05 && t_ < DISMISS {
|
||||
let press2 = pressed(t_, CONFIRM);
|
||||
let flow2 = 1.0 + 1.8 * (if t_ > CONFIRM { (-(t_ - CONFIRM) as f32 * 1.6).exp() } else { 0.0 });
|
||||
let (bw, bh) = (372.0, 58.0);
|
||||
let big = el().size(bw, bh).radius(bh / 2.0).scale(1.0 - 0.06 * press2)
|
||||
.child(fx(CHROME, [5.0, 0.0, flow2, 0.0]).absolute(0.0, 0.0).size(bw, bh).radius(bh / 2.0))
|
||||
.child(row().absolute(0.0, 0.0).size(bw, bh).center().child(t("Deploy", 18.0, 600.0, 0x0e0f12)))
|
||||
.child(fx(SPARKLES, [CONFIRM as f32 + 0.06, 14.0, 11.0, 0.0]).absolute(0.0, 0.0).size(bw, bh).radius(bh / 2.0).effect_bleed(60.0));
|
||||
let sheet = col().key("sheet").absolute(264.0, 150.0).w(432.0).padding(30.0).gap(8.0).radius(24.0)
|
||||
.fill(c(0x151518)).border(1.0, ca(0xffffff, 0.1)).shadow(24.0, 60.0, ca(0x000000, 0.6))
|
||||
.transition(Transition::scale(0.9).combined(Transition::opacity()))
|
||||
.child(row().gap(10.0).center_y().child(dot(0x34d399, 8.0)).child(t("Production", 12.5, 600.0, 0x6ee7b7)))
|
||||
.child(t("Deploy rune to production?", 21.0, 600.0, TEXT))
|
||||
.child(row().gap(8.0).center_y().child(mono("dev", 12.0, MUTED)).child(t("·", 12.0, 400.0, FAINT)).child(mono("ba5b054", 12.0, MUTED)).child(t("·", 12.0, 400.0, FAINT)).child(t("README: a 30 second showcase", 13.0, 400.0, MUTED)))
|
||||
.child(el().h(18.0))
|
||||
.child(big);
|
||||
root = root.child(sheet);
|
||||
}
|
||||
root.child(pointer_at(t_, [560.0, 420.0], &[(0.12, 861.0, 33.0), (1.0, 500.0, 333.0)], &[TAP, CONFIRM]))
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
//! Friday, 4:58 PM. A release card with a Ship it button; pressing it sets the card on fire
|
||||
//! (simulated flames and embers off its top edge, heat haze above).
|
||||
|
||||
use rune::{Cx, El, col, el, row, spacer};
|
||||
|
||||
use crate::gfx::{FIRE, GLOW, HAZE};
|
||||
use crate::kit::*;
|
||||
use crate::State;
|
||||
|
||||
const TAP: f64 = 0.95;
|
||||
|
||||
fn channel(name: &str, on: bool) -> El {
|
||||
row().w_full().h(30.0).px(12.0).radius(8.0).center_y().gap(8.0)
|
||||
.fill(if on { ca(0xffffff, 0.07) } else { ca(0, 0.0) })
|
||||
.child(t("#", 14.0, 500.0, FAINT))
|
||||
.child(t(name, 13.5, if on { 600.0 } else { 450.0 }, if on { TEXT } else { MUTED }))
|
||||
}
|
||||
|
||||
fn msg(who: u32, name: &str, time: &str, body: &str) -> El {
|
||||
row().w_full().gap(12.0)
|
||||
.child(avatar("", who, 30.0))
|
||||
.child(col().gap(4.0).child(row().gap(8.0).center_y().child(t(name, 13.5, 600.0, TEXT)).child(t(time, 12.0, 400.0, FAINT))).child(t(body, 13.5, 400.0, 0xc9c9d0)))
|
||||
}
|
||||
|
||||
pub fn view(s: &State, _: &mut Cx<State>) -> El {
|
||||
let t_ = s.t;
|
||||
let press = pressed(t_, TAP);
|
||||
let blaze = ease(t_, TAP, 0.5);
|
||||
let flame = 0.18 + 1.25 * blaze;
|
||||
|
||||
let mut side = col().w(220.0).h(H).px(12.0).pt(22.0).gap(2.0).fill(c(0x101013)).border(1.0, hair());
|
||||
side = side.child(row().px(12.0).pb(16.0).gap(10.0).center_y().child(el().size(22.0, 22.0).radius(6.0).fill(c(0xff7a1a))).child(t("Anomaly", 14.0, 600.0, TEXT)));
|
||||
for (i, ch) in ["general", "releases", "incidents", "design", "random"].iter().enumerate() {
|
||||
side = side.child(channel(ch, i == 1));
|
||||
}
|
||||
|
||||
let cx0 = 220.0 + (W - 220.0 - 460.0) / 2.0;
|
||||
let cy0 = 250.0;
|
||||
let card = col().absolute(cx0, cy0).w(460.0).h(220.0).padding(24.0).gap(10.0).radius(18.0).fill(c(0x1c1b1f)).border(1.0, ca(0xffffff, 0.09))
|
||||
.shadow(18.0, 40.0, ca(0x000000, 0.5))
|
||||
.child(row().gap(10.0).center_y().child(t("Release", 12.0, 600.0, 0xff9a5a)).child(spacer()).child(mono("v2.0.0", 12.0, MUTED)))
|
||||
.child(t("Ship v2.0 to production", 22.0, 600.0, TEXT))
|
||||
.child(t("Friday · 4:58 PM · 214 files changed", 13.5, 400.0, MUTED))
|
||||
.child(spacer())
|
||||
.child(
|
||||
row().w_full().gap(10.0)
|
||||
.child(spacer())
|
||||
.child(row().h(38.0).px(18.0).radius(10.0).center().fill(ca(0xffffff, 0.06)).child(t("Not today", 13.5, 500.0, MUTED)))
|
||||
.child(
|
||||
row().h(38.0).px(20.0).radius(10.0).center().scale(1.0 - 0.07 * press).fill(c(0xff5a1f))
|
||||
.child(t(if t_ >= TAP { "Shipping…" } else { "Ship it" }, 13.5, 600.0, 0xffffff)),
|
||||
),
|
||||
);
|
||||
|
||||
let thread = col().absolute(220.0 + 40.0, 40.0).w(W - 300.0).gap(18.0)
|
||||
.child(msg(0x7c5cff, "mira", "4:51 PM", "all green on dev, release notes are in"))
|
||||
.child(msg(0x34d399, "kai", "4:55 PM", "it's friday. it's 4:55. are we sure"))
|
||||
.child(msg(0xff7a1a, "ode", "4:57 PM", "rune renders it at 120 Hz, what could go wrong"));
|
||||
|
||||
el().w(W).h(H).fill(c(BG))
|
||||
.child(side.absolute(0.0, 0.0))
|
||||
.child(thread)
|
||||
.child(fx(GLOW, [0.0, 8.0, 0.25 + 0.9 * blaze, 30.0]).absolute(cx0, cy0).size(460.0, 220.0).radius(18.0).effect_bleed(80.0))
|
||||
.child(fx(FIRE, [64.0 + 70.0 * blaze, flame, 0.0, 0.6]).absolute(cx0, cy0).size(460.0, 220.0).radius(18.0).effect_bleed(200.0))
|
||||
.child(card)
|
||||
.child(fx(HAZE, [150.0, 1.6 * blaze, 0.0, 0.0]).effect_backdrop(true).absolute(cx0 - 10.0, cy0 - 170.0).size(480.0, 180.0))
|
||||
.child(pointer_at(t_, [700.0, 520.0], &[(0.25, cx0 + 400.0, cy0 + 182.0)], &[TAP]))
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
//! Now playing: the cover is a live mesh gradient under a huge title and a moving waveform. A
|
||||
//! slab of fluted glass slides in over all of it and the queue settles onto the glass.
|
||||
|
||||
use rune::{Cx, El, col, el, row, spacer};
|
||||
|
||||
use crate::gfx::{FLUTED, MESH};
|
||||
use crate::kit::*;
|
||||
use crate::State;
|
||||
|
||||
const QUEUE: [(&str, &str, &str, u32); 5] = [
|
||||
("Low Light", "Kaito Hayes", "3:41", 7),
|
||||
("Glass Hours", "Mira Sol", "4:02", 1),
|
||||
("Afterimage", "Sunday Static", "2:57", 5),
|
||||
("Paper Moons", "Kaito Hayes", "3:18", 4),
|
||||
("Slow Signal", "Ode Park", "5:06", 6),
|
||||
];
|
||||
|
||||
pub fn view(s: &State, _: &mut Cx<State>) -> El {
|
||||
let t_ = s.t;
|
||||
let mut root = el().w(W).h(H).fill(c(0x120a1e));
|
||||
root = root.child(fx(MESH, [7.0, 0.55, 3.0, 0.22]).absolute(0.0, 0.0).size(W, H));
|
||||
|
||||
// A waveform across the whole width, so the glass has something moving behind it.
|
||||
let mut wave = row().absolute(40.0, 400.0).w(W - 40.0).h(80.0).gap(4.0).items_end();
|
||||
for i in 0..112 {
|
||||
let x = i as f32;
|
||||
let h = 10.0 + 34.0 * (0.5 + 0.5 * (x * 0.37 + t_ as f32 * 5.1).sin()) * (0.55 + 0.45 * (x * 0.11 - t_ as f32 * 2.3).sin().abs());
|
||||
wave = wave.child(el().w(4.0).h(h).radius(2.0).fill(ca(0xffffff, if x < 44.0 { 0.85 } else { 0.5 })));
|
||||
}
|
||||
root = root.child(wave);
|
||||
|
||||
let title = col().absolute(48.0, 120.0)
|
||||
.gap(6.0)
|
||||
.child(ta("NOW PLAYING", 12.0, 600.0, 0xffffff, 0.75))
|
||||
.child(t("Night Drive", 128.0, 600.0, 0xffffff))
|
||||
.child(ta("Kaito Hayes · Low Light Sessions", 20.0, 500.0, 0xffffff, 0.8));
|
||||
root = root.child(title);
|
||||
|
||||
let progress = 0.38 + 0.02 * t_ as f32;
|
||||
root = root.child(
|
||||
row().absolute(48.0, 496.0).w(470.0).gap(12.0).center_y()
|
||||
.child(mono("1:42", 12.0, 0xffffff))
|
||||
.child(el().w(380.0).h(4.0).radius(2.0).fill(ca(0xffffff, 0.25)).child(el().absolute(0.0, 0.0).h(4.0).w(380.0 * progress).radius(2.0).fill(c(0xffffff))))
|
||||
.child(mono("3:58", 12.0, 0xffffff)),
|
||||
);
|
||||
|
||||
// The slab slides in from the right edge on a spring.
|
||||
let x = track(t_, W + 10.0, &[(0.35, 548.0, sp(0.95, 0.12))]);
|
||||
let gw = W - 548.0;
|
||||
let mut queue = col().absolute(x, 0.0).w(gw).h(H).pt(54.0).px(34.0).gap(4.0);
|
||||
let head = ease(t_, 0.95, 0.4);
|
||||
queue = queue.child(
|
||||
row().w_full().mb(14.0).offset(0.0, 10.0 * (1.0 - head))
|
||||
.child(ta("Up next", 22.0, 600.0, 0xffffff, head))
|
||||
.child(spacer())
|
||||
.child(ta("Shuffle", 13.0, 500.0, 0xffffff, 0.7 * head)),
|
||||
);
|
||||
for (i, (name, artist, dur, pal)) in QUEUE.iter().enumerate() {
|
||||
let k = track(t_, 0.0, &[(1.05 + i as f64 * 0.07, 1.0, sp(0.5, 0.2))]);
|
||||
queue = queue.child(
|
||||
row().w_full().h(68.0).gap(14.0).center_y().offset(24.0 * (1.0 - k), 0.0)
|
||||
.child(fx(MESH, [*pal as f32, 0.4, i as f32 + 5.0, 0.0]).size(48.0 * k.clamp(0.0, 1.0), 48.0 * k.clamp(0.0, 1.0)).radius(10.0))
|
||||
.child(col().gap(4.0).grow(1.0).child(ta(*name, 15.0, 600.0, 0xffffff, k)).child(ta(*artist, 13.0, 400.0, 0xffffff, 0.7 * k)))
|
||||
.child(mono_a(*dur, 12.0, 0xffffff, 0.8 * k)),
|
||||
);
|
||||
}
|
||||
root.child(fx(FLUTED, [18.0, 16.0, 0.12, 0.3]).effect_backdrop(true).absolute(x, 0.0).size(gw + 10.0, H))
|
||||
.child(el().absolute(x, 0.0).w(1.0).h(H).fill(ca(0xffffff, 0.35)))
|
||||
.child(queue)
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
//! A pad controller playing a boom-bap pattern at 90 BPM: glossy plastic keys, two liquid-metal
|
||||
//! keys, each press springing down and lighting up.
|
||||
|
||||
use rune::{Cx, El, col, el, row};
|
||||
|
||||
use crate::gfx::{CHROME, GLOW, PLASTIC};
|
||||
use crate::kit::*;
|
||||
use crate::State;
|
||||
|
||||
const EIGHTH: f64 = 60.0 / 90.0 / 2.0;
|
||||
/// (colour index, label) per key; colour 99 is liquid metal.
|
||||
const KEYS: [(u32, &str); 16] = [
|
||||
(10, "A"), (9, "B"), (9, "C"), (9, "D"), (10, "E"), (12, "F"), (99, "G"), (10, "H"),
|
||||
(11, "KICK"), (10, "I"), (9, "J"), (10, "K"), (12, "SNR"), (9, "L"), (99, "M"), (11, "FX"),
|
||||
];
|
||||
const LIGHT: [u32; 16] = [0, 9, 9, 9, 0, 12, 0, 0, 11, 0, 9, 0, 12, 9, 0, 11];
|
||||
|
||||
fn hits(n: i64) -> Vec<usize> {
|
||||
let mut v = Vec::new();
|
||||
let m = n.rem_euclid(16);
|
||||
if [0, 3, 5, 8, 11, 13].contains(&m) {
|
||||
v.push(8);
|
||||
}
|
||||
if m % 4 == 2 {
|
||||
v.push(12);
|
||||
}
|
||||
v.push(if m % 2 == 0 { 2 } else { 1 });
|
||||
if m == 7 || m == 15 {
|
||||
v.push(6);
|
||||
}
|
||||
if m == 14 {
|
||||
v.push(14);
|
||||
}
|
||||
if m == 10 {
|
||||
v.push(5);
|
||||
}
|
||||
if m == 6 {
|
||||
v.push(13);
|
||||
}
|
||||
v
|
||||
}
|
||||
|
||||
fn press_of(t: f64, key: usize) -> f32 {
|
||||
let now = (t / EIGHTH).floor() as i64;
|
||||
let mut p = 0.0f32;
|
||||
for n in (now - 3)..=now {
|
||||
if n < 0 {
|
||||
continue;
|
||||
}
|
||||
if hits(n).contains(&key) {
|
||||
p = p.max(pressed(t, n as f64 * EIGHTH));
|
||||
}
|
||||
}
|
||||
p
|
||||
}
|
||||
|
||||
pub fn view(s: &State, _: &mut Cx<State>) -> El {
|
||||
let t_ = s.t;
|
||||
let (bw, bh) = (864.0, 384.0);
|
||||
let (bx, by) = ((W - bw) / 2.0, (H - bh) / 2.0 + 4.0);
|
||||
let key = 86.0;
|
||||
let gap = 12.0;
|
||||
let kx0 = bx + (bw - 8.0 * key - 7.0 * gap) / 2.0;
|
||||
let ky0 = by + 152.0;
|
||||
|
||||
let bar = 12 + (t_ / (EIGHTH * 8.0)) as i64;
|
||||
let display = col().absolute(kx0, by + 38.0).w(230.0).h(70.0).px(16.0).justify_center().gap(4.0).radius(12.0).fill(c(0x050506)).border(1.0, ca(0xffffff, 0.05))
|
||||
.child(row().gap(8.0).items_end().child(mono("90", 30.0, 0x5df2a8)).child(mono("BPM", 13.0, 0x5df2a8).mb(5.0)))
|
||||
.child(mono(format!("pattern A · bar {bar}"), 11.0, 0x3c9b6c));
|
||||
|
||||
let mut root = el().w(W).h(H).linear_gradient(1.57, [(0.0, c(0x17161a)), (1.0, c(0x0a0a0b))])
|
||||
.child(el().absolute(bx, by).size(bw, bh).radius(30.0).linear_gradient(1.57, [(0.0, c(0x232227)), (1.0, c(0x161619))]).border(1.0, ca(0xffffff, 0.08)).shadow(30.0, 60.0, ca(0x000000, 0.6)))
|
||||
.child(display)
|
||||
.child(col().absolute(bx + bw - (kx0 - bx) - 120.0, by + 44.0).w(120.0).items_end().gap(8.0).child(t("PAD-16", 13.0, 600.0, 0x8a8a93)).child(row().gap(6.0).center_y().child(dot(0xff5a4d, 7.0)).child(t("REC", 12.0, 600.0, 0xff5a4d))));
|
||||
|
||||
// Knobs that turn slowly.
|
||||
for i in 0..4 {
|
||||
let kx = kx0 + 280.0 + i as f32 * 70.0;
|
||||
let ky = by + 46.0;
|
||||
let ang = (t_ as f32 * 0.9 + i as f32 * 1.3).sin() * 2.2 - std::f32::consts::FRAC_PI_2;
|
||||
let (dx, dy) = (ang.cos() * 16.0, ang.sin() * 16.0);
|
||||
root = root.child(fx(PLASTIC, [10.0, 0.35, 0.7, 10.0]).absolute(kx, ky).size(54.0, 54.0).radius(27.0))
|
||||
.child(dot(0xf1ece1, 6.0).absolute(kx + 27.0 + dx - 3.0, ky + 27.0 + dy - 3.0));
|
||||
}
|
||||
|
||||
for (i, (col_, label)) in KEYS.iter().enumerate() {
|
||||
let (cx, cy) = ((i % 8) as f32, (i / 8) as f32);
|
||||
let p = press_of(t_, i);
|
||||
let x = kx0 + cx * (key + gap);
|
||||
let y = ky0 + cy * (key + gap) + 3.0 * p;
|
||||
let size = key * (1.0 - 0.04 * p);
|
||||
let off = (key - size) / 2.0;
|
||||
let dark = matches!(*col_, 10 | 99);
|
||||
let face = if *col_ == 99 {
|
||||
fx(CHROME, [0.0, 0.0, 1.4, 1.0])
|
||||
} else {
|
||||
fx(PLASTIC, [*col_ as f32, 0.22, 0.35, 7.0])
|
||||
};
|
||||
root = root
|
||||
.child(el().absolute(x, ky0 + cy * (key + gap) + 5.0).size(key, key).radius(14.0).fill(ca(0x000000, 0.45)))
|
||||
.child(fx(GLOW, [0.0, LIGHT[i] as f32, 1.4 * p, 16.0]).absolute(x + off, y + off).size(size, size).radius(14.0).effect_bleed(50.0))
|
||||
.child(face.absolute(x + off, y + off).size(size, size).radius(14.0))
|
||||
.child(el().absolute(x + off + 10.0, y + off + 8.0).child(ta(*label, 11.5, 600.0, if dark && *col_ != 99 { 0xb9b9c2 } else { 0x2a2a2e }, 0.85)));
|
||||
}
|
||||
root
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
pub mod ask;
|
||||
pub mod deploy;
|
||||
pub mod fire;
|
||||
pub mod glass;
|
||||
pub mod keys;
|
||||
pub mod pricing;
|
||||
pub mod shock;
|
||||
pub mod tabs;
|
||||
pub mod type_;
|
||||
pub mod word;
|
||||
@@ -0,0 +1,65 @@
|
||||
//! A pricing page. The Pro card hums with a charged border; hovering charges it up, and Upgrade
|
||||
//! throws an electric border round it with a burst of sparks.
|
||||
|
||||
use rune::{Cx, El, col, el, row, spacer};
|
||||
|
||||
use crate::gfx::{ELECTRIC, GLOW, SPARKLES};
|
||||
use crate::kit::*;
|
||||
use crate::State;
|
||||
|
||||
const HOVER: f64 = 0.55;
|
||||
const TAP: f64 = 1.25;
|
||||
|
||||
fn feature(s: &str, on: bool) -> El {
|
||||
row().gap(10.0).center_y()
|
||||
.child(el().size(16.0, 16.0).radius(8.0).center().fill(if on { ca(0x54b3fd, 0.18) } else { ca(0xffffff, 0.06) }).child(dot(if on { 0x54b3fd } else { 0x8a8a93 }, 5.0)))
|
||||
.child(t(s, 13.5, 400.0, 0xc9c9d0))
|
||||
}
|
||||
|
||||
fn plan(name: &str, price: &str, blurb: &str, feats: [&str; 4], cta: &str, pro: bool, press: f32) -> El {
|
||||
let mut c_ = col().w(268.0).h(318.0).padding(24.0).gap(8.0).radius(20.0)
|
||||
.fill(if pro { c(0x16181f) } else { c(0x121215) })
|
||||
.border(1.0, if pro { ca(0x54b3fd, 0.35) } else { hair() })
|
||||
.child(row().w_full().center_y().child(t(name, 15.0, 600.0, TEXT)).child(spacer()).child(if pro {
|
||||
el().px(8.0).py(3.0).radius(8.0).fill(ca(0x54b3fd, 0.16)).child(t("Popular", 11.5, 600.0, 0x8fd0ff))
|
||||
} else {
|
||||
el()
|
||||
}))
|
||||
.child(row().mt(6.0).items_end().gap(4.0).child(t(price, 40.0, 600.0, TEXT)).child(t("/mo", 14.0, 500.0, MUTED).mb(8.0)))
|
||||
.child(t(blurb, 13.0, 400.0, MUTED).mb(10.0));
|
||||
for (i, f) in feats.iter().enumerate() {
|
||||
c_ = c_.child(feature(f, pro || i < 2));
|
||||
}
|
||||
c_.child(spacer()).child(
|
||||
row().w_full().h(40.0).radius(11.0).center().scale(1.0 - 0.06 * press)
|
||||
.fill(if pro { c(0xeef4ff) } else { ca(0xffffff, 0.07) })
|
||||
.child(t(cta, 14.0, 600.0, if pro { 0x0e1320 } else { TEXT })),
|
||||
)
|
||||
}
|
||||
|
||||
pub fn view(s: &State, _: &mut Cx<State>) -> El {
|
||||
let t_ = s.t;
|
||||
let hover = ease(t_, HOVER, 0.35);
|
||||
let hit = ease(t_, TAP, 0.08);
|
||||
let press = pressed(t_, TAP);
|
||||
let x0 = (W - 3.0 * 268.0 - 2.0 * 22.0) / 2.0;
|
||||
let y0 = 176.0;
|
||||
let px_ = x0 + 268.0 + 22.0;
|
||||
let lift = track(t_, 0.0, &[(HOVER, 1.0, sp(0.45, 0.3))]);
|
||||
|
||||
let header = col().absolute(0.0, 54.0).w(W).items_center().gap(10.0)
|
||||
.child(t("PRICING", 12.0, 600.0, 0x54b3fd))
|
||||
.child(t("Plans that scale with you", 32.0, 600.0, TEXT))
|
||||
.child(t("Start free. Upgrade when your team needs more.", 15.0, 400.0, MUTED));
|
||||
|
||||
let pro_y = y0 - 8.0 * lift;
|
||||
el().w(W).h(H).fill(c(0x0a0a0c))
|
||||
.child(header)
|
||||
.child(plan("Hobby", "$0", "For side projects and prototypes.", ["One project", "Preview deploys", "Community support", "Analytics"], "Get started", false, 0.0).absolute(x0, y0))
|
||||
.child(plan("Team", "$60", "For studios shipping together.", ["Unlimited projects", "SSO and audit log", "Analytics", "Priority support"], "Contact us", false, 0.0).absolute(x0 + 2.0 * (268.0 + 22.0), y0))
|
||||
.child(fx(GLOW, [1.0, 13.0, 0.35 + 0.5 * hover + 0.8 * hit, 22.0]).absolute(px_, pro_y).size(268.0, 318.0).radius(20.0).effect_bleed(60.0))
|
||||
.child(plan("Pro", "$20", "For apps people use every day.", ["Unlimited projects", "Custom domains", "Team analytics", "Priority builds"], "Upgrade", true, press).absolute(px_, pro_y))
|
||||
.child(fx(ELECTRIC, [0.5 + 0.7 * hover + 0.4 * hit, if t_ >= TAP { 6.0 } else { 0.0 }, if t_ >= TAP { 0.0 } else { 1.0 }, 13.0]).absolute(px_, pro_y).size(268.0, 318.0).radius(20.0).effect_bleed(40.0))
|
||||
.child(fx(SPARKLES, [TAP as f32 + 0.05, 14.0, 10.0, 13.0]).absolute(px_ + 24.0, pro_y + 254.0).size(220.0, 40.0).radius(11.0).effect_bleed(60.0))
|
||||
.child(pointer_at(t_, [960.0, 560.0], &[(0.12, px_ + 180.0, pro_y + 140.0), (0.75, px_ + 140.0, y0 + 272.0)], &[TAP]))
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
//! A photo library of live gradients. Taps send shockwaves through the whole window, on the beat.
|
||||
|
||||
use rune::{Cx, El, col, el, row, spacer};
|
||||
|
||||
use crate::gfx::{MESH, SHOCK};
|
||||
use crate::kit::*;
|
||||
use crate::State;
|
||||
|
||||
/// Taps: time and grid cell (column, row). 0.6667 s apart, a beat at 90 BPM.
|
||||
const TAPS: [(f64, usize, usize); 3] = [(0.5, 2, 1), (1.1667, 0, 2), (1.8333, 4, 0)];
|
||||
|
||||
pub fn view(s: &State, _: &mut Cx<State>) -> El {
|
||||
let t_ = s.t;
|
||||
let (cols, rows) = (5usize, 3usize);
|
||||
let (gx, gy, gap) = (28.0, 92.0, 10.0);
|
||||
let tw = (W - 2.0 * gx - gap * (cols as f32 - 1.0)) / cols as f32;
|
||||
let th = (H - gy - 24.0 - gap * (rows as f32 - 1.0)) / rows as f32;
|
||||
|
||||
let seg = ["Years", "Months", "Days", "All Photos"];
|
||||
let sel = track(t_, 3.0, &[(0.25, 2.0, sp(0.45, 0.25))]);
|
||||
let mut seg_row = el().h(34.0).w(4.0 * 92.0 + 8.0).radius(10.0).fill(ca(0xffffff, 0.06))
|
||||
.child(el().absolute(4.0 + sel * 92.0, 4.0).size(92.0, 26.0).radius(7.0).fill(ca(0xffffff, 0.14)));
|
||||
for (i, name) in seg.iter().enumerate() {
|
||||
seg_row = seg_row.child(row().absolute(4.0 + i as f32 * 92.0, 4.0).size(92.0, 26.0).center().child(t(*name, 13.0, 500.0, if (sel - i as f32).abs() < 0.5 { TEXT } else { MUTED })));
|
||||
}
|
||||
let header = row().absolute(gx, 28.0).w(W - 2.0 * gx).center_y()
|
||||
.child(col().gap(3.0).child(t("Library", 24.0, 600.0, TEXT)).child(t("1,284 photos · 3 albums", 13.0, 400.0, MUTED)))
|
||||
.child(spacer())
|
||||
.child(seg_row);
|
||||
|
||||
let mut root = el().w(W).h(H).fill(c(0x08080a)).child(header);
|
||||
for r in 0..rows {
|
||||
for cc in 0..cols {
|
||||
let i = r * cols + cc;
|
||||
let press = TAPS.iter().filter(|(_, x, y)| *x == cc && *y == r).map(|(tp, _, _)| pressed(t_, *tp)).fold(0.0f32, f32::max);
|
||||
let x = gx + cc as f32 * (tw + gap);
|
||||
let y = gy + r as f32 * (th + gap);
|
||||
root = root.child(fx(MESH, [(i % 8) as f32, 0.5, i as f32, 0.25]).key(format!("tile-{i}")).absolute(x, y).size(tw, th).radius(12.0).scale(1.0 - 0.06 * press));
|
||||
}
|
||||
}
|
||||
// Always in the tree (an idle shockwave draws nothing), so no slot enters inside a fade layer,
|
||||
// where its backdrop would be the empty layer.
|
||||
for (tp, cc, r) in TAPS {
|
||||
let x = gx + cc as f32 * (tw + gap) + tw / 2.0;
|
||||
let y = gy + r as f32 * (th + gap) + th / 2.0;
|
||||
root = root.child(fx(SHOCK, [x, y, tp as f32 + 0.03, 22.0]).key(format!("shock-{cc}-{r}")).effect_backdrop(true).absolute(0.0, 0.0).size(W, H));
|
||||
}
|
||||
let path: Vec<(f64, f32, f32)> = TAPS.iter().map(|(tp, cc, r)| (tp - 0.42, gx + *cc as f32 * (tw + gap) + tw / 2.0, gy + *r as f32 * (th + gap) + th / 2.0)).collect();
|
||||
let taps: Vec<f64> = TAPS.iter().map(|x| x.0).collect();
|
||||
root.child(pointer_at(t_, [700.0, 500.0], &path, &taps))
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
//! A feed scrolling under a floating liquid-glass tab bar. The selection is a drop of the same
|
||||
//! glass that slides between tabs and bulges out of the bar as it goes.
|
||||
|
||||
use rune::{Cx, El, col, el, row};
|
||||
|
||||
use crate::gfx::{LENS, MESH};
|
||||
use crate::kit::*;
|
||||
use crate::State;
|
||||
|
||||
const STORIES: [(&str, &str, u32); 6] = [
|
||||
("Kyoto after rain", "Photo essay · 12 min", 1),
|
||||
("The quiet studio", "Design · 6 min", 7),
|
||||
("Night markets", "Travel · 9 min", 5),
|
||||
("Ferry to Naoshima", "Photo essay · 8 min", 4),
|
||||
("Paper and light", "Craft · 5 min", 2),
|
||||
("Cold coast", "Travel · 11 min", 6),
|
||||
];
|
||||
|
||||
fn story(title: &str, meta: &str, pal: u32, w: f32, h: f32, seed: f32) -> El {
|
||||
col().w(w).gap(10.0)
|
||||
.child(fx(MESH, [pal as f32, 0.5, seed, 0.25]).w(w).h(h).radius(18.0))
|
||||
.child(t(title, 17.0, 600.0, TEXT))
|
||||
.child(t(meta, 13.0, 400.0, MUTED))
|
||||
}
|
||||
|
||||
pub fn view(s: &State, _: &mut Cx<State>) -> El {
|
||||
let t_ = s.t;
|
||||
// The feed scrolls on its own, with a flick a second in.
|
||||
let scroll = 50.0 * t_ as f32 + track(t_, 0.0, &[(0.9, 260.0, sp(1.1, 0.0))]);
|
||||
let mut feed = col().absolute(40.0, 30.0 - scroll).w(W - 80.0).gap(28.0)
|
||||
.child(col().gap(4.0).child(t("Today", 30.0, 600.0, TEXT)).child(t("Friday, November 6", 14.0, 500.0, MUTED)))
|
||||
.child(story("Glass, light and the long weekend", "Featured · 14 min", 0, W - 80.0, 300.0, 1.0));
|
||||
for pair in STORIES.chunks(3) {
|
||||
let mut r = row().gap(20.0);
|
||||
for (i, (title, meta, pal)) in pair.iter().enumerate() {
|
||||
r = r.child(story(title, meta, *pal, (W - 80.0 - 40.0) / 3.0, 180.0, 10.0 + i as f32 + *pal as f32));
|
||||
}
|
||||
feed = feed.child(r);
|
||||
}
|
||||
|
||||
// The bar and its selection drop.
|
||||
let (bw, bh) = (400.0, 64.0);
|
||||
let (bx, by) = ((W - bw) / 2.0, H - bh - 26.0);
|
||||
let tabs = ["Today", "Search", "Saved", "Profile"];
|
||||
let slot = bw / 4.0;
|
||||
let sel = track(t_, 0.0, &[(0.55, 2.0, sp(0.7, 0.28)), (1.75, 1.0, sp(0.6, 0.3))]);
|
||||
let sx = bx + slot * (sel + 0.5);
|
||||
let mut root = el().w(W).h(H).fill(c(0x0b0b0d)).child(feed)
|
||||
.child(fx(LENS, [sx, by + bh / 2.0, 42.0, 0.2]).effect_backdrop(true).absolute(bx, by).size(bw, bh).radius(bh / 2.0))
|
||||
.child(fx(LENS, [0.0, 0.0, 0.0, 0.25]).effect_backdrop(true).absolute(bx + bw + 16.0, by).size(bh, bh).radius(bh / 2.0));
|
||||
for (i, name) in tabs.iter().enumerate() {
|
||||
let on = (sel - i as f32).abs() < 0.5;
|
||||
root = root.child(row().absolute(bx + slot * i as f32, by).size(slot, bh).center().child(t(*name, 13.5, 600.0, if on { 0xffffff } else { 0xd8d8de })));
|
||||
}
|
||||
root.child(row().absolute(bx + bw + 16.0, by).size(bh, bh).center().child(t("+", 26.0, 400.0, 0xffffff)))
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
//! A writing app: a note on type. The last line types itself under a blinking caret, then a
|
||||
//! double click selects two words and a format bar springs up over them. Made for macro shots
|
||||
//! (`--scale 6`), where the glyph edges are the subject.
|
||||
|
||||
use rune::{Cx, El, TextStyle, col, el, row, text};
|
||||
|
||||
use crate::kit::*;
|
||||
use crate::State;
|
||||
|
||||
const TITLE: &str = "Small type, sharp edges";
|
||||
const LINES: [&str; 2] = ["Good interfaces are mostly text. Labels, numbers,", "code and long reading all live or die by the edge"];
|
||||
const TYPED: (&str, &str, &str) = ("of ", "every glyph", ", and where it lands on the pixel.");
|
||||
const TYPE_FROM: f64 = 0.5;
|
||||
const TYPE_RATE: f64 = 16.0;
|
||||
const SELECT: f64 = 3.9;
|
||||
|
||||
const BODY: f32 = 17.0;
|
||||
const INK: u32 = 0xc9cad1;
|
||||
|
||||
fn body(s: impl Into<String>, color: u32) -> El {
|
||||
text(s).font(TextStyle::new(BODY, 400.0)).color(c(color))
|
||||
}
|
||||
|
||||
fn caret(t_: f64, typing: bool) -> El {
|
||||
let on = typing || ((t_ * 1.8) as i64) % 2 == 0;
|
||||
el().w(2.0).h(22.0).radius(1.0).fill(ca(0x8ab4ff, if on { 1.0 } else { 0.0 }))
|
||||
}
|
||||
|
||||
fn format_bar(k: f32) -> El {
|
||||
let item = |s: &str, w: f32, on: bool| {
|
||||
row().size(30.0, 28.0).radius(7.0).center().fill(ca(0xffffff, if on { 0.1 } else { 0.0 }))
|
||||
.child(text(s).font(TextStyle::new(14.0, w)).color(c(if on { 0xffffff } else { 0xb4b6bf })))
|
||||
};
|
||||
row().key("format").h(38.0).px(5.0).gap(2.0).radius(11.0).center_y()
|
||||
.fill(c(0x1d1e23)).border(1.0, ca(0xffffff, 0.1)).shadow(10.0, 28.0, ca(0x000000, 0.55))
|
||||
.scale(0.86 + 0.14 * k).opacity(k.clamp(0.0, 1.0))
|
||||
.child(item("B", 700.0, true))
|
||||
.child(item("I", 400.0, false))
|
||||
.child(item("U", 400.0, false))
|
||||
.child(el().w(1.0).h(18.0).mx(4.0).fill(ca(0xffffff, 0.12)))
|
||||
.child(item("Aa", 500.0, false))
|
||||
.child(item("“", 500.0, false))
|
||||
}
|
||||
|
||||
pub fn view(s: &State, _: &mut Cx<State>) -> El {
|
||||
let t_ = s.t;
|
||||
let full = format!("{}{}{}", TYPED.0, TYPED.1, TYPED.2);
|
||||
let n = (((t_ - TYPE_FROM) * TYPE_RATE).max(0.0) as usize).min(full.chars().count());
|
||||
let typing = n < full.chars().count();
|
||||
let sel = track(t_, 0.0, &[(SELECT, 1.0, sp(0.3, 0.0))]);
|
||||
let bar = track(t_, 0.0, &[(SELECT + 0.12, 1.0, sp(0.45, 0.32))]);
|
||||
|
||||
let last = if t_ < SELECT {
|
||||
let typed: String = full.chars().take(n).collect();
|
||||
row().h(28.0).center_y().child(body(typed, INK)).child(caret(t_, typing))
|
||||
} else {
|
||||
row().h(28.0).center_y()
|
||||
.child(body(TYPED.0, INK))
|
||||
.child(el().radius(3.0).fill(ca(0x3b82f6, 0.42 * sel)).child(body(TYPED.1, 0xffffff)))
|
||||
.child(body(TYPED.2, INK))
|
||||
};
|
||||
|
||||
let mut doc = col().key("doc").absolute(200.0, 130.0).w(600.0).gap(0.0)
|
||||
.child(row().gap(8.0).center_y()
|
||||
.child(text("Notes").font(TextStyle::new(12.5, 500.0)).color(c(FAINT)))
|
||||
.child(text("/").font(TextStyle::new(12.5, 400.0)).color(c(0x45454c)))
|
||||
.child(text("Typography").font(TextStyle::new(12.5, 500.0)).color(c(MUTED))))
|
||||
.child(el().h(22.0))
|
||||
.child(text(TITLE).font(TextStyle { tracking: -0.9, ..TextStyle::new(40.0, 600.0) }).color(c(0xf3f3f5)))
|
||||
.child(el().h(10.0))
|
||||
.child(row().gap(10.0).center_y()
|
||||
.child(avatar("", 0x7c5cff, 18.0))
|
||||
.child(text("Mira Chen").font(TextStyle::new(13.0, 500.0)).color(c(MUTED)))
|
||||
.child(text("·").font(TextStyle::new(13.0, 400.0)).color(c(FAINT)))
|
||||
.child(text("4 min read").font(TextStyle::new(13.0, 400.0)).color(c(FAINT))))
|
||||
.child(el().h(26.0));
|
||||
for l in LINES {
|
||||
doc = doc.child(row().h(28.0).center_y().child(body(l, INK)));
|
||||
}
|
||||
doc = doc.child(last);
|
||||
doc = doc.child(el().h(24.0)).child(
|
||||
row().gap(10.0).center_y()
|
||||
.child(el().px(8.0).py(3.0).radius(6.0).fill(ca(0xffffff, 0.06)).child(mono("font-feature-settings: \"tnum\"", 12.5, 0x9ecbff)))
|
||||
.child(text("0123456789").font(TextStyle::new(13.0, 500.0)).color(c(MUTED))),
|
||||
);
|
||||
|
||||
let mut root = el().w(W).h(H).fill(c(0x0b0b0d)).child(doc);
|
||||
if t_ >= SELECT + 0.1 {
|
||||
// Centred over the selected words on the third body line.
|
||||
root = root.child(row().key("format-at").absolute(181.0, 284.0 - 6.0 * (1.0 - bar)).child(format_bar(bar)));
|
||||
}
|
||||
root
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
//! ᚱUNE, the wordmark from the site's pixel grid, built from liquid-metal tiles that spring in
|
||||
//! along the letters and then flow as one surface. `card` adds the repository line under it.
|
||||
|
||||
use rune::{Cx, El, el};
|
||||
|
||||
use crate::gfx::CHROME;
|
||||
use crate::kit::*;
|
||||
use crate::State;
|
||||
|
||||
const GLYPHS: [&str; 4] = [
|
||||
"###....|####...|##.##..|##..##.|##..##.|##.##..|####...|##.##..|##..##.|##...##|##...##",
|
||||
"##...##|##...##|##...##|##...##|##...##|##...##|##...##|##...##|##...##|#######|.#####.",
|
||||
"###...##|####..##|####..##|####..##|##.##.##|##.##.##|##.##.##|##..####|##..####|##..####|##...###",
|
||||
"######|######|##....|##....|#####.|#####.|##....|##....|##....|######|######",
|
||||
];
|
||||
|
||||
fn ink(rows: &[&str], dx: i32) -> Vec<(i32, i32)> {
|
||||
let mut v = Vec::new();
|
||||
for (y, r) in rows.iter().enumerate() {
|
||||
for (x, ch) in r.chars().enumerate() {
|
||||
if ch == '#' {
|
||||
v.push((x as i32 + dx, y as i32));
|
||||
}
|
||||
}
|
||||
}
|
||||
v
|
||||
}
|
||||
|
||||
/// Every inked cell of the wordmark, letters fitted one clear pixel apart (diagonals included).
|
||||
pub fn cells() -> (Vec<(i32, i32, usize)>, i32) {
|
||||
let mut out: Vec<(i32, i32, usize)> = Vec::new();
|
||||
let mut at = 0;
|
||||
let mut width = 0;
|
||||
let mut prev: Option<Vec<(i32, i32)>> = None;
|
||||
for (g, glyph) in GLYPHS.iter().enumerate() {
|
||||
let rows: Vec<&str> = glyph.split('|').collect();
|
||||
let b = ink(&rows, 0);
|
||||
if let Some(a) = &prev {
|
||||
let mut x = at + 1;
|
||||
while a.iter().any(|(ax, ay)| b.iter().any(|(bx, by)| (bx + x - ax).abs() <= 1 && (by - ay).abs() <= 1)) {
|
||||
x += 1;
|
||||
}
|
||||
at = x;
|
||||
}
|
||||
let placed = ink(&rows, at);
|
||||
out.extend(placed.iter().map(|&(x, y)| (x, y, g)));
|
||||
width = at + rows[0].len() as i32;
|
||||
prev = Some(placed);
|
||||
}
|
||||
(out, width)
|
||||
}
|
||||
|
||||
pub fn view(s: &State, _: &mut Cx<State>, card: bool) -> El {
|
||||
let t = s.t;
|
||||
let (cells, width) = cells();
|
||||
let cell = if card { 19.0 } else { 25.0 };
|
||||
let tile = cell - 1.0;
|
||||
let total_w = width as f32 * cell;
|
||||
let total_h = 11.0 * cell;
|
||||
// A slow push in, about the frame's centre.
|
||||
let zoom = if card { 1.0 } else { 1.0 + 0.05 * ease(t, 0.0, 4.0) };
|
||||
let ox = (W - total_w * zoom) / 2.0;
|
||||
let oy = if card { 168.0 } else { (H - total_h * zoom) / 2.0 };
|
||||
let mut root = el().w(W).h(H).fill(c(0x000000));
|
||||
for &(x, y, g) in &cells {
|
||||
// A wave left to right, each letter a beat behind the last, rows rippling down.
|
||||
let delay = 0.08 + g as f64 * 0.11 + x as f64 * 0.012 + y as f64 * 0.018;
|
||||
let k = track(t, 0.0, &[(delay, 1.0, sp(0.55, 0.38))]);
|
||||
let size = tile * zoom * k.max(0.0);
|
||||
let cx = ox + (x as f32 + 0.5) * cell * zoom;
|
||||
let cy = oy + (y as f32 + 0.5) * cell * zoom;
|
||||
if size < 0.5 {
|
||||
continue;
|
||||
}
|
||||
root = root.child(
|
||||
fx(CHROME, [4.0, 0.0, 1.25, 0.0])
|
||||
.key(format!("c{x}_{y}"))
|
||||
.absolute(cx - size / 2.0, cy - size / 2.0)
|
||||
.size(size, size)
|
||||
.radius(2.5 * zoom * k),
|
||||
);
|
||||
}
|
||||
if card {
|
||||
let a = ease(t, 0.9, 0.6);
|
||||
root = root.child(
|
||||
el().absolute(0.0, oy + total_h + 46.0 - 8.0 * a)
|
||||
.w(W)
|
||||
.center()
|
||||
.child(mono_a("github.com/anomalyco/rune", 22.0, 0xb8bcc6, a)),
|
||||
);
|
||||
}
|
||||
root
|
||||
}
|
||||
Reference in new issue
Block a user