MiniDevil As beautiful as a shell
welcome_effects.c
Go to the documentation of this file.
1 /* ************************************************************************** */
2 /* */
3 /* ::: :::::::: */
4 /* welcome_effects.c :+: :+: :+: */
5 /* +:+ +:+ +:+ */
6 /* By: baelgadi <baelgadi@student.42.fr> +#+ +:+ +#+ */
7 /* +#+#+#+#+#+ +#+ */
8 /* Created: 2026/02/17 17:50:02 by zotaj-di #+# #+# */
9 /* Updated: 2026/03/04 03:58:55 by baelgadi ### ########.fr */
10 /* */
11 /* ************************************************************************** */
12 
13 #include "welcome_ui.h"
14 
21 static void print_mystic_char(char c, int idx)
22 {
23  const char *mystic[] = {C_M1, C_M2, C_M3, C_M4, C_M5};
24 
25  ft_printf("%s%s%c", BOLD, mystic[idx % 5], c);
26 }
27 
34 {
35  const char *title = ">>> MINIHELL <<<";
36  int row;
37  int col;
38  int i;
39 
40  row = t->center_y - 12;
41  col = (t->width - 16) / 2;
42  print_at_pos(row - 1, col - 2, C_AURA3 "▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄" RESET);
43  print_at_pos(row + 1, col - 2, C_AURA3 "▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀" RESET);
44  print_at_pos(row, col - 2, C_AURA5 "█" RESET);
45  print_at_pos(row, col + 17, C_AURA5 "█" RESET);
46  print_at_pos(row, col, "");
47  i = -1;
48  while (title[++i])
49  {
50  print_mystic_char(title[i], i);
51  ft_msleep(40);
52  }
53  ft_printf("%s", RESET);
54 }
55 
62 static void print_quote_lines(t_welcome_term *t, int row)
63 {
64  const char *q1;
65  const char *q2;
66  const char *q3;
67 
68  q1 = "\"Unix is simple. It just takes a genius";
69  q2 = "to understand its simplicity.\"";
70  q3 = "- Dennis Ritchie";
71  print_centered(t, row + 1, C_AURA3 "║ " RESET, 46);
72  print_at_pos(row + 1, (t->width + 44) / 2 - 1, C_AURA3 " ║" RESET);
73  print_at_pos(row + 1, (t->width - 40) / 2 + 1, DIM C_M4);
74  ft_printf("%s%s", q1, RESET);
75  ft_msleep(100);
76  print_centered(t, row + 2, C_AURA3 "║ " RESET, 46);
77  print_at_pos(row + 2, (t->width + 44) / 2 - 1, C_AURA3 " ║" RESET);
78  print_at_pos(row + 2, (t->width - 32) / 2 + 1, DIM C_M4);
79  ft_printf("%s%s", q2, RESET);
80  ft_msleep(100);
81  print_centered(t, row + 3, C_AURA3 "║ " RESET, 46);
82  print_at_pos(row + 3, (t->width + 44) / 2 - 1, C_AURA3 " ║" RESET);
83  print_at_pos(row + 3, (t->width - 18) / 2 + 1, BOLD C_M5);
84  ft_printf("%s%s", q3, RESET);
85 }
86 
93 {
94  int row;
95 
96  row = t->center_y - 9;
97  print_centered(t, row,
98  C_AURA3 "╔════════════════════════════════════════════╗" RESET, 46);
99  ft_msleep(100);
100  print_quote_lines(t, row);
101  print_centered(t, row + 4,
102  C_AURA3 "╚════════════════════════════════════════════╝" RESET, 46);
103 }
#define BOLD
Definition: minishell_ui.h:38
#define RESET
Definition: minishell_ui.h:37
#define DIM
Definition: minishell_ui.h:39
Extended terminal info (for welcome screen pos)
Definition: welcome_ui.h:49
int width
Terminal width.
Definition: welcome_ui.h:50
int center_y
Vertical center row.
Definition: welcome_ui.h:53
static void print_mystic_char(char c, int idx)
Print a single title character in mystic fire color.
static void print_quote_lines(t_welcome_term *t, int row)
Print the quote and its box borders.
void animate_quote(t_welcome_term *t)
Draw the quote inside a decorative box.
void animate_title(t_welcome_term *t)
Animate the title appearing character by character.
Welcome screen structures & prototypes.
#define C_AURA5
Definition: welcome_ui.h:32
#define C_M4
Definition: welcome_ui.h:38
#define C_M3
Definition: welcome_ui.h:37
#define C_M2
Definition: welcome_ui.h:36
#define C_M5
Definition: welcome_ui.h:39
#define C_AURA3
Definition: welcome_ui.h:30
#define C_M1
Definition: welcome_ui.h:35
void print_centered(t_welcome_term *t, int row, const char *str, int len)
Print string centered on the given row.
Definition: welcome_utils.c:90
void ft_msleep(int ms)
Sleep for approximately ms millisecondes using a little trick.
Definition: welcome_utils.c:28
void print_at_pos(int row, int col, const char *str)
Move the terminal cursor to [row, col] and print str.
Definition: welcome_utils.c:77