Skip to content

Commit

Permalink
chore(examples): update website
Browse files Browse the repository at this point in the history
  • Loading branch information
orhun committed Jan 28, 2025
1 parent bb20ad1 commit 4b5e660
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 17 deletions.
2 changes: 1 addition & 1 deletion examples/animations/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions examples/animations/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ fn main() -> io::Result<()> {
std::panic::set_hook(Box::new(console_error_panic_hook::hook));
let backend = CanvasBackend::new()?;
let terminal = Terminal::new(backend)?;

// Or you can use the provided effect combinators.
let mut effect = fx::sequence(&[
// first we "sweep in" the text from the left, before reversing the effect
fx::ping_pong(fx::sweep_in(
Expand Down
2 changes: 1 addition & 1 deletion examples/website/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 25 additions & 13 deletions examples/website/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
use std::io;

use layout::Flex;
use layout::{Flex, Offset};
use ratzilla::{
event::{KeyCode, KeyEvent},
ratatui::{
prelude::*,
widgets::{Block, BorderType, Clear, Paragraph, Wrap},
},
utils::open_url,
CanvasBackend, WebRenderer,
widgets::Hyperlink,
DomBackend, WebRenderer,
};
use tachyonfx::{
fx, CenteredShrink, Duration, Effect, EffectRenderer, EffectTimer, Interpolation, Motion,
Shader,
fx::{self, RepeatMode},
CenteredShrink, Duration, Effect, EffectRenderer, EffectTimer, Interpolation, Motion, Shader,
};

struct State {
Expand All @@ -33,6 +34,14 @@ impl Default for State {
)),
fx::coalesce((3000, Interpolation::SineOut)),
fx::sleep(1000),
fx::repeat(
fx::hsl_shift(
Some([120.0, 25.0, 25.0]),
None,
(5000, Interpolation::Linear),
),
RepeatMode::Forever,
),
]),
menu_effect: fx::sequence(&[
fx::coalesce((3000, Interpolation::SineOut)),
Expand All @@ -44,7 +53,7 @@ impl Default for State {

fn main() -> io::Result<()> {
std::panic::set_hook(Box::new(console_error_panic_hook::hook));
let backend = CanvasBackend::new()?;
let backend = DomBackend::new()?;
let terminal = Terminal::new(backend)?;
let mut state = State::default();
terminal.on_key_event(move |key| handle_key_event(key));
Expand All @@ -53,11 +62,12 @@ fn main() -> io::Result<()> {
}

fn ui(f: &mut Frame<'_>, state: &mut State) {
if state.intro_effect.running() {
render_intro(f, state);
} else {
render_menu(f, state);
}
render_intro(f, state);
// if state.intro_effect.running() {
// render_intro(f, state);
// } else {
// render_menu(f, state);
// }
}

fn handle_key_event(key: KeyEvent) {
Expand All @@ -74,12 +84,14 @@ fn handle_key_event(key: KeyEvent) {

fn render_intro(f: &mut Frame<'_>, state: &mut State) {
Clear.render(f.area(), f.buffer_mut());
let area = f.area().inner_centered(25, 2);
let area = f.area().inner_centered(33, 2);
let main_text = Text::from(vec![
Line::from("| R A T Z I L L A |"),
Line::from("Stomping through the web"),
Line::from("| R A T Z I L L A |").bold(),
Line::from("Stomping through the web").italic(),
]);
f.render_widget(main_text.light_green().centered(), area);
let link = Hyperlink::new("https://github.com/orhun/ratzilla".red());
f.render_widget(link, area.offset(Offset { x: 0, y: 4 }));
f.render_effect(&mut state.intro_effect, area, Duration::from_millis(40));
}

Expand Down

0 comments on commit 4b5e660

Please sign in to comment.