Rust 的电影感 ANSI 横幅

发布: (2025年12月20日 GMT+8 14:42)
4 min read
原文: Dev.to

Source: Dev.to

tui-banner 有何硬核之处?

  • Zero Dependencies – No external crates, fonts, or Figlet files required. Your binary stays lean and mean.
    零依赖 – 不需要外部 crate、字体或 Figlet 文件。你的二进制文件保持轻量且高效。
  • Truecolor Support – Full 24‑bit and ANSI256 color support for silky‑smooth transitions.
    真彩色支持 – 完整的 24 位和 ANSI256 颜色支持,实现丝般顺滑的过渡。
  • Figlet Font Rendering – Built‑in classic Figlet engine supporting all standard Figlet fonts.
    Figlet 字体渲染 – 内置经典 Figlet 引擎,支持所有标准 Figlet 字体。
  • Preset Styles – 14 hand‑picked, cinematic color schemes ready to use with a single line of code:
    预设样式 – 14 种精选、电影感的配色方案,只需一行代码即可使用:
    • Matrix (classic green‑and‑black cyber digital rain)
      Matrix(经典的绿黑赛博数字雨)
    • Neon Cyber (vibrant neon cyberpunk)
      Neon Cyber(充满活力的霓虹赛博朋克)
    • Aurora Flux (ethereal aurora‑like shimmer)
      Aurora Flux(如极光般的空灵闪烁)
    • Deep Space (vast deep‑space nebula)
      Deep Space(浩瀚的深空星云)
    • Ocean Flow (fluid motion of the ocean)
      Ocean Flow(海洋的流动感)
    • Sunset Neon (blazing neon sunset)
      Sunset Neon(炽热的霓虹日落)
    • Fire Warning (intense fire alert)
      Fire Warning(强烈的火警警报)
    • Warm Luxury (elegant warm gold tones)
      Warm Luxury(优雅温暖的金色调)
    • Forest Sky (serene forest canopy)
      Forest Sky(宁静的森林天际)
    • Earth Tone (natural earthy colors)
      Earth Tone(自然的土色系)
    • Chrome (sleek metallic)
      Chrome(光滑金属感)
    • Royal Purple (rich royal purple)
      Royal Purple(浓郁的皇家紫)
    • CRT Amber (classic CRT amber‑on‑black)
      CRT Amber(经典 CRT 的琥珀色‑黑)
    • Arctic Tech (cool high‑tech arctic blue)
      Arctic Tech(冷峻的高科技北极蓝)
  • Highly Customizable – Gradients, palettes, fill characters, borders… total control over the look.
    高度可定制 – 渐变、调色板、填充字符、边框……对外观拥有完全控制。
  • Blazing Fast – Renders instantly, so your launch screen appears in a flash.
    极速渲染 – 即时渲染,让启动画面瞬间出现。

代码有多简洁?

use tui_banner::{Banner, Style};

fn main() -> Result {
    println!();
    let banner = Banner::new("RUST CLI")?
        .style(Style::Matrix) // Select a style with one line
        .render();
    println!("{banner}");
    Ok(())
}

只需这几行代码,你的程序启动就像《黑客帝国》中的场景。

自定义渐变和字体

let banner = Banner::new("WELCOME")
    .font("Big")            // Switch to a larger font
    .gradient(true)        // Enable the gradient
    .palette("cyberpunk")  // Use a custom palette
    .fill("•")              // Set a custom fill character
    .render();

适合谁使用?

  • Rust Developers – Give your command‑line tools a high‑end, professional launch screen.
    Rust 开发者 – 为你的命令行工具提供高端、专业的启动画面。
  • TUI Project Authors – Add ceremony to ratatui or cursive projects.
    TUI 项目作者 – 为 ratatuicursive 项目增添仪式感。
  • Open Source Enthusiasts – Make your tool’s screenshots instantly eye‑catching on GitHub.
    开源爱好者 – 让你的工具截图在 GitHub 上立刻吸睛。
  • Terminal Aesthetes – For those who believe daily coding should be beautiful.
    终端审美者 – 为那些相信日常编码也应当美观的人。

官方网站

tui-banner Official Website

点击链接即可享受视觉盛宴:查看全部 14 种样式的渲染效果,详细的使用方法、API 文档,当然,一切都是免费且开源的。

最后一点…

如果你仍然用 println!("Hello, world!"); 来启动程序,那你真的错失良机。是时候让你的 CLI 成为终端的主角了。

Rust 社区又交付了一个让人惊喜的工具。给它点星标,让你的终端焕发光彩吧! 🚀

Back to Blog

相关文章

阅读更多 »