commit 50c15b30e1deda11461caaedab6d305ad394822b Author: lfirmin Date: Sun Nov 16 09:58:07 2025 +0100 intra to gitea diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a43c18f --- /dev/null +++ b/.gitignore @@ -0,0 +1,33 @@ +# IDE - Visual Studio Code +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json + +# IDE - JetBrains (IntelliJ, PyCharm, WebStorm, etc) +.idea/ +*.iml +*.iws +.idea_modules/ + +# IDE - Eclipse +.classpath +.project +.settings/ +.metadata/ + +# IDE - Sublime Text +*.sublime-workspace +*.sublime-project + +# IDE - NetBeans +nbproject/ +nbbuild/ +dist/ +nbdist/ +.nb-gradle/ + +# Fichiers système +.DS_Store +Thumbs.db \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..1893b58 --- /dev/null +++ b/Makefile @@ -0,0 +1,97 @@ +# **************************************************************************** # +# # +# ::: :::::::: # +# Makefile :+: :+: :+: # +# +:+ +:+ +:+ # +# By: lfirmin lfirmim@student.42.fr> +#+ +:+ +#+ # +# +#+#+#+#+#+ +#+ # +# Created: 2024/08/12 07:07:31 by lfirmin #+# #+# # +# Updated: 2024/08/12 09:15:05 by lfirmin ### ########.fr # +# # +# **************************************************************************** # + +NAME = so_long +LIBFT = libft.a +GNL = gnl.a +FT_PRINTF_FD = libftprintf.a +SRC_FILES = main.c pars_map.c pars_map_2.c pars_map_3.c utils.c utils_2.c utils_3.c utils_4.c +INCLUDES_FILES = include/so_long.h +SRC_DIR = srcs/ +SRC = $(addprefix $(SRC_DIR), $(SRC_FILES)) +OBJ_DIR = obj/ +OBJ = $(addprefix $(OBJ_DIR), $(SRC_FILES:.c=.o)) +CC = cc +CFLAGS = -Wall -Werror -Wextra -g3 +INCLUDE = -I include +RM = rm -rf +MKDIR = mkdir -p + +GREEN = \033[0;32m +YELLOW = \033[0;33m +CYAN = \033[0;36m +RESET = \033[0m +BOLD = \033[1m +WHITE = \033[0;97m + +LOADING_CHARS = ⠋ ⠙ ⠹ ⠸ ⠼ ⠴ ⠦ ⠧ ⠇ ⠏ + +define SO_LONG_ART + ▗▄▄▖ ▗▄▖ ▗▖ ▗▄▖ ▗▖ ▗▖ ▗▄▄▖ +▐▌ ▐▌ ▐▌ ▐▌ ▐▌ ▐▌▐▛▚▖▐▌▐▌ + ▝▀▚▖▐▌ ▐▌ ▐▌ ▐▌ ▐▌▐▌ ▝▜▌▐▌▝▜▌ +▗▄▄▞▘▝▚▄▞▘▄▄▄▄▖▐▙▄▄▖▝▚▄▞▘▐▌ ▐▌▝▚▄▞▘ + + +endef +export SO_LONG_ART + +all: print_art $(NAME) + +print_art: + @printf "$(YELLOW)%s$(RESET)\n" "$$SO_LONG_ART" + +$(NAME): $(OBJ) $(INCLUDES_FILES) + @printf "$(BOLD)$(WHITE)Welcome to the $(GREEN)SO_LONG$(WHITE) compilation process.\nPlease hold on as we prepare your program.\n\n$(RESET)" + @make -s -C libft + @make -s -C minilibx-linux + @make -s -C gnl + @make -s -C ft_printf_fd + @printf "$(YELLOW)Compiling So_long, Please wait...$(RESET)" + @for char in $(LOADING_CHARS); do \ + printf "\r$(YELLOW)Compiling So_long, Please wait... $$char$(RESET)"; \ + sleep 0.1; \ + done + @$(CC) $(CFLAGS) $(OBJ) $(INCLUDE) -L minilibx-linux -lmlx -lXext -lX11 -lm -lz libft/$(LIBFT) gnl/$(GNL) ft_printf_fd/$(FT_PRINTF_FD) -o $(NAME) + @printf "\r$(GREEN)Great news ! $(WHITE)SO_LONG compiled successfully ! $(RESET)\n\n" + @printf "$(BOLD)$(WHITE)Compilation complete !\n$(GREEN)So_long$(WHITE) is ready to use !\n" + +$(OBJ_DIR)%.o: $(SRC_DIR)%.c + @$(MKDIR) $(OBJ_DIR) + @$(CC) $(CFLAGS) $(INCLUDE) -c $< -o $@ + +clean: + @make clean -s -C libft + @make clean -s -C gnl + @make clean -s -C ft_printf_fd + @$(RM) $(OBJ_DIR) + @printf "$(WHITE)Clean process completed for $(GREEN)So_long.$(RESET)\n" + +clean1: + @$(RM) $(OBJ_DIR) + @printf "$(WHITE)Clean process completed for $(GREEN)So_long$(RESET)\n" + +fclean: clean1 + @make fclean -s -C libft + @make fclean -s -C gnl + @make fclean -s -C ft_printf_fd + @$(RM) $(NAME) + @$(RM) $(PRINTF) + @$(RM) $(LIBFT) + @printf "$(WHITE)Full clean process completed for $(GREEN)So_long.$(RESET)\n" + +re: fclean all + +.PHONY: all clean fclean re print_art clean1 norminette + +norminette: + norminette srcs/* include/* libft/*.c libft/*.h gnl/*/*.c gnl/*/*.h ft_printf_fd/*.c ft_printf_fd/*.h | grep "Error" \ No newline at end of file diff --git a/assets/collectible.xpm b/assets/collectible.xpm new file mode 100644 index 0000000..68f68e2 --- /dev/null +++ b/assets/collectible.xpm @@ -0,0 +1,46 @@ +/* XPM */ +static char *result[] = { +/* columns rows colors chars-per-pixel */ +"32 32 8 1 ", +" c #686868", +". c #747474", +"X c gray50", +"o c #3DE0E5", +"O c #65F5E3", +"+ c gray56", +"@ c #9EFEEB", +"# c #D5FFF6", +/* pixels */ +"++++++++X...X.XXX. . ..X++X..XX", +"X+++X+XXXX...XXX... ..XXXXXXXXX", +"XX....X...XXX..X++X++X . .X...", +"+XXX.XXX...X..XX.X..XXX. X..X+", +"XX.. ... ...... @O X..X", +"++X.. #@+XX. ..X.XX @#@O+XXX", +"X...XX. Oo+XXX @O +XXX.+Ooo+..X", +".X++++++++++X @#@Oo+XX++++++.XX.", +"....X++. ..XX+Ooo+++++XX++...XX", +"X.XXXXX.... X++++X. +XX..XXXX", +"X++++X... @Oo .XX.. @O . .++", +"XX++XX @##@Oo X.. @#@oX......X", +"...X. O@#@@OOooo+++ O@Oo+XXXXXXX", +"X.....X+O@OooOo+X...Xoo+XX+++..X", +".... X+++++X......++.....XXX.", +"XX. . ......... .....XXXXXXX", +"X. @#@X..X..X+X @#O XX..X....X", +"X @#@OOo+++XXX @@##@Oo XXXXX..XX", +"XX+Oooo+.X.XX @O#@O@Ooo++XX++XXX", +"XX+++++X. ..X++OooOo++XX+++....", +". .XXXX. @@ . +++++XXX..X.. .X", +"XXXX... @#Oo+ ..XXXXXX ++XXX.", +"XXX..XXX+Oo++++X++XXX. Ooo ..X++", +"XXXXXXXXX++++XXXXX @@Ooo ...X", +".X..X...XX+XXX.. @##@@OOOoo+ ..", +"XXX. . +++XXX O@##@OOOooo+. .", +"X++++. O@ XX..XX.O@@Ooo++++X.+++", +"+++XX @#Oo+XXX....oOoo+..XX...X+", +"XX.X. Ooo++++...XX++++XX++++++++", +"X. .X+++++XXX...XXXXXXXXX+X+++X", +".XX...XXX.X.. .X+++++X.X.....X.", +"XX..XXXXXXXX.....XX++XXXXX..XXXX" +}; diff --git a/assets/exit.xpm b/assets/exit.xpm new file mode 100644 index 0000000..8b735d7 --- /dev/null +++ b/assets/exit.xpm @@ -0,0 +1,215 @@ +/* XPM */ +static char *xpm_[] = { +/* columns rows colors chars-per-pixel */ +"32 32 177 2 ", +" c #051003", +". c #0B110B", +"X c #0C1B0C", +"o c #10110D", +"O c #130E12", +"+ c #170F1A", +"@ c #0E1214", +"# c #0E1C11", +"$ c #0E1018", +"% c #141214", +"& c #141C14", +"* c #1B1D16", +"= c #171218", +"- c #1B141A", +"; c #1D1B1C", +": c #161518", +"> c #350F04", +", c #3D140D", +"< c #33120F", +"1 c #200E1D", +"2 c #2F1118", +"3 c #201D1E", +"4 c #23121E", +"5 c #3D1414", +"6 c #331019", +"7 c #3B1219", +"8 c #1E211E", +"9 c #161720", +"0 c #1D1C22", +"q c #1F1625", +"w c #231C23", +"e c #221628", +"r c #271C29", +"t c #281C2A", +"y c #391426", +"u c #3B172A", +"i c #3D1A27", +"p c #2A1C36", +"a c #2A1C3A", +"s c #301F37", +"d c #3F1933", +"f c #3A153E", +"g c #3F1B38", +"h c #36163C", +"j c #1E2224", +"k c #1C2D24", +"l c #212121", +"z c #2A2226", +"x c #20212A", +"c c #2B232C", +"v c #2B282D", +"b c #312C2E", +"n c #29322E", +"m c #2B2234", +"M c #252830", +"N c #262039", +"B c #2A2038", +"V c #2B2735", +"C c #322632", +"Z c #322C32", +"A c #382D34", +"S c #353134", +"D c #303933", +"F c #3A353D", +"G c #36343B", +"H c #431416", +"J c #5F1C14", +"K c #5C1E1D", +"L c #631E15", +"P c #5E201D", +"I c #6E2416", +"U c #63221A", +"Y c #6D241A", +"T c #69291E", +"R c #4C1B26", +"E c #4F1729", +"W c #471E29", +"Q c #4C1C2D", +"! c #511E28", +"~ c #5B1D22", +"^ c #541E3F", +"/ c #601F25", +"( c #4B242D", +") c #57232D", +"_ c #5C252B", +"` c #5D292E", +"' c #4D2536", +"] c #612126", +"[ c #6B2322", +"{ c #662927", +"} c #642629", +"| c #652A2A", +" . c #6B2A29", +".. c #712523", +"X. c #712E28", +"o. c #72302B", +"O. c #6F2638", +"+. c #602B3D", +"@. c #72263C", +"#. c #2A1D40", +"$. c #3C1641", +"%. c #322748", +"&. c #3A3442", +"*. c #3D3A44", +"=. c #3D354C", +"-. c #3B3350", +";. c #421645", +":. c #4E1F56", +">. c #521A5E", +",. c #413C46", +"<. c #5B2859", +"1. c #602259", +"2. c #6B245F", +"3. c #6A2547", +"4. c #401E6E", +"5. c #581764", +"6. c #561C64", +"7. c #5E1469", +"8. c #5B1D6B", +"9. c #641B6E", +"0. c #61166D", +"q. c #621673", +"w. c #701D77", +"e. c #731C7C", +"r. c #4C2D73", +"t. c #502D72", +"y. c #533075", +"u. c #65286C", +"i. c #684040", +"p. c #534969", +"a. c #5D5668", +"s. c #665D68", +"d. c #665F70", +"f. c #686868", +"g. c #6C6367", +"h. c #706B6D", +"j. c #656071", +"k. c #6D6676", +"l. c #6C6877", +"z. c #6D6778", +"x. c #747474", +"c. c #7F7F7F", +"v. c #83247D", +"b. c #7E1E8E", +"n. c #583685", +"m. c #7F288D", +"M. c #783BBF", +"N. c #787383", +"B. c #6045B5", +"V. c #7047B5", +"C. c #6752C2", +"Z. c #7051D1", +"A. c #7E57EC", +"S. c #7861E2", +"D. c #811E92", +"F. c #871D9B", +"G. c #812091", +"H. c #8B219A", +"J. c #9B2895", +"K. c #AC3092", +"L. c #B23294", +"P. c #9A24AA", +"I. c #9F26B4", +"U. c #A227A1", +"Y. c #CE38AB", +"T. c #D438AF", +"R. c #D13AA7", +"E. c #827487", +"W. c #8A35D6", +"Q. c #B728C5", +"!. c #BC29C9", +"~. c #BD27D2", +"^. c #C227CE", +"/. c #C428D5", +"(. c #C92AD5", +"). c gray56", +"_. c gray56", +/* pixels */ +").).).).).).).).c.x.x.x.c.x.c.c.c.x.f.f.x.f.x.x.c.).).c.x.x.c.c.", +"c.).).).c.).c.c.c.c.x.x.x.c.c.c.x.x.x.f.f.x.x.c.c.c.c.c.c.c.c.c.", +"c.c.x.x.x.x.c.x.x.x.c.c.c.x.x.c.z F p.).).c.f.f.x.f.f.x.c.x.x.x.", +").c.c.c.x.c.c.c.x.x.x.c.x.x.v c b z S =.p.c.c.x.f.f.x.c.x.x.c.).", +"c.c.x.x.f.f.f.f.x.x.x.x.v b b Z S G m - %.x.x.c.c.c.c.c.c.x.x.c.", +").).c.x.x.f.f.x.f.f.0 c A Z C F Z r ; ; z A -.c.x.x.c.c.c.c.c.c.", +"c.x.x.x.c.c.x.x.x.c.O + w G V w ; 3 w w c C b #.d.c.x.f.f.x.x.c.", +"x.c.).).).).).).c.c.% % O ; w ; w w w w m c * p N.c.c.x.x.c.c.x.", +"x.x.x.x.c.).).x.f.f.= % % ; w w * * e % * w ; a z.).).x.x.x.c.c.", +"c.x.c.c.c.c.c.x.x.x.- O O * & & p 5.f . ; w 3 B k.c.x.x.c.c.c.c.", +"c.).).).).c.x.x.c.Z F C % X h H.F.e.f . ; w ; B a.f.x.f.f.x.).).", +"c.c.).).c.c.c.z b S C F D 6./.(.D.7.$. ; l ; B a.x.x.x.x.x.x.c.", +"x.x.x.c.x.c.,.O q Z F c # 9./.Q.b.9.;. ; w * p z.c.c.c.c.c.c.c.", +"c.x.x.x.x.x.F o O = r ; X 8.^.Q.b.7.$.. ; w ; B l.c.).).).x.x.c.", +"x.x.x.x.f.f.&.% % % w w X 9./.!.D.9.f . ; w ; m j.x.x.x.c.c.c.x.", +"c.c.c.x.x.f.&.% = - w w X 9.~.P.w.0.f ; l ; B d.c.c.c.c.c.c.c.", +"c.c.x.x.c.c.*.% O % 8 3 & >.U.L.v.q.$. ; w ; a d.x.c.x.x.x.x.c.", +"c.).).).).).,.% % % w l # 1.Y.R.v.7.;.. ; w ; N k.c.c.c.x.x.c.c.", +"c.c.c.).).c.,.% % % w w X 2.T.K.e.q.h . ; 0 - a E.c.c.).).c.c.c.", +"c.c.).).).).*.% % - w w # <.J.G.P.m.s . : w W | +.).).).x.x.x.x.", +"x.f.x.c.c.c.&.% % % j w & :.I.H.<.v M C W | .{ T | ' x.x.f.x.c.", +"c.c.c.c.x.i.- % % % w l & :.u.n k v Q } .| { | ` _ ~ O.c.c.c.x.", +"c.c.c.i T o.4 % % % w w ; x j v ( } | | | | ` ) / [ ] @.x.c.).).", +"c.c.c.> 7 R - $ % - w 0 9 t ( } | | | | ` ) ] [ [ [ U 3.x.x.x.c.", +"x.c.x., 5 5 6 1 $ @ 0 w W } | | | | ` ) ] [ [ [ Y I J V.f.f.x.x.", +"c.c.c., 5 5 H H 2 + i .X.| | | ` ) ] [ [ [ [ I L E 4.A.x.f.f.x.", +"c.).).y 5 , 5 5 H H 7 R _ | ` ) ] [ [ [ [ Y L E y.S.c.c.x.).).).", +").).).x.d y 5 , 5 5 5 7 6 ! ] [ [ [ [ I L E 6.W.x.c.c.x.x.x.c.).", +"c.c.x.c.x.h.g u 5 , 5 5 5 K ..[ [ Y U E r.B.c.c.).).).).).).).).", +"c.x.f.f.x.c.x.g.d u 5 , 5 P ..Y U Q t.Z.c.c.c.c.c.c.).c.).).).c.", +"x.c.c.x.x.x.c.c.c.s.d u < J U E 8.M.).).).).c.x.c.x.x.x.x.x.c.x.", +"c.c.x.x.c.c.c.c.c.c.c.c.^ Q n.C.x.c.c.).).c.c.c.c.c.x.x.c.c.c.c." +}; diff --git a/assets/floor.xpm b/assets/floor.xpm new file mode 100755 index 0000000..57341d2 --- /dev/null +++ b/assets/floor.xpm @@ -0,0 +1,42 @@ +/* XPM */ +static char *ea534f601fc548b8ddbc80a1baa83d2dTHcmw34tLSzWZjDk[] = { +/* columns rows colors chars-per-pixel */ +"32 32 4 1 ", +" c #686868", +". c #747474", +"X c gray50", +"o c gray56", +/* pixels */ +"ooooooooX...X.XXX. . ..XooX..XX", +"XoooXoXXXX...XXX... ..XXXXXXXXX", +"XX....X...XXX..XooXooX . .X...", +"oXXX.XXX...X..XX.X..XXX. .X..Xo", +"XX.. ..... .....XXXXXX..X", +"ooX.. . .XX. ....X.XXX..XXXXXX", +"X...XX...XXXXXXoooooXXX..X. ..X", +".XooooooXXooX..XXooXXXoooXX..XX.", +"....Xoo. ..XX..XXoooooXXoo...XX", +"X.XXXXX...XX..XXXooXXoooXX..XXXX", +"XooooX..XXXXXX..XX....X. . .oo", +"XXooXXXXXXX....XX.. . ......X", +"...X.XoooooX.Xooooo.....XXXXXXXX", +"X.......ooX...XoX... .XXXooo..X", +".... . .XX...X..XX.....XXX.", +"XXX.. . ........XXXX.....XXXXXXX", +"XX..XXX..X..XoooooooX.XX..X....X", +"XoooooXXoooXXXoooXX....XXXXX..XX", +"XXXooXX..X.XooXXooXX.XoooXXooXXX", +"XXooooXXXXX..XooXXXX...XXooo....", +". .XXXXX... . ..X..XXX..X.. .X", +"XXXX...XX.XX. ..XXXXXooooooXXX.", +"XXX..XXXXXoooooXooXXXXXXooX..Xoo", +"XXXXXXXXXooooXXXXX..X....XXX...X", +".X..X...XXoXXX.. .XXX. . ..", +"XXX. .XooooXXX..XXX..X. .... .", +"Xoooo.X...XX..XX...ooXXX..XX.ooo", +"oooXXX...XXXXX....XXX....XX...Xo", +"XX.X..XXooooo...XX..XXXXoooooooo", +"X. .X..XooXXX...XXXXXXXXXoXoooX", +".XX...XXX.X.. .XoooooX.X.....X.", +"XX..XXXXXXXX.....XXooXXXXX..XXXX" +}; diff --git a/assets/player.xpm b/assets/player.xpm new file mode 100755 index 0000000..48f9d91 --- /dev/null +++ b/assets/player.xpm @@ -0,0 +1,216 @@ +/* XPM */ +static char *_472f46639e945e19be1c36ef31d5cc9[] = { +/* columns rows colors chars-per-pixel */ +"32 32 178 2 ", +" c #3C2205", +". c #3E3519", +"X c #1D3233", +"o c #343529", +"O c #222F36", +"+ c #293737", +"@ c #481A00", +"# c #571A01", +"$ c #462A0D", +"% c #492C0F", +"& c #5E2201", +"* c #532606", +"= c #4D2F12", +"- c #402C11", +"; c #4C3013", +": c #42391E", +"> c #453215", +", c #523619", +"< c #5D3C1D", +"1 c #56391B", +"2 c #602402", +"3 c #622B0A", +"4 c #662804", +"5 c #762E09", +"6 c #72270B", +"7 c #7D350E", +"8 c #703614", +"9 c #713C1D", +"0 c #6A3615", +"q c #453D21", +"w c #593E21", +"e c #5D4023", +"r c #5E4A35", +"t c #4F5037", +"y c #644325", +"u c #674A2B", +"i c #6A4D2E", +"p c #654728", +"a c #604C36", +"s c #6B4E30", +"d c #634F3A", +"f c #7A4E35", +"g c #6C5032", +"h c #63503A", +"j c #725335", +"k c #735639", +"l c #7C5438", +"z c #76593B", +"x c #7E5535", +"c c #7B4B2D", +"v c #053A52", +"b c #2D4142", +"n c #314546", +"m c #36494A", +"M c #394C4D", +"N c #144B66", +"B c #1E5E7F", +"V c #22546D", +"C c #295E76", +"Z c #2B5F78", +"A c #265B73", +"S c #006869", +"D c #2D6079", +"F c #435758", +"G c #54585B", +"H c #685540", +"J c #7C5F41", +"K c #715B48", +"L c #7E6143", +"P c #76624D", +"I c #7D6456", +"U c #596B6C", +"Y c #686868", +"T c #747474", +"R c gray50", +"E c #737564", +"W c #843C17", +"Q c #884825", +"! c #944B24", +"~ c #99542D", +"^ c #825939", +"/ c #80563E", +"( c #985A36", +") c #A15932", +"_ c #AD663E", +"` c #8F5F43", +"' c #816446", +"] c #846749", +"[ c #85684A", +"{ c #8D6A51", +"} c #A66942", +"| c #AB6942", +" . c #AC7049", +".. c #A77453", +"X. c #AA7A57", +"o. c #B97A55", +"O. c #B46D4A", +"+. c #867462", +"@. c #A57F6B", +"#. c #7F827C", +"$. c #C3845E", +"%. c #C98962", +"&. c #C88A65", +"*. c #D58F69", +"=. c #D3926C", +"-. c #DB9369", +";. c #DE9B74", +":. c #DE9E79", +">. c #D79770", +",. c #E0A07F", +"<. c #004E80", +"1. c #055B8E", +"2. c #046283", +"3. c #12699D", +"4. c #1F76AA", +"5. c #2177AC", +"6. c #257AAD", +"7. c #277DB2", +"8. c #7C53BF", +"9. c #6441C8", +"0. c #7C6AE3", +"q. c #AE7BAF", +"w. c #B37FAF", +"e. c #9176D6", +"r. c #008E89", +"t. c #019C9D", +"y. c #029696", +"u. c #06928B", +"i. c #0C87AE", +"p. c #158AAF", +"a. c #09B0AB", +"s. c #6D8283", +"d. c #28AAD2", +"f. c #0FCAC6", +"g. c #10CBC7", +"h. c #10CCC9", +"j. c #15D3D0", +"k. c #3CC5EE", +"l. c #43CDF5", +"z. c gray56", +"x. c #899E9E", +"c. c #929D9E", +"v. c #BD94BB", +"b. c #B882A8", +"n. c #93A3A3", +"m. c #ECAB85", +"M. c #F4AA80", +"N. c #E9B38D", +"B. c #FFBA8E", +"V. c #EFB299", +"C. c #FBB792", +"Z. c #F7B995", +"A. c #FBBA95", +"S. c #F3B59A", +"D. c #F7BC9A", +"F. c #F8BC9F", +"G. c #D59CA1", +"H. c #FBC38F", +"J. c #FFC294", +"K. c #FDC39D", +"L. c #FFCA93", +"P. c #FFCBA5", +"I. c #FFC6A0", +"U. c #FFD3AD", +"Y. c #FEDBBB", +"T. c #AFC3C4", +"R. c #B6CACB", +"E. c #BDD1D2", +"W. c #C1D6D7", +"Q. c #C9DCDD", +"!. c #E0C0C6", +"~. c #FBDFC9", +"^. c #FFEED4", +"/. c #FFF6DD", +"(. c #CEC5EA", +"). c #C7C7FA", +"_. c #FDF9EF", +"`. c #FFFFFE", +/* pixels */ +"z.z.z.z.z.z.z.z.R T T T R T R R R T Y Y T Y T T R z.z.R T T R R ", +"R z.z.z.R z.R R R R T T T R R R T T T Y Y T T R R R R R R R R R ", +"R R T T T T R T T T R R R T T R z.z.R z.z.R Y Y T Y Y T R T T T ", +"z.R R R T R R R T T T R T T R R T R T T R R R T Y Y T R T T R z.", +"R R T T Y Y Y Y T T T T T Y Y Y Y Y T T T T T R R R R R R T T R ", +"z.z.R T T Y Y T Y Y T R R T Y T T T T R T R R R T T R R R R R R ", +"R T T T R R T T T R R R R R R z.z.z.z.z.R R R T T R T Y Y T T R ", +"T R z.z.z.z.+.H r a h h a r r r r h h r r r h d K +.P T T R R T ", +"T T T T R z.w u u u u u u u u s s s i s s i i i p e w T T T R R ", +"R T R R R R % z ] ' ' ' ' ] J s g g g g g g s g y % < T R R R R ", +"R z.z.z.z.R ; k L J L L L J s < < < < < < < < < 1 = 0 Y Y T z.z.", +"R R z.z.R R = k ' J J J ] 1 x K.Z.A.A.A.A.Z.Z.K.=.& 8 T T T T R ", +"T T T R T R = k L L ] [ , { N.A.C.J.J.A.A.J.B.K.>.2 8 R R R R R ", +"R T T T T T ; k ] k 1 w X.P.Z.~.v.G.J.S.w.!.Y.=.2 8 z.z.T T R ", +"T T T T Y Y = z k j ^ ^ $ ..K.D.`.0.q.L.S.9.)./.*.2 8 T R R R T ", +"R R R T T Y = z , ^ P.K.y X.K.D._.e.b.H.V.8.(.^.*.2 8 R R R R R ", +"R R T T R R ; % ^ A.%.o.:.A.C.D.F.,.%.=.S.D.K.=.2 8 T T T T R ", +"R z.z.z.z.z.3 } o.&.:.=.*.m.P.I.P.%.} } } .m.U.:.2 8 R T T R R ", +"R R R z.z.R 4 ! ( ~ ! ! ! ) _ _ | W 5 7 7 5 ~ .~ & 9 z.z.R R R ", +"R R z.z.z.z.3 & # * q : : . . . . : q q q q - @ # 9 / z.T T T T ", +"T Y T R R R R l 6 t y.y.y.t.t.t.t.t.t.t.t.t.S o Q T R T T Y T R ", +"R R R R T T K ..m.$.> u.r.a.h.f.g.g.g.g.f.j.S E ;.I [ z.R R R T ", +"R R R T T R & o.K.-.* p.i.d.l.k.k.k.k.k.k.l.2.#.M.# f T T R z.z.", +"R R R R R R ( ( O.` O 1.1.3.5.4.7.6.5.4.4.6.<.G _ f @.R T T T R ", +"T R T T R T T f # o B V D D Z C v N A Z C D N + c Y Y T Y Y T T ", +"R R R T Y Y T R z.F n.x.R.W.W.R.b s.T.W.E.Q.U + Y T T T T Y Y T ", +"R z.z.z.z.T R T T + n n m m m m + b m m m M X U T T R R T z.z.z.", +"z.z.z.R R R T T T M M M m m m m M M m m m m F c.T R R T T T R z.", +"R R T R T T R R z.z.z.z.z.T T T R R T T R R R R z.z.z.z.z.z.z.z.", +"R T Y Y T R T T R z.z.R R R T T T R R R R R R R R R z.R z.z.z.R ", +"T R R T T T R R R T R T T Y Y T R z.z.z.z.z.R T R T T T T T R T ", +"R R T T R R R R R R R R T T T T T R R z.z.R R R R R T T R R R R " +}; diff --git a/assets/wall.xpm b/assets/wall.xpm new file mode 100644 index 0000000..53b6267 --- /dev/null +++ b/assets/wall.xpm @@ -0,0 +1,43 @@ +/* XPM */ +static char *result[] = { +/* columns rows colors chars-per-pixel */ +"32 32 5 1 ", +" c #222222", +". c gray20", +"X c gray34", +"o c gray39", +"O c #979797", +/* pixels */ +"XX..XX.XXXXXoooXXXXXXX.........X", +"X.........XoooooXOOOO....XX..XOO", +"...XooOOoOOoOO...oOOooooX. .XX..", +"..XooOOoXXoOOoX...oOOoXX. .XX.", +"X.... XX....XOOX.....XXoOOoXXXX", +". . .... ..XOOX.XXXXXoOOoOOo", +"XXX...XXX .oOOXXXX..........XX", +"XoooOOooXX. XXoXXXOOoX.....XOXXX", +"...OOo... ...XXXX..XoooX...X...", +"X. .OOXX...XOX.......ooooXooX.X", +"..XXooX......XXX. XXXXOOo.. ..", +"XoooOOXo..XooX.... .OOOo..... ", +"oooooooXXoXXooXooXXooooOOooOO X", +"oOoOOXXoooooOOooXX..XXooooOO....", +"OOOXXX.OOXOOOoXX... ..XXX..XXXX", +"XooX....XXXXOO. . .XXXooXXooXX", +"oooOOXX......XXXXoooOOooooOOOOXo", +"OOOOoooX...XXXXoOOoOOooXXOOOoooo", +"oXX... ....XooXXOOoX.....oOOOOo", +"X... . .XX..XX..XXXXXX...ooooo", +".ooOOo..XXoOOo.. ..oooOOooX....", +"oOOOo....oOOXXX .XXXOOOooooXX..", +" .OOX.. . .XXOOOOoXXXXoOOOOoo.", +"..XXXXXX. .XXoooOoooXXoOOOOoX..", +"XXX...XXOX.XX...OOOo...XX....XXX", +"XX......XXXX......XoX......XXXoo", +"ooOOoXXX. .X...XX... .XXooOOXO", +"oOOoXOOoOX ..XXX. . ...XXXoOOO", +"ooXXX.....XXX......XoOOooX.....X", +"XoooXXX..XXX....XXoOOoOOooX..XXX", +"OOX.... .oOOOX...Xooo. .....XX", +". . . .oOOooOOXXOooooX ..XXoo" +}; diff --git a/ft_printf_fd/Makefile b/ft_printf_fd/Makefile new file mode 100644 index 0000000..88b4bb7 --- /dev/null +++ b/ft_printf_fd/Makefile @@ -0,0 +1,61 @@ +# **************************************************************************** # +# # +# ::: :::::::: # +# Makefile :+: :+: :+: # +# +:+ +:+ +:+ # +# By: lfirmin lfirmim@student.42.fr> +#+ +:+ +#+ # +# +#+#+#+#+#+ +#+ # +# Created: 2024/08/12 07:07:31 by lfirmin #+# #+# # +# Updated: 2024/08/12 09:15:05 by lfirmin ### ########.fr # +# # +# **************************************************************************** # + +NAME = libftprintf.a +HEADER = ./ +SRC = ft_putchar.c ft_put_ptr.c ft_conv_ith.c ft_hex_len.c \ + ft_sorting.c ft_printf.c ft_print_ith.c ft_printchar.c \ + ft_printstr.c ft_printpercent.c ft_print_unsigned.c \ + ft_print_nbr.c ft_print_ptr.c ft_adrr_len.c ft_print_null.c \ + ft_itoa.c ft_unsigned_itoa.c ft_count.c + +CC = cc +CFLAGS = -Wall -Wextra -Werror +INCLUDE = -I $(HEADER) +OBJ_DIR = obj/ +OBJ = $(addprefix $(OBJ_DIR), $(SRC:.c=.o)) + + +GREEN = \033[0;32m +YELLOW = \033[0;33m +RESET = \033[0m +WHITE = \033[0;97m + +LOADING_CHARS = ⠋ ⠙ ⠹ ⠸ ⠼ ⠴ ⠦ ⠧ ⠇ ⠏ + +all: $(NAME) + +$(NAME): $(OBJ) + @printf "$(YELLOW)Compiling ft_printf, Please wait...$(RESET)" + @for char in $(LOADING_CHARS); do \ + printf "\r$(YELLOW)Compiling ft_print, Please wait... $$char$(RESET)"; \ + sleep 0.1; \ + done + @ar rc $(NAME) $(OBJ)`` + @ranlib $(NAME) + @printf "\r$(GREEN)Great news ! $(WHITE)ft_printf compiled successfully ! $(RESET)\n" + +$(OBJ_DIR)%.o: %.c + @mkdir -p $(OBJ_DIR) + @$(CC) $(CFLAGS) $(INCLUDE) -c $< -o $@ + +clean: + @rm -rf $(OBJ_DIR) + @printf "$(WHITE)Clean process completed for $(GREEN)Ft_printf.$(RESET)\n" + +fclean: clean + @rm -f $(NAME) + @printf "$(WHITE)Full clean process completed for $(GREEN)Ft_printf.$(RESET)\n" + +re: fclean all + +.PHONY: all clean fclean re diff --git a/ft_printf_fd/Readme.md b/ft_printf_fd/Readme.md new file mode 100644 index 0000000..887ac1b --- /dev/null +++ b/ft_printf_fd/Readme.md @@ -0,0 +1,48 @@ +# ft_printf_fd + +Your own implementation of the printf function with file descriptor support. + +## 💡 About +The ft_printf_fd project is an extension of ft_printf that allows writing to any file descriptor. You will learn about file descriptors, variadic arguments and formatted output conversion. This project enhances the original printf functionality by adding the ability to choose the output destination. + +## 🛠️ Supported Conversions +The function handles the following conversions: +* `%c` - Single character +* `%s` - String +* `%p` - Pointer address +* `%d` - Decimal (base 10) integer +* `%i` - Integer in base 10 +* `%u` - Unsigned decimal (base 10) integer +* `%x` - Hexadecimal (base 16) integer lowercase +* `%X` - Hexadecimal (base 16) integer uppercase +* `%%` - Percentage sign + +## 📋 Usage +```c +#include "ft_printf_fd.h" + +int main(void) +{ + // Write to stdout (fd 1) + ft_printf_fd(1, "Hello %s!\n", "world"); + + // Write to stderr (fd 2) + ft_printf_fd(2, "Error: %d\n", 42); + + // Write to a file + int fd = open("output.txt", O_WRONLY | O_CREAT, 0644); + ft_printf_fd(fd, "Number: %d\n", 42); + close(fd); + + return (0); +} +``` + +## ⚠️ Function Prototype +```c +int ft_printf_fd(int fd, const char *format, ...); +``` +Returns the number of characters printed (excluding the null byte used to end output to strings). + +## 📊 Expected Output +The function should work exactly like the original printf, handling all the specified conversions correctly, but writing to the specified file descriptor instead of stdout. \ No newline at end of file diff --git a/ft_printf_fd/ft_adrr_len.c b/ft_printf_fd/ft_adrr_len.c new file mode 100644 index 0000000..47b4153 --- /dev/null +++ b/ft_printf_fd/ft_adrr_len.c @@ -0,0 +1,27 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_adrr_len.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lfirmin +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/06/19 05:16:57 by lfirmin #+# #+# */ +/* Updated: 2024/06/19 07:50:34 by lfirmin ### ########.fr */ +/* */ +/* ************************************************************************** */ +#include "ftprintf.h" + +int ft_adrr_len(unsigned long long nbr) +{ + int i; + + if (nbr == 0) + return (1); + i = 0; + while (nbr != 0) + { + i++; + nbr = nbr / 16; + } + return (i); +} diff --git a/ft_printf_fd/ft_conv_ith.c b/ft_printf_fd/ft_conv_ith.c new file mode 100644 index 0000000..472574b --- /dev/null +++ b/ft_printf_fd/ft_conv_ith.c @@ -0,0 +1,30 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_conv_ith.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lfirmin +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/06/19 04:46:47 by lfirmin #+# #+# */ +/* Updated: 2024/06/19 07:46:23 by lfirmin ### ########.fr */ +/* */ +/* ************************************************************************** */ +#include "ftprintf.h" + +void ft_conv_ith(int fd, unsigned int nbr, const char str) +{ + if (nbr >= 16) + { + ft_conv_ith(fd, (nbr / 16), str); + nbr = nbr % 16; + } + if (nbr <= 9) + ft_putchar(fd, nbr + '0'); + else + { + if (str == 'x') + ft_putchar(fd, nbr - 10 + 'a'); + else if (str == 'X') + ft_putchar(fd, nbr - 10 + 'A'); + } +} diff --git a/ft_printf_fd/ft_count.c b/ft_printf_fd/ft_count.c new file mode 100644 index 0000000..24e6e21 --- /dev/null +++ b/ft_printf_fd/ft_count.c @@ -0,0 +1,27 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_count.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lfirmin +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/06/19 04:52:36 by lfirmin #+# #+# */ +/* Updated: 2024/06/19 07:47:07 by lfirmin ### ########.fr */ +/* */ +/* ************************************************************************** */ +#include "ftprintf.h" + +size_t ft_count(long long int n) +{ + size_t c; + + c = 0; + if (n <= 0) + c = 1; + while (n != 0) + { + n = n / 10; + c++; + } + return (c); +} diff --git a/ft_printf_fd/ft_hex_len.c b/ft_printf_fd/ft_hex_len.c new file mode 100644 index 0000000..29baa8b --- /dev/null +++ b/ft_printf_fd/ft_hex_len.c @@ -0,0 +1,27 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_hex_len.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lfirmin +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/06/19 04:45:50 by lfirmin #+# #+# */ +/* Updated: 2024/06/19 07:49:59 by lfirmin ### ########.fr */ +/* */ +/* ************************************************************************** */ +#include "ftprintf.h" + +int ft_hex_len(unsigned int nbr) +{ + int i; + + if (nbr == 0) + return (1); + i = 0; + while (nbr != 0) + { + i++; + nbr = nbr / 16; + } + return (i); +} diff --git a/ft_printf_fd/ft_itoa.c b/ft_printf_fd/ft_itoa.c new file mode 100644 index 0000000..138ed77 --- /dev/null +++ b/ft_printf_fd/ft_itoa.c @@ -0,0 +1,36 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_itoa.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lfirmin +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/06/19 04:51:58 by lfirmin #+# #+# */ +/* Updated: 2024/06/19 04:53:33 by lfirmin ### ########.fr */ +/* */ +/* ************************************************************************** */ +#include "ftprintf.h" + +char *ft_itoa(int n) +{ + char *str; + size_t size; + long int num; + + num = n; + size = ft_count(num); + str = (char *)malloc(size + 1); + if (!str) + return (NULL); + str[size] = '\0'; + if (num < 0) + num = -num; + while (size--) + { + str[size] = num % 10 + '0'; + num = num / 10; + if (n < 0 && size == 0) + str[size] = '-'; + } + return (str); +} diff --git a/ft_printf_fd/ft_print_ith.c b/ft_printf_fd/ft_print_ith.c new file mode 100644 index 0000000..e94502e --- /dev/null +++ b/ft_printf_fd/ft_print_ith.c @@ -0,0 +1,20 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_print_ith.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lfirmin +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/06/19 04:44:27 by lfirmin #+# #+# */ +/* Updated: 2024/06/19 04:49:51 by lfirmin ### ########.fr */ +/* */ +/* ************************************************************************** */ +#include "ftprintf.h" + +int ft_print_ith(int fd, unsigned int nbr, const char str) +{ + if (nbr == 0) + return (write(fd, "0", 1)); + ft_conv_ith(fd, nbr, str); + return (ft_hex_len(nbr)); +} diff --git a/ft_printf_fd/ft_print_nbr.c b/ft_printf_fd/ft_print_nbr.c new file mode 100644 index 0000000..b83098e --- /dev/null +++ b/ft_printf_fd/ft_print_nbr.c @@ -0,0 +1,23 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_print_nbr.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lfirmin +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/06/19 04:44:27 by lfirmin #+# #+# */ +/* Updated: 2024/06/19 04:52:47 by lfirmin ### ########.fr */ +/* */ +/* ************************************************************************** */ +#include "ftprintf.h" + +int ft_print_nbr(int fd, int nb) +{ + int len; + char *str; + + str = ft_itoa(nb); + len = ft_printstr(fd, str); + free (str); + return (len); +} diff --git a/ft_printf_fd/ft_print_null.c b/ft_printf_fd/ft_print_null.c new file mode 100644 index 0000000..e596cd1 --- /dev/null +++ b/ft_printf_fd/ft_print_null.c @@ -0,0 +1,18 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_print_null.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lfirmin +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/06/19 07:01:50 by lfirmin #+# #+# */ +/* Updated: 2024/06/19 07:46:39 by lfirmin ### ########.fr */ +/* */ +/* ************************************************************************** */ +#include "ftprintf.h" + +int ft_print_null(int fd) +{ + write(fd, "(null)", 6); + return (6); +} diff --git a/ft_printf_fd/ft_print_ptr.c b/ft_printf_fd/ft_print_ptr.c new file mode 100644 index 0000000..3d68c29 --- /dev/null +++ b/ft_printf_fd/ft_print_ptr.c @@ -0,0 +1,30 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_print_ptr.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lfirmin +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/06/19 04:44:27 by lfirmin #+# #+# */ +/* Updated: 2024/06/19 07:51:10 by lfirmin ### ########.fr */ +/* */ +/* ************************************************************************** */ +#include "ftprintf.h" + +int ft_print_ptr(int fd, unsigned long long ptr) +{ + int print_length; + + if (ptr == 0) + { + write(fd, "(nil)", 5); + return (5); + } + print_length = 2; + write(fd, "0x", 2); + { + ft_put_ptr(fd, ptr); + print_length = print_length + ft_adrr_len(ptr); + } + return (print_length); +} diff --git a/ft_printf_fd/ft_print_unsigned.c b/ft_printf_fd/ft_print_unsigned.c new file mode 100644 index 0000000..28c81f3 --- /dev/null +++ b/ft_printf_fd/ft_print_unsigned.c @@ -0,0 +1,23 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_print_unsigned.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lfirmin +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/06/19 04:50:53 by lfirmin #+# #+# */ +/* Updated: 2024/06/19 07:51:31 by lfirmin ### ########.fr */ +/* */ +/* ************************************************************************** */ +#include "ftprintf.h" + +int ft_print_unsigned(int fd, unsigned int nb) +{ + int len; + char *str; + + str = ft_unsigned_itoa(nb); + len = ft_printstr(fd, str); + free (str); + return (len); +} diff --git a/ft_printf_fd/ft_printchar.c b/ft_printf_fd/ft_printchar.c new file mode 100644 index 0000000..02180e7 --- /dev/null +++ b/ft_printf_fd/ft_printchar.c @@ -0,0 +1,18 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_printchar.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lfirmin +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/06/19 04:56:02 by lfirmin #+# #+# */ +/* Updated: 2024/06/19 04:56:25 by lfirmin ### ########.fr */ +/* */ +/* ************************************************************************** */ +#include "ftprintf.h" + +int ft_printchar(int fd, int c) +{ + write (fd, &c, 1); + return (1); +} diff --git a/ft_printf_fd/ft_printf.c b/ft_printf_fd/ft_printf.c new file mode 100644 index 0000000..033dc54 --- /dev/null +++ b/ft_printf_fd/ft_printf.c @@ -0,0 +1,39 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_printf.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lfirmin +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/06/19 04:44:27 by lfirmin #+# #+# */ +/* Updated: 2024/06/19 04:55:41 by lfirmin ### ########.fr */ +/* */ +/* ************************************************************************** */ +#include "ftprintf.h" + +int ft_printf_fd(int fd, const char *str, ...) +{ + int i; + va_list list; + int count; + + i = 0; + count = 0; + va_start(list, str); + while (str[i]) + { + if (str[i] == '%') + { + count += ft_sorting(list, str[i + 1], fd); + i++; + } + else + { + write (fd, &str[i], 1); + count++; + } + i++; + } + va_end(list); + return (count); +} diff --git a/ft_printf_fd/ft_printpercent.c b/ft_printf_fd/ft_printpercent.c new file mode 100644 index 0000000..eccd4c8 --- /dev/null +++ b/ft_printf_fd/ft_printpercent.c @@ -0,0 +1,18 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_printpercent.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lfirmin +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/06/19 04:47:38 by lfirmin #+# #+# */ +/* Updated: 2024/06/19 07:50:08 by lfirmin ### ########.fr */ +/* */ +/* ************************************************************************** */ +#include "ftprintf.h" + +int ft_printpercent(int fd) +{ + ft_putchar(fd, '%'); + return (1); +} diff --git a/ft_printf_fd/ft_printstr.c b/ft_printf_fd/ft_printstr.c new file mode 100644 index 0000000..7b8b4ca --- /dev/null +++ b/ft_printf_fd/ft_printstr.c @@ -0,0 +1,27 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_printstr.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lfirmin +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/06/19 04:55:08 by lfirmin #+# #+# */ +/* Updated: 2024/06/19 07:46:05 by lfirmin ### ########.fr */ +/* */ +/* ************************************************************************** */ +#include "ftprintf.h" + +int ft_printstr(int fd, char *s) +{ + int i; + + if (!s) + return (ft_print_null(fd)); + i = 0; + while (s[i]) + { + write (fd, &s[i], 1); + i++; + } + return (i); +} diff --git a/ft_printf_fd/ft_put_ptr.c b/ft_printf_fd/ft_put_ptr.c new file mode 100644 index 0000000..bcc1954 --- /dev/null +++ b/ft_printf_fd/ft_put_ptr.c @@ -0,0 +1,28 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_put_ptr.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lfirmin +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/06/19 04:54:06 by lfirmin #+# #+# */ +/* Updated: 2024/06/19 07:46:52 by lfirmin ### ########.fr */ +/* */ +/* ************************************************************************** */ +#include "ftprintf.h" + +void ft_put_ptr(int fd, unsigned long long num) +{ + if (num >= 16) + { + ft_put_ptr(fd, num / 16); + ft_put_ptr(fd, num % 16); + } + else + { + if (num <= 9) + ft_putchar(fd, num + '0'); + else + ft_putchar(fd, num - 10 + 'a'); + } +} diff --git a/ft_printf_fd/ft_putchar.c b/ft_printf_fd/ft_putchar.c new file mode 100644 index 0000000..4c68cdd --- /dev/null +++ b/ft_printf_fd/ft_putchar.c @@ -0,0 +1,17 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_putchar.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lfirmin +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/06/19 04:45:04 by lfirmin #+# #+# */ +/* Updated: 2024/06/19 04:49:11 by lfirmin ### ########.fr */ +/* */ +/* ************************************************************************** */ +#include "ftprintf.h" + +void ft_putchar(int fd, char c) +{ + write(fd, &c, 1); +} diff --git a/ft_printf_fd/ft_sorting.c b/ft_printf_fd/ft_sorting.c new file mode 100644 index 0000000..4d456de --- /dev/null +++ b/ft_printf_fd/ft_sorting.c @@ -0,0 +1,34 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_sorting.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lfirmin +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/06/19 04:56:45 by lfirmin #+# #+# */ +/* Updated: 2024/06/19 07:51:17 by lfirmin ### ########.fr */ +/* */ +/* ************************************************************************** */ +#include "ftprintf.h" + +int ft_sorting(va_list list, const char str, int fd) +{ + int count; + + count = 0; + if (str == 'c') + count += ft_printchar(fd, va_arg(list, int)); + else if (str == 's') + count += ft_printstr(fd, va_arg(list, char *)); + else if (str == 'p') + count += ft_print_ptr(fd, va_arg(list, unsigned long long)); + else if (str == 'd' || str == 'i') + count += ft_print_nbr(fd, va_arg(list, int)); + else if (str == 'u') + count += ft_print_unsigned(fd, va_arg(list, unsigned int)); + else if (str == 'x' || str == 'X') + count += ft_print_ith(fd, va_arg(list, unsigned int), str); + else if (str == '%') + count += ft_printpercent(fd); + return (count); +} diff --git a/ft_printf_fd/ft_unsigned_itoa.c b/ft_printf_fd/ft_unsigned_itoa.c new file mode 100644 index 0000000..5b897cf --- /dev/null +++ b/ft_printf_fd/ft_unsigned_itoa.c @@ -0,0 +1,34 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_unsigned_itoa.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lfirmin +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/06/19 04:51:27 by lfirmin #+# #+# */ +/* Updated: 2024/06/19 07:45:46 by lfirmin ### ########.fr */ +/* */ +/* ************************************************************************** */ +#include "ftprintf.h" + +char *ft_unsigned_itoa(unsigned int n) +{ + char *str; + size_t size; + long int num; + + num = n; + size = ft_count(num); + str = (char *)malloc(size + 1); + if (!str) + return (NULL); + str[size] = '\0'; + if (num < 0) + num = -num; + while (size--) + { + str[size] = num % 10 + '0'; + num = num / 10; + } + return (str); +} diff --git a/ft_printf_fd/ftprintf.h b/ft_printf_fd/ftprintf.h new file mode 100644 index 0000000..d4dac01 --- /dev/null +++ b/ft_printf_fd/ftprintf.h @@ -0,0 +1,43 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ftprintf.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lfirmin +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/06/19 04:44:27 by lfirmin #+# #+# */ +/* Updated: 2024/06/19 07:49:08 by lfirmin ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef FTPRINTF_H +# define FTPRINTF_H + +# include +# include +# include +# include "stdlib.h" + +void ft_putchar(int fd, char c); +void ft_put_ptr(int fd, unsigned long long num); +void ft_conv_ith(int fd, unsigned int nbr, const char str); + +int ft_hex_len(unsigned int nbr); +int ft_sorting(va_list list, const char str, int fd); +int ft_printf_fd(int fd, const char *str, ...); +int ft_print_ith(int fd, unsigned int nbr, const char str); +int ft_printchar(int fd, int c); +int ft_printstr(int fd, char *s); +int ft_printpercent(int fd); +int ft_print_unsigned(int fd, unsigned int nb); +int ft_print_nbr(int fd, int nb); +int ft_print_ptr(int fd, unsigned long long ptr); +int ft_adrr_len(unsigned long long nbr); +int ft_print_null(int fd); + +char *ft_itoa(int n); +char *ft_unsigned_itoa(unsigned int n); + +size_t ft_count(long long int n); + +#endif \ No newline at end of file diff --git a/gnl/Makefile b/gnl/Makefile new file mode 100644 index 0000000..baedc93 --- /dev/null +++ b/gnl/Makefile @@ -0,0 +1,61 @@ +# **************************************************************************** # +# # +# ::: :::::::: # +# Makefile :+: :+: :+: # +# +:+ +:+ +:+ # +# By: lfirmin lfirmim@student.42.fr> +#+ +:+ +#+ # +# +#+#+#+#+#+ +#+ # +# Created: 2024/08/12 07:07:31 by lfirmin #+# #+# # +# Updated: 2024/08/12 09:15:05 by lfirmin ### ########.fr # +# # +# **************************************************************************** # + +NAME = gnl.a +SRCS_DIR = srcs/ +INCS_DIR = includes/ +OBJ_DIR = obj/ + +SRC = get_next_line.c get_next_line_utils.c + +CC = cc +CFLAGS = -Wall -Wextra -Werror +INCLUDE = -I $(INCS_DIR) +SRCS = $(addprefix $(SRCS_DIR), $(SRC)) +OBJ = $(addprefix $(OBJ_DIR), $(SRC:.c=.o)) + +# Colors +GREEN = \033[0;32m +YELLOW = \033[0;33m +RESET = \033[0m +WHITE = \033[0;97m + +# Loading animation +LOADING_CHARS = ⠋ ⠙ ⠹ ⠸ ⠼ ⠴ ⠦ ⠧ ⠇ ⠏ + +all: $(NAME) + +$(NAME): $(OBJ) + @printf "$(YELLOW)Compiling get_next_line, Please wait...$(RESET)" + @for char in $(LOADING_CHARS); do \ + printf "\r$(YELLOW)Compiling get_next_line, Please wait... $$char$(RESET)"; \ + sleep 0.1; \ + done + @ar rc $(NAME) $(OBJ) + @ranlib $(NAME) + @printf "\r$(GREEN)fine ! $(WHITE)get_next_line compiled successfully ! $(RESET)\n" + +$(OBJ_DIR)%.o: $(SRCS_DIR)%.c + @mkdir -p $(OBJ_DIR) + @$(CC) $(CFLAGS) $(INCLUDE) -c $< -o $@ + +clean: + @rm -rf $(OBJ_DIR) + @printf "$(WHITE)Clean process completed for $(GREEN)get_next_line.$(RESET)\n" + +fclean: clean + @rm -f $(NAME) + @printf "$(WHITE)Full clean process completed for $(GREEN)get_next_line.$(RESET)\n" + +re: fclean all + +.PHONY: all clean fclean re diff --git a/gnl/include/get_next_line.h b/gnl/include/get_next_line.h new file mode 100644 index 0000000..2450971 --- /dev/null +++ b/gnl/include/get_next_line.h @@ -0,0 +1,32 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* get_next_line.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: abelghou +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/07/21 19:32:47 by abelghou #+# #+# */ +/* Updated: 2024/07/23 20:47:15 by abelghou ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef GET_NEXT_LINE_H +# define GET_NEXT_LINE_H + +# ifndef BUFFER_SIZE +# define BUFFER_SIZE 10 +# endif + +# include +# include +# include +# include + +char *ft_substr(char const *s, unsigned int start, size_t len); +int ft_strlen_g(const char *str); +char *ft_strchr(const char *s, int i); +char *ft_strdup_g(const char *s); +char *ft_strjoin(char const *s1, char const *s2); +char *get_next_line(int fd); + +#endif \ No newline at end of file diff --git a/gnl/readme.md b/gnl/readme.md new file mode 100644 index 0000000..8e0d256 --- /dev/null +++ b/gnl/readme.md @@ -0,0 +1,41 @@ +# get_next_line + +A function that reads a line from a file descriptor. + +## 💡 About +The get_next_line project is a programming function that reads a line ending with a newline character from a file descriptor. When calling the function in a loop, it will then allow you to read the text file pointed to by the file descriptor, one line at a time until the end of the file. + +## 🛠️ Function Prototype +```c +char *get_next_line(int fd); +``` +## 📋 Usage +```c +#include "get_next_line.h" +#include + +int main(void) +{ + int fd; + char *line; + + fd = open("test.txt", O_RDONLY); + while ((line = get_next_line(fd)) != NULL) + { + printf("%s", line); + free(line); + } + close(fd); + return (0); +} +``` + +## ⚠️ Return Value +* The line that was read when successful +* NULL if there is nothing else to read or if an error occurred + +## 📊 Expected Behavior +* Repeated calls to get_next_line() should let you read the text file pointed to by the file descriptor, one line at a time +* The function should return the line that was read +* If there is nothing else to read or if an error occurred, it should return NULL +* The returned line should include the terminating \n character, except if the end of file was reached and does not end with a \n character \ No newline at end of file diff --git a/gnl/srcs/get_next_line.c b/gnl/srcs/get_next_line.c new file mode 100644 index 0000000..2cab0b6 --- /dev/null +++ b/gnl/srcs/get_next_line.c @@ -0,0 +1,102 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* get_next_line.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: abelghou +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/07/17 21:31:24 by abelghou #+# #+# */ +/* Updated: 2024/07/24 18:17:55 by abelghou ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "../include/get_next_line.h" + +static char *sort_and_store(int fd, char *buf, char *backup) +{ + int read_line; + char *char_temp; + + read_line = 1; + while (read_line != 0) + { + read_line = read(fd, buf, BUFFER_SIZE); + if (read_line == -1) + return (0); + else if (read_line == 0) + break ; + buf[read_line] = '\0'; + if (!backup) + backup = ft_strdup_g(""); + if (!backup) + return (NULL); + char_temp = backup; + backup = ft_strjoin(char_temp, buf); + free(char_temp); + char_temp = NULL; + if (ft_strchr (buf, '\n')) + break ; + } + return (backup); +} + +static char *extract(char *line) +{ + size_t count; + char *backup; + + count = 0; + while (line[count] != '\n' && line[count] != '\0') + count++; + if (line[count] == '\0' || line[1] == '\0') + return (0); + backup = ft_substr(line, count + 1, ft_strlen_g(line) - count); + if (!backup) + return (NULL); + if (*backup == '\0') + { + free (backup); + backup = NULL; + } + line[count + 1] = '\0'; + return (backup); +} + +char *get_next_line(int fd) +{ + char *line; + char *buf; + char *temp; + static char *backup; + + if (fd < 0 || BUFFER_SIZE <= 0) + return (free(backup), backup = NULL, NULL); + buf = (char *)malloc(sizeof(char) * (BUFFER_SIZE + 1)); + if (!buf) + return (free(backup), backup = NULL, NULL); + line = sort_and_store(fd, buf, backup); + free(buf); + buf = NULL; + if (!line) + return (free(backup), backup = NULL, NULL); + backup = extract(line); + temp = ft_strdup_g(line); + free(line); + if (!temp) + return (free(backup), backup = NULL, NULL); + return (temp); +} + +// int main() +// { +// int fd; +// char *line; +// fd = open("fd.txt", O_RDONLY); +// while((line = get_next_line(fd)) != NULL) +// { +// printf("%s", line); +// free(line); +// } +// line = get_next_line(fd); +// close(fd); +// } \ No newline at end of file diff --git a/gnl/srcs/get_next_line_utils.c b/gnl/srcs/get_next_line_utils.c new file mode 100644 index 0000000..6e3cd9c --- /dev/null +++ b/gnl/srcs/get_next_line_utils.c @@ -0,0 +1,106 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* get_next_line_utils.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: abelghou +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/07/21 19:34:18 by abelghou #+# #+# */ +/* Updated: 2024/07/23 20:06:41 by abelghou ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "../include/get_next_line.h" + +char *ft_substr(char const *s, unsigned int start, size_t len) +{ + size_t i; + size_t j; + char *str; + + str = (char *)malloc(sizeof(*s) * (len + 1)); + if (str == 0) + return (NULL); + i = 0; + j = 0; + while (s[i]) + { + if (i >= start && j < len) + { + str[j] = s[i]; + j++; + } + i++; + } + str[j] = '\0'; + return (str); +} + +int ft_strlen_g(const char *str) +{ + int i; + + i = 0; + while (str[i]) + i++; + return (i); +} + +char *ft_strchr(const char *s, int i) +{ + while (*s) + { + if (*s == i) + return ((char *)s); + s++; + } + if (i == '\0') + return ((char *)s); + return (0); +} + +char *ft_strdup_g(const char *s) +{ + int i; + int j; + char *str; + + i = 0; + j = ft_strlen_g(s); + str = (char *)malloc(sizeof(*str) * (j + 1)); + if (!str) + return (NULL); + while (i < j) + { + str[i] = s[i]; + i++; + } + str[i] = '\0'; + return (str); +} + +char *ft_strjoin(char const *s1, char const *s2) +{ + int i; + int j; + char *str; + + i = 0; + j = 0; + str = (char *)malloc(sizeof(char) * (ft_strlen_g(s1) \ + + ft_strlen_g(s2) + 1)); + if (str == NULL) + return (NULL); + while (s1[i] != '\0') + { + str[i] = s1[i]; + i++; + } + while (s2[j] != '\0') + { + str[i + j] = s2[j]; + j++; + } + str[i + j] = '\0'; + return (str); +} diff --git a/include/so_long.h b/include/so_long.h new file mode 100644 index 0000000..d7abe0b --- /dev/null +++ b/include/so_long.h @@ -0,0 +1,108 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* so_long.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lfirmin +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/11/12 11:00:04 by lfirmin #+# #+# */ +/* Updated: 2024/11/17 13:53:20 by lfirmin ### ########.fr */ +/* */ +/* ************************************************************************** */ + +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* so_long.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lfirmin +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/03/17 10:00:00 by lfirmin #+# #+# */ +/* Updated: 2024/03/17 10:00:00 by lfirmin ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef SO_LONG_H +# define SO_LONG_H + +# define KEY_ESC 65307 +# define KEY_W 119 +# define KEY_A 97 +# define KEY_S 115 +# define KEY_D 100 +# define KEY_UP 65362 +# define KEY_LEFT 65361 +# define KEY_DOWN 65364 +# define KEY_RIGHT 65363 + +# include "../minilibx-linux/mlx.h" +# include "../gnl/include/get_next_line.h" +# include "../libft/libft.h" +# include "../ft_printf_fd/ftprintf.h" +# include + +typedef struct s_data +{ + char **map; + int colect; + int e; + int p; +} t_data; + +typedef struct s_game +{ + void *mlx; + void *win; + void *img_floor; + void *img_wall; + void *img_player; + void *img_collect; + void *img_exit; + int player_x; + int player_y; + int moves; + int collectibles; + char **map; + int map_width; + int map_height; + int exit_x; + int exit_y; + t_data *data; +} t_game; + +/* Utils functions */ +t_data *init_data(void); +void clean_data(t_data *data); +int init_game(t_game *game); +int find_player_pos(t_game *game); +void draw_map(t_game *game); +int close_game(t_game *game); +void move_player(t_game *game, int new_x, int new_y); +int is_valid_move(t_game *game, int x, int y); +int key_hook(int keycode, t_game *game); +void find_exit_pos(t_game *game); +void draw_tile(t_game *game, char current, int x, int y); +int init_images(t_game *game); +int init_window(t_game *game); +int check_player(t_game *game, int x, int y, int *found); +void init_struct(t_game *game); + +/* Map parsing functions */ +int get_map(char *filename, t_data *data); +int ft_count_lines(char *file); +int check_close(t_data *data); +int check_rectangle(t_data *data); +int check_playable(t_data *data); +char **copy_map(char **original); +int play_check(char **map, int x, int y); +void free_map(char **map); +int is_playable(t_data *data, int x, int y); +int check_first_last_lines(t_data *data, int i); +int pars_map(t_data *data, char *file); +int have_require_item(t_data *data); +char *add_newline_if_needed(char *line); +int check_char(t_data *data); +int is_ber(char *file); +int get_map_2(int i, int nb_lines, t_data *data, int fd); /* in utils_4 */ + +#endif \ No newline at end of file diff --git a/libft/Makefile b/libft/Makefile new file mode 100644 index 0000000..2112db1 --- /dev/null +++ b/libft/Makefile @@ -0,0 +1,65 @@ +# **************************************************************************** # +# # +# ::: :::::::: # +# makefile :+: :+: :+: # +# +:+ +:+ +:+ # +# By: lfirmin +#+ +:+ +#+ # +# +#+#+#+#+#+ +#+ # +# Created: 2024/05/19 12:59:31 by lfirmin #+# #+# # +# Updated: 2024/05/22 15:18:38 by lfirmin ### ########.fr # +# # +# **************************************************************************** # + +NAME = libft.a +HEADER = ./ +SRC = ft_isalnum.c ft_isprint.c ft_memcmp.c ft_putchar_fd.c ft_split.c \ + ft_strlcat.c ft_strncmp.c ft_substr.c ft_atoi.c ft_isalpha.c \ + ft_itoa.c ft_memcpy.c ft_putendl_fd.c ft_strchr.c ft_strlcpy.c \ + ft_strnstr.c ft_tolower.c ft_bzero.c ft_isascii.c ft_strtrim.c \ + ft_memmove.c ft_putnbr_fd.c ft_strdup.c ft_strlen.c ft_strrchr.c \ + ft_toupper.c ft_calloc.c ft_isdigit.c ft_memchr.c ft_memset.c \ + ft_putstr_fd.c ft_strjoin.c ft_strmapi.c ft_striteri.c \ + ft_lstnew_bonus.c ft_lstadd_front_bonus.c ft_lstsize_bonus.c \ + ft_lstlast_bonus.c ft_lstadd_back_bonus.c ft_lstdelone_bonus.c \ + ft_lstclear_bonus.c ft_lstiter_bonus.c ft_lstmap_bonus.c ft_strcmp.c \ + ft_atoll.c ft_print_array.c ft_strcat.c +CC = cc +CFLAGS = -Wall -Wextra -Werror -g3 +INCLUDE = -I $(HEADER) +OBJ_DIR = obj/ +OBJ = $(addprefix $(OBJ_DIR), $(SRC:.c=.o)) + +GREEN = \033[0;32m +YELLOW = \033[0;33m +RESET = \033[0m +WHITE = \033[0;97m + +LOADING_CHARS = ⠋ ⠙ ⠹ ⠸ ⠼ ⠴ ⠦ ⠧ ⠇ ⠏ + +all: $(NAME) + +$(NAME): $(OBJ) + @printf "$(YELLOW)Compiling libft, Please wait...$(RESET)" + @for char in $(LOADING_CHARS); do \ + printf "\r$(YELLOW)Compiling libft, Please wait... $$char$(RESET)"; \ + sleep 0.1; \ + done + @ar rc $(NAME) $(OBJ) + @ranlib $(NAME) + @printf "\r$(GREEN)Great news ! $(WHITE)Libft compiled successfully ! $(RESET)\n" + +$(OBJ_DIR)%.o: %.c + @mkdir -p $(OBJ_DIR) + @$(CC) $(CFLAGS) $(INCLUDE) -c $< -o $@ + +clean: + @rm -rf $(OBJ_DIR) + @printf "$(WHITE)Clean process completed for $(GREEN)Libft.$(RESET)\n" + +fclean: clean + @rm -f $(NAME) + @printf "$(WHITE)Full clean process completed for $(GREEN)Libft.$(RESET)\n" + +re: fclean all + +.PHONY: all clean fclean re \ No newline at end of file diff --git a/libft/ft_atoi.c b/libft/ft_atoi.c new file mode 100644 index 0000000..a05a597 --- /dev/null +++ b/libft/ft_atoi.c @@ -0,0 +1,40 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_atoi.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lfirmin +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/05/21 10:09:46 by lfirmin #+# #+# */ +/* Updated: 2024/06/03 21:02:02 by lfirmin ### ########.fr */ +/* */ +/* ************************************************************************** */ +#include "libft.h" + +int ft_atoi(const char *str) +{ + int i; + int s; + int m; + + i = 0; + s = 0; + m = 0; + while ((str[i] <= 13 && str[i] >= 9) || str[i] == 32) + i++; + while (str[i] == '-' || str[i] == '+') + { + s++; + if (s >= 2) + return (0); + if (str[i] == '-') + m++; + i++; + } + s = 0; + while (str[i] >= 48 && str[i] <= 57) + s = s * 10 + (str[i++] - 48); + if (m % 2 == 1) + s = s * -1; + return (s); +} diff --git a/libft/ft_atoll.c b/libft/ft_atoll.c new file mode 100644 index 0000000..34fd5a5 --- /dev/null +++ b/libft/ft_atoll.c @@ -0,0 +1,38 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_atoll.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lfirmin +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/11/03 17:25:06 by lfirmin #+# #+# */ +/* Updated: 2024/11/03 17:25:33 by lfirmin ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +long long ft_atoll(const char *str) +{ + long long result; + int sign; + + result = 0; + sign = 1; + while (*str == ' ' || (*str >= 9 && *str <= 13)) + str++; + if (*str == '-' || *str == '+') + { + if (*str == '-') + sign = -1; + str++; + } + while (*str >= '0' && *str <= '9') + { + if (result > INT_MAX || result < INT_MIN) + return (2147483648); + result = result * 10 + (*str - '0'); + str++; + } + return (result * sign); +} diff --git a/libft/ft_bzero.c b/libft/ft_bzero.c new file mode 100644 index 0000000..507f22d --- /dev/null +++ b/libft/ft_bzero.c @@ -0,0 +1,24 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_bzero.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lfirmin +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/05/21 00:20:00 by lfirmin #+# #+# */ +/* Updated: 2024/05/30 19:49:23 by lfirmin ### ########.fr */ +/* */ +/* ************************************************************************** */ +#include "libft.h" + +void *ft_bzero(void *b, size_t len) +{ + size_t i; + unsigned char *r; + + r = (unsigned char *)b; + i = 0; + while (i < len) + r[i++] = '\0'; + return (b); +} diff --git a/libft/ft_calloc.c b/libft/ft_calloc.c new file mode 100644 index 0000000..b42206a --- /dev/null +++ b/libft/ft_calloc.c @@ -0,0 +1,31 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_calloc.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lfirmin +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/05/21 11:14:02 by lfirmin #+# #+# */ +/* Updated: 2024/06/03 18:15:05 by lfirmin ### ########.fr */ +/* */ +/* ************************************************************************** */ +#include "libft.h" + +void *ft_calloc(size_t c, size_t s) +{ + void *ptr; + long long int tmp1; + long long int tmp2; + + tmp1 = (long long int)c; + tmp2 = (long long int)s; + if ((c > 4294967295 || s > 4294967295) && (tmp1 < 0 && tmp2 < 0)) + return (NULL); + if (tmp1 * tmp2 < 0) + return (NULL); + ptr = malloc(c * s); + if (!ptr) + return (NULL); + ft_bzero(ptr, c * s); + return (ptr); +} diff --git a/libft/ft_isalnum.c b/libft/ft_isalnum.c new file mode 100644 index 0000000..0fd48a2 --- /dev/null +++ b/libft/ft_isalnum.c @@ -0,0 +1,19 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_isalnum.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lfirmin +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/05/20 02:29:49 by lfirmin #+# #+# */ +/* Updated: 2024/05/22 09:59:44 by lfirmin ### ########.fr */ +/* */ +/* ************************************************************************** */ +#include "libft.h" + +int ft_isalnum(int c) +{ + if ((c >= 97 && c <= 122) || (c >= 48 && c <= 57) || (c >= 65 && c <= 90)) + return (1); + return (0); +} diff --git a/libft/ft_isalpha.c b/libft/ft_isalpha.c new file mode 100644 index 0000000..3382c40 --- /dev/null +++ b/libft/ft_isalpha.c @@ -0,0 +1,19 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_isalpha.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lfirmin +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/05/20 01:55:52 by lfirmin #+# #+# */ +/* Updated: 2024/05/22 09:59:44 by lfirmin ### ########.fr */ +/* */ +/* ************************************************************************** */ +#include "libft.h" + +int ft_isalpha(int c) +{ + if ((c >= 97 && c <= 122) || (c >= 65 && c <= 90)) + return (1); + return (0); +} diff --git a/libft/ft_isascii.c b/libft/ft_isascii.c new file mode 100644 index 0000000..c5d9e0b --- /dev/null +++ b/libft/ft_isascii.c @@ -0,0 +1,19 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_isascii.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lfirmin +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/05/20 02:36:17 by lfirmin #+# #+# */ +/* Updated: 2024/05/22 09:59:44 by lfirmin ### ########.fr */ +/* */ +/* ************************************************************************** */ +#include "libft.h" + +int ft_isascii(int c) +{ + if (c >= 0 && c <= 127) + return (1); + return (0); +} diff --git a/libft/ft_isdigit.c b/libft/ft_isdigit.c new file mode 100644 index 0000000..78f90b9 --- /dev/null +++ b/libft/ft_isdigit.c @@ -0,0 +1,19 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_isdigit.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lfirmin +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/05/20 02:31:51 by lfirmin #+# #+# */ +/* Updated: 2024/05/22 09:59:44 by lfirmin ### ########.fr */ +/* */ +/* ************************************************************************** */ +#include "libft.h" + +int ft_isdigit(int c) +{ + if (c >= 48 && c <= 57) + return (1); + return (0); +} diff --git a/libft/ft_isprint.c b/libft/ft_isprint.c new file mode 100644 index 0000000..2a09bb2 --- /dev/null +++ b/libft/ft_isprint.c @@ -0,0 +1,19 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_isprint.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lfirmin +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/05/20 02:38:24 by lfirmin #+# #+# */ +/* Updated: 2024/05/23 06:21:54 by lfirmin ### ########.fr */ +/* */ +/* ************************************************************************** */ +#include "libft.h" + +int ft_isprint(int c) +{ + if (((c >= 0 && c <= 31) || c >= 127 || c == EOF)) + return (0); + return (1); +} diff --git a/libft/ft_itoa.c b/libft/ft_itoa.c new file mode 100644 index 0000000..eade559 --- /dev/null +++ b/libft/ft_itoa.c @@ -0,0 +1,51 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_itoa.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lfirmin +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/05/24 12:59:00 by lfirmin #+# #+# */ +/* Updated: 2024/05/29 10:31:36 by lfirmin ### ########.fr */ +/* */ +/* ************************************************************************** */ +#include "libft.h" + +static size_t ft_count(long int n) +{ + size_t c; + + c = 0; + if (n <= 0) + c = 1; + while (n != 0) + { + n = n / 10; + c++; + } + return (c); +} + +char *ft_itoa(int n) +{ + char *str; + size_t size; + long int num; + + num = n; + size = ft_count(num); + str = (char *)malloc(size + 1); + if (!str) + return (NULL); + str[size] = '\0'; + if (num < 0) + num = -num; + while (size--) + { + str[size] = num % 10 + '0'; + num = num / 10; + if (n < 0 && size == 0) + str[size] = '-'; + } + return (str); +} diff --git a/libft/ft_lstadd_back_bonus.c b/libft/ft_lstadd_back_bonus.c new file mode 100644 index 0000000..2bfdfc7 --- /dev/null +++ b/libft/ft_lstadd_back_bonus.c @@ -0,0 +1,27 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_lstadd_back.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lfirmin +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/06/01 02:01:18 by lfirmin #+# #+# */ +/* Updated: 2024/06/03 15:59:33 by lfirmin ### ########.fr */ +/* */ +/* ************************************************************************** */ +#include "libft.h" + +void ft_lstadd_back(t_list **lst, t_list *new) +{ + t_list *last; + + if (!new) + return ; + if (!lst || !*lst) + { + *lst = new; + return ; + } + last = ft_lstlast(*lst); + last->next = new; +} diff --git a/libft/ft_lstadd_front_bonus.c b/libft/ft_lstadd_front_bonus.c new file mode 100644 index 0000000..b784622 --- /dev/null +++ b/libft/ft_lstadd_front_bonus.c @@ -0,0 +1,21 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_lstadd_front.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lfirmin +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/05/31 20:34:57 by lfirmin #+# #+# */ +/* Updated: 2024/05/31 20:41:34 by lfirmin ### ########.fr */ +/* */ +/* ************************************************************************** */ +#include "libft.h" + +void ft_lstadd_front(t_list **lst, t_list *new) +{ + if (lst && new) + { + new->next = *lst; + *lst = new; + } +} diff --git a/libft/ft_lstclear_bonus.c b/libft/ft_lstclear_bonus.c new file mode 100644 index 0000000..54479d1 --- /dev/null +++ b/libft/ft_lstclear_bonus.c @@ -0,0 +1,28 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_lstclear.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lfirmin +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/06/01 20:46:07 by lfirmin #+# #+# */ +/* Updated: 2024/06/01 20:51:07 by lfirmin ### ########.fr */ +/* */ +/* ************************************************************************** */ +#include "libft.h" + +void ft_lstclear(t_list **lst, void (*del)(void*)) +{ + t_list *t; + + if (lst) + { + while (*lst) + { + t = (*lst)->next; + ft_lstdelone(*lst, del); + (*lst) = t; + } + (*lst) = NULL; + } +} diff --git a/libft/ft_lstdelone_bonus.c b/libft/ft_lstdelone_bonus.c new file mode 100644 index 0000000..94ae5ab --- /dev/null +++ b/libft/ft_lstdelone_bonus.c @@ -0,0 +1,20 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_lstdelone.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lfirmin +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/06/01 20:32:56 by lfirmin #+# #+# */ +/* Updated: 2024/06/01 20:32:56 by lfirmin ### ########.fr */ +/* */ +/* ************************************************************************** */ +#include "libft.h" + +void ft_lstdelone(t_list *lst, void (*del)(void*)) +{ + if (!lst || !del) + return ; + del(lst->content); + free(lst); +} diff --git a/libft/ft_lstiter_bonus.c b/libft/ft_lstiter_bonus.c new file mode 100644 index 0000000..8870692 --- /dev/null +++ b/libft/ft_lstiter_bonus.c @@ -0,0 +1,23 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_lstiter.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lfirmin +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/06/01 21:05:12 by lfirmin #+# #+# */ +/* Updated: 2024/06/01 21:05:12 by lfirmin ### ########.fr */ +/* */ +/* ************************************************************************** */ +#include "libft.h" + +void ft_lstiter(t_list *lst, void (*f)(void *)) +{ + if (!lst || !f) + return ; + while (lst) + { + f(lst->content); + lst = lst->next; + } +} diff --git a/libft/ft_lstlast_bonus.c b/libft/ft_lstlast_bonus.c new file mode 100644 index 0000000..c00582b --- /dev/null +++ b/libft/ft_lstlast_bonus.c @@ -0,0 +1,23 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_lstlast.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lfirmin +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/06/01 01:52:09 by lfirmin #+# #+# */ +/* Updated: 2024/06/01 01:57:22 by lfirmin ### ########.fr */ +/* */ +/* ************************************************************************** */ +#include "libft.h" + +t_list *ft_lstlast(t_list *lst) +{ + while (lst) + { + if (!lst->next) + return (lst); + lst = lst->next; + } + return (lst); +} diff --git a/libft/ft_lstmap_bonus.c b/libft/ft_lstmap_bonus.c new file mode 100644 index 0000000..7efc366 --- /dev/null +++ b/libft/ft_lstmap_bonus.c @@ -0,0 +1,41 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_lstmap.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lfirmin +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/06/02 18:21:09 by lfirmin #+# #+# */ +/* Updated: 2024/06/03 15:53:13 by lfirmin ### ########.fr */ +/* */ +/* ************************************************************************** */ +#include "libft.h" + +t_list *ft_lstmap(t_list *lst, void *(*f)(void *), void (*del)(void *)) +{ + t_list *new; + t_list *save; + + if (!lst || !del || !f) + return (NULL); + new = ft_lstnew(lst->content); + if (!new) + return (NULL); + new->content = f(new->content); + save = new; + lst = lst->next; + while (lst) + { + new->next = ft_lstnew(lst->content); + if (!new->next) + { + ft_lstclear(&save, del); + return (NULL); + } + new->next->content = f(new->next->content); + new = new->next; + lst = lst->next; + } + new->next = NULL; + return (save); +} diff --git a/libft/ft_lstnew_bonus.c b/libft/ft_lstnew_bonus.c new file mode 100644 index 0000000..d9a9ba7 --- /dev/null +++ b/libft/ft_lstnew_bonus.c @@ -0,0 +1,24 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_lstnew.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lfirmin +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/05/31 18:41:23 by lfirmin #+# #+# */ +/* Updated: 2024/05/31 20:33:26 by lfirmin ### ########.fr */ +/* */ +/* ************************************************************************** */ +#include "libft.h" + +t_list *ft_lstnew(void *content) +{ + t_list *new; + + new = (t_list *)malloc(sizeof(*new)); + if (!new) + return (NULL); + new->content = content; + new->next = NULL; + return (new); +} diff --git a/libft/ft_lstsize_bonus.c b/libft/ft_lstsize_bonus.c new file mode 100644 index 0000000..d68e15d --- /dev/null +++ b/libft/ft_lstsize_bonus.c @@ -0,0 +1,27 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_lstsize.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lfirmin +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/05/31 22:00:49 by lfirmin #+# #+# */ +/* Updated: 2024/05/31 22:12:17 by lfirmin ### ########.fr */ +/* */ +/* ************************************************************************** */ +#include "libft.h" + +int ft_lstsize(t_list *lst) +{ + int i; + t_list *count; + + count = lst; + i = 0; + while (count) + { + count = count->next; + i++; + } + return (i); +} diff --git a/libft/ft_memchr.c b/libft/ft_memchr.c new file mode 100644 index 0000000..4272249 --- /dev/null +++ b/libft/ft_memchr.c @@ -0,0 +1,26 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_memchr.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lfirmin +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/05/21 07:40:39 by lfirmin #+# #+# */ +/* Updated: 2024/05/22 09:59:44 by lfirmin ### ########.fr */ +/* */ +/* ************************************************************************** */ +#include "libft.h" + +void *ft_memchr(const void *s, int c, size_t n) +{ + unsigned char *str; + + str = (unsigned char *)s; + while (n--) + { + if (*str == (unsigned char)c) + return (str); + str++; + } + return (NULL); +} diff --git a/libft/ft_memcmp.c b/libft/ft_memcmp.c new file mode 100644 index 0000000..fc9d739 --- /dev/null +++ b/libft/ft_memcmp.c @@ -0,0 +1,30 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_memcmp.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lfirmin +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/05/21 07:57:58 by lfirmin #+# #+# */ +/* Updated: 2024/05/22 11:34:35 by lfirmin ### ########.fr */ +/* */ +/* ************************************************************************** */ +#include "libft.h" + +int ft_memcmp(const void *ptr1, const void *ptr2, size_t num) +{ + unsigned char *pt1; + unsigned char *pt2; + size_t i; + + pt1 = (unsigned char *)ptr1; + pt2 = (unsigned char *)ptr2; + i = 0; + while (i < num) + { + if (pt1[i] != pt2[i]) + return (pt1[i] - pt2[i]); + i++; + } + return (0); +} diff --git a/libft/ft_memcpy.c b/libft/ft_memcpy.c new file mode 100644 index 0000000..fdfb104 --- /dev/null +++ b/libft/ft_memcpy.c @@ -0,0 +1,31 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_memcpy.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lfirmin +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/05/21 01:08:31 by lfirmin #+# #+# */ +/* Updated: 2024/05/30 18:46:00 by lfirmin ### ########.fr */ +/* */ +/* ************************************************************************** */ +#include "libft.h" + +void *ft_memcpy(void *dest, const void *src, size_t len) +{ + size_t i; + unsigned char *r; + unsigned char *s; + + i = 0; + r = (unsigned char *)dest; + s = (unsigned char *)src; + if (dest == (void *)0 && src == (void *)0) + return (dest); + while (i < len) + { + r[i] = s[i]; + i++; + } + return (dest); +} diff --git a/libft/ft_memmove.c b/libft/ft_memmove.c new file mode 100644 index 0000000..8920c37 --- /dev/null +++ b/libft/ft_memmove.c @@ -0,0 +1,39 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_memmov.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lfirmin +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/05/21 01:26:13 by lfirmin #+# #+# */ +/* Updated: 2024/05/22 09:59:44 by lfirmin ### ########.fr */ +/* */ +/* ************************************************************************** */ +#include "libft.h" + +void *ft_memmove(void *s1, const void *s2, size_t len) +{ + unsigned char *dest; + unsigned char *src; + unsigned int i; + + dest = (unsigned char *)s1; + src = (unsigned char *)s2; + i = 0; + if (dest == NULL && src == NULL) + return (NULL); + if (dest < src) + { + while (i < len) + { + dest[i] = src[i]; + i++; + } + } + else + { + while (0 < len--) + dest[len] = src[len]; + } + return (dest); +} diff --git a/libft/ft_memset.c b/libft/ft_memset.c new file mode 100644 index 0000000..d4ecdb0 --- /dev/null +++ b/libft/ft_memset.c @@ -0,0 +1,24 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_memset.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lfirmin +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/05/20 02:42:40 by lfirmin #+# #+# */ +/* Updated: 2024/05/22 09:59:44 by lfirmin ### ########.fr */ +/* */ +/* ************************************************************************** */ +#include "libft.h" + +void *ft_memset(void *b, int c, size_t len) +{ + size_t i; + unsigned char *r; + + i = 0; + r = (unsigned char *)b; + while (i < len) + r[i++] = (unsigned char)c; + return (b); +} diff --git a/libft/ft_print_array.c b/libft/ft_print_array.c new file mode 100644 index 0000000..f2d8309 --- /dev/null +++ b/libft/ft_print_array.c @@ -0,0 +1,39 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_print_array.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lfirmin +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/11/05 02:29:54 by lfirmin #+# #+# */ +/* Updated: 2024/11/05 02:29:54 by lfirmin ### ########.fr */ +/* */ +/* ************************************************************************** */ +#include "libft.h" + +void put_str(char *str) +{ + if (!str) + return ; + while (*str) + write(1, str++, 1); +} + +void ft_print_str_array(char **array) +{ + int i; + + if (array == NULL) + { + put_str("Tableau invalide\n"); + return ; + } + i = 0; + put_str("Contenu du tableau:\n"); + while (array[i]) + { + put_str(array[i]); + write(1, "\n", 1); + i++; + } +} diff --git a/libft/ft_putchar_fd.c b/libft/ft_putchar_fd.c new file mode 100644 index 0000000..8a930f9 --- /dev/null +++ b/libft/ft_putchar_fd.c @@ -0,0 +1,17 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_putchar_fd.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lfirmin +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/05/29 11:17:45 by lfirmin #+# #+# */ +/* Updated: 2024/05/29 11:20:42 by lfirmin ### ########.fr */ +/* */ +/* ************************************************************************** */ +#include "libft.h" + +void ft_putchar_fd(char c, int fd) +{ + write(fd, &c, 1); +} diff --git a/libft/ft_putendl_fd.c b/libft/ft_putendl_fd.c new file mode 100644 index 0000000..c2e3e97 --- /dev/null +++ b/libft/ft_putendl_fd.c @@ -0,0 +1,18 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_putendl_fd.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lfirmin +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/05/29 11:35:44 by lfirmin #+# #+# */ +/* Updated: 2024/05/29 11:38:36 by lfirmin ### ########.fr */ +/* */ +/* ************************************************************************** */ +#include "libft.h" + +void ft_putendl_fd(char *s, int fd) +{ + ft_putstr_fd(s, fd); + ft_putchar_fd('\n', fd); +} diff --git a/libft/ft_putnbr_fd.c b/libft/ft_putnbr_fd.c new file mode 100644 index 0000000..0b02ab1 --- /dev/null +++ b/libft/ft_putnbr_fd.c @@ -0,0 +1,31 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_putnbr_fd.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lfirmin +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/05/29 11:42:38 by lfirmin #+# #+# */ +/* Updated: 2024/05/29 11:56:04 by lfirmin ### ########.fr */ +/* */ +/* ************************************************************************** */ +#include "libft.h" + +void ft_putnbr_fd(int n, int fd) +{ + long int nb; + + nb = n; + if (nb < 0) + { + nb = -nb; + ft_putchar_fd('-', fd); + } + if (nb >= 10) + { + ft_putnbr_fd(nb / 10, fd); + ft_putnbr_fd(nb % 10, fd); + } + else + ft_putchar_fd(nb + '0', fd); +} diff --git a/libft/ft_putstr_fd.c b/libft/ft_putstr_fd.c new file mode 100644 index 0000000..ecdc0ef --- /dev/null +++ b/libft/ft_putstr_fd.c @@ -0,0 +1,24 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_putstr_fd.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lfirmin +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/05/29 11:27:05 by lfirmin #+# #+# */ +/* Updated: 2024/05/29 11:33:18 by lfirmin ### ########.fr */ +/* */ +/* ************************************************************************** */ +#include "libft.h" + +void ft_putstr_fd(char *s, int fd) +{ + int i; + + i = 0; + while (s[i]) + { + ft_putchar_fd(s[i], fd); + i++; + } +} diff --git a/libft/ft_split.c b/libft/ft_split.c new file mode 100644 index 0000000..0b14904 --- /dev/null +++ b/libft/ft_split.c @@ -0,0 +1,59 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_split.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lfirmin +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/05/22 05:56:37 by lfirmin #+# #+# */ +/* Updated: 2024/06/04 12:08:51 by lfirmin ### ########.fr */ +/* */ +/* ************************************************************************** */ +#include "libft.h" + +static size_t ft_countword(char const *s, char c) +{ + size_t count; + + if (!*s) + return (0); + count = 0; + while (*s) + { + while (*s == c) + s++; + if (*s) + count++; + while (*s != c && *s) + s++; + } + return (count); +} + +char **ft_split(char const *s, char c) +{ + char **lst; + size_t word_len; + int i; + + lst = (char **)malloc((ft_countword(s, c) + 1) * sizeof(char *)); + if (!s || !lst) + return (0); + i = 0; + while (*s) + { + while (*s == c && *s) + s++; + if (*s) + { + if (!ft_strchr(s, c)) + word_len = ft_strlen(s); + else + word_len = ft_strchr(s, c) - s; + lst[i++] = ft_substr(s, 0, word_len); + s += word_len; + } + } + lst[i] = NULL; + return (lst); +} diff --git a/libft/ft_strcat.c b/libft/ft_strcat.c new file mode 100644 index 0000000..bc538f2 --- /dev/null +++ b/libft/ft_strcat.c @@ -0,0 +1,82 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strcat.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lfirmin +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/11/05 02:21:14 by lfirmin #+# #+# */ +/* Updated: 2024/11/05 08:19:47 by lfirmin ### ########.fr */ +/* */ +/* ************************************************************************** */ +#include "libft.h" + +int should_add_space(char *dest, char *src) +{ + size_t dest_len; + size_t src_len; + + dest_len = ft_strlen(dest); + src_len = ft_strlen(src); + if (dest_len > 0 && src_len > 0) + { + if (dest[dest_len - 1] != ' ' && src[0] != ' ') + return (1); + } + return (0); +} + +char *create_new_str(char *dest, char *src, int add_space) +{ + size_t dest_len; + size_t src_len; + char *new_str; + + dest_len = ft_strlen(dest); + src_len = ft_strlen(src); + if (add_space == 1) + new_str = malloc(sizeof(char) * (dest_len + src_len + 2)); + else + new_str = malloc(sizeof(char) * (dest_len + src_len + 1)); + if (!new_str) + return (NULL); + return (new_str); +} + +void fill_new_str(char *new_str, char *dest, char *src, int add_space) +{ + size_t dest_len; + size_t src_len; + + dest_len = ft_strlen(dest); + src_len = ft_strlen(src); + if (add_space == 1) + { + ft_memset(new_str, 0, dest_len + src_len + 2); + ft_strlcpy(new_str, dest, dest_len + 1); + new_str[dest_len] = ' '; + ft_strlcpy(new_str + dest_len + 1, src, src_len + 1); + } + else + { + ft_memset(new_str, 0, dest_len + src_len + 1); + ft_strlcpy(new_str, dest, dest_len + 1); + ft_strlcpy(new_str + dest_len, src, src_len + 1); + } +} + +char *ft_strcat(char *dest, char *src) +{ + char *new_str; + int add_space; + + if (!dest || !src) + return (NULL); + add_space = should_add_space(dest, src); + new_str = create_new_str(dest, src, add_space); + if (!new_str) + return (NULL); + fill_new_str(new_str, dest, src, add_space); + free(dest); + return (new_str); +} diff --git a/libft/ft_strchr.c b/libft/ft_strchr.c new file mode 100644 index 0000000..11f57be --- /dev/null +++ b/libft/ft_strchr.c @@ -0,0 +1,26 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strchr.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lfirmin +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/05/21 06:46:40 by lfirmin #+# #+# */ +/* Updated: 2024/05/24 08:51:25 by lfirmin ### ########.fr */ +/* */ +/* ************************************************************************** */ +#include "libft.h" + +char *ft_strchr(char const *str, int c) +{ + while (*str) + { + if (*str == (char)c) + return ((char *)str); + str++; + } + if (*str == (char)c) + return ((char *)str); + else + return (NULL); +} diff --git a/libft/ft_strcmp.c b/libft/ft_strcmp.c new file mode 100644 index 0000000..e3d21ba --- /dev/null +++ b/libft/ft_strcmp.c @@ -0,0 +1,22 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strcmp.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lfirmin +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/10/19 21:01:26 by lfirmin #+# #+# */ +/* Updated: 2024/10/19 21:01:26 by lfirmin ### ########.fr */ +/* */ +/* ************************************************************************** */ +#include "libft.h" + +int ft_strcmp(char *s1, char *s2) +{ + int i; + + i = 0; + while (s1[i] == s2[i] && s1[i] != '\0' && s2[i] != '\0') + i++; + return (s1[i] - s2[i]); +} diff --git a/libft/ft_strdup.c b/libft/ft_strdup.c new file mode 100644 index 0000000..7df78c5 --- /dev/null +++ b/libft/ft_strdup.c @@ -0,0 +1,34 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strdup.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lfirmin +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/05/15 05:28:24 by lfirmin #+# #+# */ +/* Updated: 2024/05/22 09:59:44 by lfirmin ### ########.fr */ +/* */ +/* ************************************************************************** */ +#include "libft.h" + +char *ft_strdup(const char *src) +{ + char *dest; + int i; + int size; + + size = 0; + while (src[size] != '\0') + size++; + dest = malloc(sizeof(char) * (size + 1)); + if (dest == NULL) + return (NULL); + i = 0; + while (i != size) + { + dest[i] = src[i]; + i++; + } + dest[i] = '\0'; + return (dest); +} diff --git a/libft/ft_striteri.c b/libft/ft_striteri.c new file mode 100644 index 0000000..bd32dda --- /dev/null +++ b/libft/ft_striteri.c @@ -0,0 +1,27 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_striteri.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lfirmin +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/05/29 10:54:40 by lfirmin #+# #+# */ +/* Updated: 2024/05/29 11:12:05 by lfirmin ### ########.fr */ +/* */ +/* ************************************************************************** */ +#include "libft.h" + +void ft_striteri(char *s, void (*f)(unsigned int, char*)) +{ + int i; + + i = 0; + if (s) + { + while (s[i]) + { + f(i, &s[i]); + ++i; + } + } +} diff --git a/libft/ft_strjoin.c b/libft/ft_strjoin.c new file mode 100644 index 0000000..aed8eb4 --- /dev/null +++ b/libft/ft_strjoin.c @@ -0,0 +1,34 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strjoin.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lfirmin +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/05/22 01:00:14 by lfirmin #+# #+# */ +/* Updated: 2024/05/24 08:49:06 by lfirmin ### ########.fr */ +/* */ +/* ************************************************************************** */ +#include "libft.h" + +char *ft_strjoin(const char *s1, const char *s2) +{ + char *res; + int i; + int j; + + i = 0; + j = 0; + if (s1 == NULL && s2 == NULL) + return (NULL); + res = (char *) malloc((ft_strlen(s1) + ft_strlen(s2) + 1) * sizeof(char)); + if (!res) + return (NULL); + while (s1[i]) + res[j++] = s1[i++]; + i = 0; + while (s2[i]) + res[j++] = s2[i++]; + res[j] = 0; + return (res); +} diff --git a/libft/ft_strlcat.c b/libft/ft_strlcat.c new file mode 100644 index 0000000..b691378 --- /dev/null +++ b/libft/ft_strlcat.c @@ -0,0 +1,32 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strlcat.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lfirmin +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/05/21 03:55:25 by lfirmin #+# #+# */ +/* Updated: 2024/05/22 09:59:44 by lfirmin ### ########.fr */ +/* */ +/* ************************************************************************** */ +#include "libft.h" + +size_t ft_strlcat(char *dst, const char *src, size_t size) +{ + size_t i; + size_t r; + size_t s; + + i = 0; + r = ft_strlen(dst); + s = ft_strlen(src); + if (size <= r) + return (s + size); + while (r + i < size - 1 && src[i] != '\0') + { + dst[r + i] = src[i]; + i++; + } + dst[r + i] = '\0'; + return (r + s); +} diff --git a/libft/ft_strlcpy.c b/libft/ft_strlcpy.c new file mode 100644 index 0000000..9721995 --- /dev/null +++ b/libft/ft_strlcpy.c @@ -0,0 +1,34 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strlcpy.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lfirmin +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/05/21 02:18:17 by lfirmin #+# #+# */ +/* Updated: 2024/05/30 18:36:18 by lfirmin ### ########.fr */ +/* */ +/* ************************************************************************** */ +#include "libft.h" + +size_t ft_strlcpy(char *dst, const char *src, size_t dsts) +{ + size_t srcs; + size_t i; + + ft_strlen(src); + if (!src || !dst) + return (0); + srcs = ft_strlen(src); + i = 0; + if (dsts != 0) + { + while (src[i] != '\0' && i < (dsts - 1)) + { + dst[i] = src[i]; + i++; + } + dst[i] = '\0'; + } + return (srcs); +} diff --git a/libft/ft_strlen.c b/libft/ft_strlen.c new file mode 100644 index 0000000..c8a5c83 --- /dev/null +++ b/libft/ft_strlen.c @@ -0,0 +1,22 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strlen.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lfirmin +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/05/19 23:16:45 by lfirmin #+# #+# */ +/* Updated: 2024/05/23 07:36:59 by lfirmin ### ########.fr */ +/* */ +/* ************************************************************************** */ +#include "libft.h" + +size_t ft_strlen(const char *s) +{ + int i; + + i = 0; + while (s[i]) + i++; + return ((size_t)i); +} diff --git a/libft/ft_strmapi.c b/libft/ft_strmapi.c new file mode 100644 index 0000000..9197596 --- /dev/null +++ b/libft/ft_strmapi.c @@ -0,0 +1,32 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strmapi.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lfirmin +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/05/28 15:10:42 by lfirmin #+# #+# */ +/* Updated: 2024/05/28 17:00:27 by lfirmin ### ########.fr */ +/* */ +/* ************************************************************************** */ +#include "libft.h" + +char *ft_strmapi(char const *s, char (*f)(unsigned int, char)) +{ + char *str; + int i; + + if (!s) + return (NULL); + str = (char *)malloc(ft_strlen(s) + 1); + if (!str) + return (NULL); + i = 0; + while (s[i]) + { + str[i] = f(i, s[i]); + ++i; + } + str[i] = '\0'; + return (str); +} diff --git a/libft/ft_strncmp.c b/libft/ft_strncmp.c new file mode 100644 index 0000000..7fcfec4 --- /dev/null +++ b/libft/ft_strncmp.c @@ -0,0 +1,32 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strncmp.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lfirmin +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/05/21 06:55:09 by lfirmin #+# #+# */ +/* Updated: 2024/05/24 08:47:59 by lfirmin ### ########.fr */ +/* */ +/* ************************************************************************** */ +#include "libft.h" + +int ft_strncmp(const char *s1, const char *s2, unsigned int n) +{ + unsigned int i; + unsigned char c1; + unsigned char c2; + + i = 0; + if (n == 0) + return (0); + while (i < n) + { + c1 = (unsigned char)s1[i]; + c2 = (unsigned char)s2[i]; + if (c1 != c2 || c1 == '\0' || c2 == '\0') + return (c1 - c2); + i++; + } + return (0); +} diff --git a/libft/ft_strnstr.c b/libft/ft_strnstr.c new file mode 100644 index 0000000..4f5acca --- /dev/null +++ b/libft/ft_strnstr.c @@ -0,0 +1,36 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strnstr.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lfirmin +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/05/21 08:22:59 by lfirmin #+# #+# */ +/* Updated: 2024/05/22 09:59:44 by lfirmin ### ########.fr */ +/* */ +/* ************************************************************************** */ +#include "libft.h" + +char *ft_strnstr(const char *hay, const char *need, size_t len) +{ + size_t i; + size_t n; + + i = 0; + if (need[0] == '\0') + return ((char *)hay); + while (hay[i] != '\0') + { + n = 0; + while (hay[i + n] == need[n] && (i + n) < len) + { + if (hay[i + n] == '\0' && need[n] == '\0') + return ((char *)&hay[i]); + n++; + } + if (need[n] == '\0') + return ((char *)hay + i); + i++; + } + return (0); +} diff --git a/libft/ft_strrchr.c b/libft/ft_strrchr.c new file mode 100644 index 0000000..c7fc977 --- /dev/null +++ b/libft/ft_strrchr.c @@ -0,0 +1,35 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strrchr.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lfirmin +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/05/21 06:42:38 by lfirmin #+# #+# */ +/* Updated: 2024/05/30 18:30:00 by lfirmin ### ########.fr */ +/* */ +/* ************************************************************************** */ +#include "libft.h" + +char *ft_strrchr(const char *str, int c) +{ + int i; + int last_occurrence; + + ft_strlen(str); + i = 0; + last_occurrence = -1; + if (str == NULL) + return (NULL); + while (str[i]) + { + if (str[i] == (char)c) + last_occurrence = i; + i++; + } + if ((char)c == '\0') + return ((char *)&str[i]); + if (last_occurrence != -1) + return ((char *)&str[last_occurrence]); + return (NULL); +} diff --git a/libft/ft_strtrim.c b/libft/ft_strtrim.c new file mode 100644 index 0000000..abbf77f --- /dev/null +++ b/libft/ft_strtrim.c @@ -0,0 +1,68 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strtrim.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lfirmin +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/05/23 21:32:01 by lfirmin #+# #+# */ +/* Updated: 2024/05/31 02:04:11 by lfirmin ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +static int is_in_set(char c, const char *set) +{ + while (*set) + { + if (c == *set) + { + return (1); + } + set++; + } + return (0); +} + +static char *ft_strncpy(char *dest, const char *src, unsigned int n) +{ + unsigned int i; + + i = 0; + while (src[i] != '\0' && i < n) + { + dest[i] = src[i]; + ++i; + } + while (i < n) + { + dest[i] = '\0'; + i++; + } + return (dest); +} + +char *ft_strtrim(const char *s1, const char *set) +{ + size_t s; + size_t e; + size_t len; + char *str; + + if (!s1 || !set) + return (NULL); + s = 0; + while (s1[s] && is_in_set(s1[s], set)) + s++; + e = ft_strlen(s1); + while (e > s && is_in_set(s1[e - 1], set)) + e--; + len = e - s; + str = (char *)malloc(sizeof(char) * (len + 1)); + if (!str) + return (NULL); + ft_strncpy(str, s1 + s, len); + str[len] = '\0'; + return (str); +} diff --git a/libft/ft_substr.c b/libft/ft_substr.c new file mode 100644 index 0000000..8e73142 --- /dev/null +++ b/libft/ft_substr.c @@ -0,0 +1,34 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_substr.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lfirmin +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/05/22 00:15:54 by lfirmin #+# #+# */ +/* Updated: 2024/05/24 08:28:01 by lfirmin ### ########.fr */ +/* */ +/* ************************************************************************** */ +#include "libft.h" + +char *ft_substr(char const *s, unsigned int start, size_t len) +{ + char *sub; + size_t i; + + if ((ft_strlen(s) - start) < len) + len = ft_strlen(s) - start; + if (ft_strlen(s) < start) + return (ft_strdup("")); + i = 0; + sub = (char *) malloc(len + 1); + if (!sub) + return (NULL); + while (len > 0) + { + sub[i++] = s[start++]; + len--; + } + sub[i] = '\0'; + return (sub); +} diff --git a/libft/ft_tolower.c b/libft/ft_tolower.c new file mode 100644 index 0000000..288a27a --- /dev/null +++ b/libft/ft_tolower.c @@ -0,0 +1,19 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_tolower.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lfirmin +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/05/21 04:50:40 by lfirmin #+# #+# */ +/* Updated: 2024/05/22 11:09:36 by lfirmin ### ########.fr */ +/* */ +/* ************************************************************************** */ +#include "libft.h" + +int ft_tolower(int c) +{ + if (c >= 65 && c <= 90) + return (c + 32); + return (c); +} diff --git a/libft/ft_toupper.c b/libft/ft_toupper.c new file mode 100644 index 0000000..d563003 --- /dev/null +++ b/libft/ft_toupper.c @@ -0,0 +1,19 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_toupper.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lfirmin +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/05/21 04:50:40 by lfirmin #+# #+# */ +/* Updated: 2024/05/22 09:59:44 by lfirmin ### ########.fr */ +/* */ +/* ************************************************************************** */ +#include "libft.h" + +int ft_toupper(int c) +{ + if (c >= 97 && c <= 122) + return (c - 32); + return (c); +} diff --git a/libft/libft.h b/libft/libft.h new file mode 100644 index 0000000..1f859e3 --- /dev/null +++ b/libft/libft.h @@ -0,0 +1,82 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* libft.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lfirmin +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/05/21 11:19:08 by lfirmin #+# #+# */ +/* Updated: 2024/06/02 21:12:47 by lfirmin ### ########.fr */ +/* */ +/* ************************************************************************** */ +#ifndef LIBFT_H +# define LIBFT_H + +# include +# include +# include +# include +# include +# include + +typedef struct s_list +{ + void *content; + struct s_list *next; +} t_list; + +int ft_isalnum(int c); +int ft_isalpha(int c); +int ft_isascii(int c); +int ft_isdigit(int c); +int ft_isprint(int c); +int ft_atoi(const char *str); +int ft_memcmp(const void *ptr1, const void *ptr2, size_t num); +int ft_strncmp(const char *s1, const char *s2, unsigned int n); +int ft_toupper(int c); +int ft_tolower(int c); +int ft_lstsize(t_list *lst); +int ft_strcmp(char *s1, char *s2); +long long ft_atoll(const char *str); + +size_t ft_strlen(const char *s); +size_t ft_strlcat(char *dst, const char *src, size_t size); +size_t ft_strlcpy(char *dst, const char *src, size_t dsts); + +void *ft_bzero(void *s, size_t n); +void *ft_calloc(size_t count, size_t n); +void *ft_memchr(const void *s, int c, size_t n); +void *ft_memcpy(void *dest, const void *src, size_t len); +void *ft_memset(void *b, int c, size_t len); +void *ft_memmove(void *s1, const void *s2, size_t len); +void *ft_memset(void *str, int c, size_t n); +void ft_putchar_fd(char c, int fd); +void ft_putstr_fd(char *s, int fd); +void ft_putendl_fd(char *s, int fd); +void ft_putnbr_fd(int n, int fd); +void ft_striteri(char *s, void (*f)(unsigned int, char*)); +void ft_lstadd_front(t_list **lst, t_list *new); +void ft_lstadd_back(t_list **lst, t_list *new); +void ft_lstdelone(t_list *lst, void (*del)(void*)); +void ft_lstclear(t_list **lst, void (*del)(void*)); +void ft_print_str_array(char **array); +void ft_lstiter(t_list *lst, void (*f)(void *)); +t_list *ft_lstmap(t_list *lst, void *(*f)(void *), \ + void (*del)(void *)); + +char *ft_strchr(char const *str, int c); +char *ft_strdup(const char *src); +char *ft_strjoin(const char *s1, const char *s2); +char *ft_strnstr(const char *hay, const char *need, size_t len); +char *ft_strrchr(const char *str, int c); +char *ft_strtrim(char const *s1, char const *set); +char *ft_substr(char const *s, unsigned int start, size_t len); +char **ft_split(char const *s, char c); +char *ft_strmapi(char const *s, char (*f)(unsigned int, char)); +char *ft_itoa(int n); +char *ft_strcat(char *dest, char *src); + +t_list *ft_lstnew(void *content); +t_list *ft_lstlast(t_list *lst); + +#endif \ No newline at end of file diff --git a/maps/invalid/empty.ber b/maps/invalid/empty.ber new file mode 100644 index 0000000..e69de29 diff --git a/maps/invalid/not_ber.txt b/maps/invalid/not_ber.txt new file mode 100644 index 0000000..e617348 --- /dev/null +++ b/maps/invalid/not_ber.txt @@ -0,0 +1,3 @@ +1111111111111111111 +10P0000C0000C0000E1 +1111111111111111111 \ No newline at end of file diff --git a/maps/invalid/not_close.ber b/maps/invalid/not_close.ber new file mode 100644 index 0000000..e6b3d4e --- /dev/null +++ b/maps/invalid/not_close.ber @@ -0,0 +1,3 @@ +1111111111111111111 +10P0000C0000C0000E1 +1111111110111111111 \ No newline at end of file diff --git a/maps/invalid/not_play.ber b/maps/invalid/not_play.ber new file mode 100644 index 0000000..ef37c43 --- /dev/null +++ b/maps/invalid/not_play.ber @@ -0,0 +1,3 @@ +1111111111111111111 +10P0000C0000C0010E1 +1111111111111111111 \ No newline at end of file diff --git a/maps/invalid/not_recta.ber b/maps/invalid/not_recta.ber new file mode 100644 index 0000000..330d093 --- /dev/null +++ b/maps/invalid/not_recta.ber @@ -0,0 +1,3 @@ +1111111111111111111 +10P0000C0000C0E0111 +11111111111111111 diff --git a/maps/invalid/too_big.ber b/maps/invalid/too_big.ber new file mode 100644 index 0000000..62df18d --- /dev/null +++ b/maps/invalid/too_big.ber @@ -0,0 +1,36 @@ +1111111111111111111111111111111111111111 +1001010001000001000100000000000000000001 +100001000000C010000010000101010100000001 +100010000100C000000001001000010000000111 +1000001010000110000100000110101000010011 +10C0000000000000001010101000100010000011 +10C1001001000010010000100000100001000101 +1100000010000000110000101011000000C00001 +1000100000000000010010000000000000000001 +1000000100000001000000011010000000000001 +1000100110001000000010010010000C00000001 +1000100000010010000010000000101000000001 +1000100000001111011010100001110001100001 +1000000000011010100000011000000000000101 +10110C0100011000000000000000000011101001 +10100000C1000100000000000010010010000001 +10000000001000000111010110000001000000P1 +10000000000010011001000C0000110010001011 +10000000000010011001000C0000110010001011 +10000000000010011001000C0000110010001011 +10000000000010011001000C0000110010001011 +10000000000010011001000C0000110010001011 +1000000C00000100000000110001010001000001 +1001010000000001C00001000001010100010001 +1010000000000010110000110000000111000001 +10000000000010011001000C0000110010001011 +10000000000010011001000C0000110010001011 +10000000000010011001000C0000110010001011 +1110100001001000100100000001001010000101 +110010001100000CC000001010100E1000000001 +11000000000000000000000110100C0100010001 +1000000000100000010001000000000000000001 +1100100000000000000010001000000100110011 +1101100000100010000000010100100000001001 +10000C0000000100000111100100010000000001 +1111111111111111111111111111111111111111 diff --git a/maps/valid/crep.ber b/maps/valid/crep.ber new file mode 100644 index 0000000..1dcb7f4 --- /dev/null +++ b/maps/valid/crep.ber @@ -0,0 +1,11 @@ +111111111111 +10C00C000001 +10P00000C001 +100110011001 +100110011001 +10CC00CCC0C1 +10C001100001 +100C1111C001 +10C01C0100E1 +10C00C000001 +111111111111 \ No newline at end of file diff --git a/maps/valid/hard.ber b/maps/valid/hard.ber new file mode 100644 index 0000000..ff34a40 --- /dev/null +++ b/maps/valid/hard.ber @@ -0,0 +1,19 @@ +1111111111111111111111111111111111111111 +1E00000000000001111111000C000000000C0001 +1011110111110101000000011111111111111101 +1010010100010101011111100000000000000101 +1010010111110101010000101011111111110101 +1010000000000101000110101010000000010101 +101111111111010101011C101010111111010101 +1000000000010101010110101010100001010101 +1011111111110101010110101C10101101010101 +101000CCC0000101010110101010101101010101 +1010111111111101010110101010101101010101 +10100000000000010101101010101C11C1010101 +1011111111111111010110101010101101010101 +1000000000000000010110101010101101010101 +1111111111111111110110101010101101010101 +100000C0000CCC00000000101000000000000101 +1111111111111111111110101111111111111101 +1P00000000000000000000100000000CCCCCCCC1 +1111111111111111111111111111111111111111 \ No newline at end of file diff --git a/maps/valid/map1.ber b/maps/valid/map1.ber new file mode 100644 index 0000000..ca9d55d --- /dev/null +++ b/maps/valid/map1.ber @@ -0,0 +1,6 @@ +1111111111111111111111111111111111111111 +1000000000000000000000001000000000000001 +100000000000000000C000001000C00010000001 +1000000000000000000000001000000010000001 +100000000P0000000000000000C00000100000E1 +1111111111111111111111111111111111111111 \ No newline at end of file diff --git a/maps/valid/map2.ber b/maps/valid/map2.ber new file mode 100644 index 0000000..e617348 --- /dev/null +++ b/maps/valid/map2.ber @@ -0,0 +1,3 @@ +1111111111111111111 +10P0000C0000C0000E1 +1111111111111111111 \ No newline at end of file diff --git a/minilibx-linux/.github/workflows/ci.yml b/minilibx-linux/.github/workflows/ci.yml new file mode 100644 index 0000000..8c880cb --- /dev/null +++ b/minilibx-linux/.github/workflows/ci.yml @@ -0,0 +1,88 @@ +name: Build + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + build: + + runs-on: ${{ matrix.os }} + env: + DISPLAY: ":99" + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, macos-latest] + + timeout-minutes: 20 + steps: + - uses: actions/checkout@v2 + - name: Install mlx dependencies + run: | + set -x + if [ "$RUNNER_OS" == "Linux" ]; then + sudo apt-get update -qq + sudo apt-get install -y -qq gcc make xorg libxext-dev libbsd-dev + elif [ "$RUNNER_OS" == "macOS" ]; then + brew install xquartz + echo "/usr/X11/bin" >> $GITHUB_PATH + else + echo "$RUNNER_OS not supported" + exit 1 + fi + - name: Setup x11 headless testing environment + run: | + set -x + if [ "$RUNNER_OS" == "Linux" ]; then + sudo apt-get install xvfb xdotool valgrind + Xvfb $DISPLAY -screen 0 1280x1024x24 & + elif [ "$RUNNER_OS" == "macOS" ]; then + brew install xdotool + defaults write org.x.X11 enable_test_extensions -boolean true + sudo Xvfb $DISPLAY -screen 0 1280x1024x24 & + else + echo "$RUNNER_OS not supported" + exit 1 + fi + - name: Run ./configure + run: ./configure + + - name: make check Linux + if: matrix.os == 'ubuntu-latest' + run: make -f Makefile.gen check + - name: make check MacOS + continue-on-error: true + if: matrix.os == 'macos-latest' + run: make -f Makefile.gen check + # Didn't find a way to simulate inputs on Macos. libxdo seem to no longer work on macos. + # It can be partially fixed writing proper unit-tests, thus avoiding the need of libxdo. + + - name: Check leaks from binary "test/mlx-test" + run: | + cd test + if [ "$RUNNER_OS" == "Linux" ]; then + echo "Info: Still reachable doesn't matter. Valgrind will return success on thoses reports. + It is fine, we searching for lost pointers. Valgrind will return exit status 42 if any block is lost." + valgrind --leak-check=full --show-leak-kinds=definite,indirect,possible --errors-for-leak-kinds=definite,indirect,possible --error-exitcode=42 ./mlx-test > /dev/null & + PID=$! + sleep 30 + xdotool search --name Title3 windowfocus key Escape + xdotool search --name Title2 windowfocus key Escape + wait $PID + elif [ "$RUNNER_OS" == "macOS" ]; then + MallocStackLoggingNoCompact=1 + ./mlx-test & + sleep 30 + leaks mlx-test + pkill mlx-test + fi + + - name: Norminette, just for fun + continue-on-error: true + run: | + pip3 install Norminette + norminette *.c *.h + norminette --version diff --git a/minilibx-linux/.gitignore b/minilibx-linux/.gitignore new file mode 100644 index 0000000..9595e5f --- /dev/null +++ b/minilibx-linux/.gitignore @@ -0,0 +1,67 @@ +## Mlx related +Makefile.gen +/test/mlx-test + +## Editor +.vscode/* +*~ +\#*\# + +## Other +.DS_STORE + + + +## Template from https://github.com/github/gitignore +# Prerequisites +*.d + +# Object files +*.o +*.ko +*.obj +*.elf + +# Linker output +*.ilk +*.map +*.exp + +# Precompiled Headers +*.gch +*.pch + +# Libraries +*.lib +*.a +*.la +*.lo + +# Shared objects (inc. Windows DLLs) +*.dll +*.so +*.so.* +*.dylib + +# Executables +*.exe +*.out +*.app +*.i*86 +*.x86_64 +*.hex + +# Debug files +*.dSYM/ +*.su +*.idb +*.pdb + +# Kernel Module Compile Results +*.mod* +*.cmd +.tmp_versions/ +modules.order +Module.symvers +Mkfile.old +dkms.conf \ No newline at end of file diff --git a/minilibx-linux/LICENSE b/minilibx-linux/LICENSE new file mode 100644 index 0000000..ed2de25 --- /dev/null +++ b/minilibx-linux/LICENSE @@ -0,0 +1,25 @@ +BSD 2-Clause License + +Copyright (c) 2021, Ecole 42 +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/minilibx-linux/Makefile b/minilibx-linux/Makefile new file mode 100644 index 0000000..5c418c5 --- /dev/null +++ b/minilibx-linux/Makefile @@ -0,0 +1,22 @@ +## +## Makefile for MiniLibX in /home/boulon/work/c/raytraceur/minilibx +## +## Made by Olivier Crouzet +## Login +## +## Started on Tue Oct 5 15:56:43 2004 Olivier Crouzet +## Last update Tue May 15 15:44:41 2007 Olivier Crouzet +## + +## Please use configure script + + +all : do_configure + +do_configure : + ./configure + +clean : + ./configure clean + +re : clean all diff --git a/minilibx-linux/Makefile.mk b/minilibx-linux/Makefile.mk new file mode 100644 index 0000000..1bae8df --- /dev/null +++ b/minilibx-linux/Makefile.mk @@ -0,0 +1,66 @@ +## +## Makefile for MiniLibX in /home/boulon/work/c/raytraceur/minilibx +## +## Made by Olivier Crouzet +## Login +## +## Started on Tue Oct 5 15:56:43 2004 Olivier Crouzet +## Last update Tue May 15 15:41:20 2007 Olivier Crouzet +## + +## Please use configure script + + +INC =%%%% + +UNAME = $(shell uname) +CC = gcc +ifeq ($(UNAME),FreeBSD) + CC = clang +endif + +NAME = libmlx.a +NAME_UNAME = libmlx_$(UNAME).a + +SRC = mlx_init.c mlx_new_window.c mlx_pixel_put.c mlx_loop.c \ + mlx_mouse_hook.c mlx_key_hook.c mlx_expose_hook.c mlx_loop_hook.c \ + mlx_int_anti_resize_win.c mlx_int_do_nothing.c \ + mlx_int_wait_first_expose.c mlx_int_get_visual.c \ + mlx_flush_event.c mlx_string_put.c mlx_set_font.c \ + mlx_new_image.c mlx_get_data_addr.c \ + mlx_put_image_to_window.c mlx_get_color_value.c mlx_clear_window.c \ + mlx_xpm.c mlx_int_str_to_wordtab.c mlx_destroy_window.c \ + mlx_int_param_event.c mlx_int_set_win_event_mask.c mlx_hook.c \ + mlx_rgb.c mlx_destroy_image.c mlx_mouse.c mlx_screen_size.c \ + mlx_destroy_display.c + +OBJ_DIR = obj +OBJ = $(addprefix $(OBJ_DIR)/,$(SRC:%.c=%.o)) +CFLAGS = -O3 -I$(INC) + +all : $(NAME) + +$(OBJ_DIR)/%.o: %.c + @mkdir -p $(OBJ_DIR) + $(CC) $(CFLAGS) $(IFLAGS) -c $< -o $@ + +$(NAME) : $(OBJ) + ar -r $(NAME) $(OBJ) + ranlib $(NAME) + cp $(NAME) $(NAME_UNAME) + +check: all + @test/run_tests.sh + +show: + @printf "NAME : $(NAME)\n" + @printf "NAME_UNAME : $(NAME_UNAME)\n" + @printf "CC : $(CC)\n" + @printf "CFLAGS : $(CFLAGS)\n" + @printf "SRC :\n $(SRC)\n" + @printf "OBJ :\n $(OBJ)\n" + +clean : + rm -rf $(OBJ_DIR)/ $(NAME) $(NAME_UNAME) *~ core *.core + +.PHONY: all check show clean diff --git a/minilibx-linux/README.md b/minilibx-linux/README.md new file mode 100755 index 0000000..cb60744 --- /dev/null +++ b/minilibx-linux/README.md @@ -0,0 +1,55 @@ +[![Build](https://github.com/42Paris/minilibx-linux/actions/workflows/ci.yml/badge.svg)](https://github.com/42Paris/minilibx-linux/actions/workflows/ci.yml) + +This is the MinilibX, a simple X-Window (X11R6) programming API +in C, designed for students, suitable for X-beginners. + + +Contents + + - source code in C to create the mlx library + - man pages (in man/ directory) + - a test program (in test/ directory) is built + with the library + - a public include file mlx.h + - a tiny configure script to generate an appropriate Makefile.gen + +Requirements for Linux + + - MinilibX only support TrueColor visual type (8,15,16,24 or 32 bits depth) + - gcc + - make + - X11 include files (package xorg) + - XShm extension must be present (package libxext-dev) + - Utility functions from BSD systems - development files (package libbsd-dev) + - **e.g. _sudo apt-get install gcc make xorg libxext-dev libbsd-dev_ (Debian/Ubuntu)** + +Requirements for MacOS + - [Xquartz](https://www.xquartz.org/) + +```bash +➜ ~ Brew install Xquartz +➜ ~ reboot +➜ ~ xeyes # run an hello world X11 app +``` + +MlX Color Opacity / Transparency / Alpha (32 bits depth) + - 0xFF (fully transparent) or 0x00 (fully opaque) + +Compile MinilibX + + - run ./configure or make + both will make a few tests, create Makefile.gen + and then automatically run make on this generated Makefile.gen . + libmlx.a and libmlx_$(HOSTTYPE).a are created. + test/mlx-test binary is also created. + + +Install MinilibX + + - no installation script is provided. You may want to install + - libmlx.a and/or libmlx_$(HOSTTYPE).a in /usr/X11/lib or /usr/local/lib + - mlx.h in /usr/X11/include or /usr/local/include + - man/man3/mlx*.1 in /usr/X11/man/man3 or /usr/local/man/man3 + + + Olivier CROUZET - 2014-01-06 - diff --git a/minilibx-linux/configure b/minilibx-linux/configure new file mode 100755 index 0000000..18d1e4d --- /dev/null +++ b/minilibx-linux/configure @@ -0,0 +1,126 @@ +#!/usr/bin/env sh + +set -e + +BOLD="\033[1m" +RESET="\033[0m" +LIGHT_RED="\033[91m" +LIGHT_GREEN="\033[92m" +LIGHT_CYAN="\033[96m" + +logging(){ + local type=$1; shift + printf "${LIGHT_CYAN}${BOLD}configure${RESET} [%b] : %b\n" "$type" "$*" +} +log_info(){ + logging "${LIGHT_GREEN}info${RESET}" "$@" +} +log_error(){ + logging "${LIGHT_RED}error${RESET}" "$@" >&2 +} + +# find and print x11 header path +get_xlib_include_path(){ + local result="" + + for inc in \ + /usr/X11/include \ + /usr/X11R6/include \ + /usr/X11R5/include \ + /usr/X11R4/include \ + \ + /usr/include \ + /usr/include/X11 \ + /usr/include/X11R6 \ + /usr/include/X11R5 \ + /usr/include/X11R4 \ + \ + /usr/local/X11/include \ + /usr/local/X11R6/include \ + /usr/local/X11R5/include \ + /usr/local/X11R4/include \ + \ + /usr/local/include/X11 \ + /usr/local/include/X11R6 \ + /usr/local/include/X11R5 \ + /usr/local/include/X11R4 \ + \ + /usr/X386/include \ + /usr/x386/include \ + /usr/XFree86/include/X11 \ + \ + /usr/local/include \ + /usr/athena/include \ + /usr/local/x11r5/include \ + /usr/lpp/Xamples/include \ + \ + /usr/openwin/include \ + /usr/openwin/share/include + do + if [ -f "$inc/X11/Xlib.h" -a -f "$inc/X11/extensions/XShm.h" ]; then + result=$inc + break + fi + done + echo $result +} + +show_help(){ +cat < Makefile.gen + cat Makefile.mk | grep -v %%%% >> Makefile.gen + log_info 'Generate "test/makefile.gen" from template "test/makefile.mk"' + echo "INC=$xlib_inc" > test/Makefile.gen + cat test/Makefile.mk | grep -v %%%% >> test/Makefile.gen + + log_info 'Execute "make all" from file "makefile.gen"' + ${MAKE} -f Makefile.gen all + log_info 'Execute "make all" from file "test/makefile.gen"' + (cd test ; ${MAKE} -f Makefile.gen all ) +} + +main "$@" diff --git a/minilibx-linux/man/man1/mlx.1 b/minilibx-linux/man/man1/mlx.1 new file mode 100644 index 0000000..9ad0ac1 --- /dev/null +++ b/minilibx-linux/man/man1/mlx.1 @@ -0,0 +1,93 @@ +.TH MiniLibX 3 "September 19, 2002" +.SH NAME +MiniLibX - Simple X-Window Interface Library for students +.SH SYNOPSYS +#include + +.nf +.I void * +.fi +.B mlx_init +(); + +.SH DESCRIPTION +MiniLibX is an easy way to create graphical software, +without any X-Window programming knowledge. It provides +simple window creation, a drawing tool, image and basic events +management. + +.SH X-WINDOW CONCEPT + +X-Window is a network-oriented graphical system for Unix. +It is based on two main parts: +.br +On one side, your software wants to draw something on the screen and/or +get keyboard & mouse entries. +.br +On the other side, the X-Server manages the screen, keyboard and mouse +(It is often refered to as a "display"). +.br +A network connection must be established between these two entities to send +drawing orders (from the software to the X-Server), and keyboard/mouse +events (from the X-Server to the software). + +.SH INCLUDE FILE +.B mlx.h +should be included for a correct use of the MiniLibX API. +It only contains function prototypes, no structure is needed. + +.SH LIBRARY FUNCTIONS +.P +First of all, you need to initialize the connection +between your software and the display. +Once this connection is established, you'll be able to +use other MiniLibX functions to send the X-Server messages, +like "I want to draw a yellow pixel in this window" or "did the +user hit a key?". +.P +The +.B mlx_init +function will create this connection. No parameters are needed, ant it will +return a +.I "void *" +identifier, used for further calls to the library routines. +.P +All other MiniLibX functions are described in the following man pages: + +.TP 20 +.B mlx_new_window +: manage windows +.TP 20 +.B mlx_pixel_put +: draw inside window +.TP 20 +.B mlx_new_image +: manipulate images +.TP 20 +.B mlx_loop +: handle keyboard or mouse events + +.SH LINKING MiniLibX +To use MiniLibX functions, you'll need to link +your software with several libraries, including the MiniLibX library itself. +To do this, simply add the following arguments at linking time: + +.B -lmlx -lXext -lX11 + +You may also need to specify the path to these libraries, using +the +.B -L +flag. + + +.SH RETURN VALUES +If +.B mlx_init() +fails to set up the connection to the X server, it will return NULL, otherwise +a non-null pointer is returned as a connection identifier. + +.SH SEE ALSO +mlx_new_window(3), mlx_pixel_put(3), mlx_new_image(3), mlx_loop(3) + +.SH AUTHOR +Copyright ol@ - 2002-2014 - Olivier Crouzet diff --git a/minilibx-linux/man/man1/mlx_loop.1 b/minilibx-linux/man/man1/mlx_loop.1 new file mode 100644 index 0000000..3397ce2 --- /dev/null +++ b/minilibx-linux/man/man1/mlx_loop.1 @@ -0,0 +1,141 @@ +.TH MiniLibX 3 "September 19, 2002" +.SH NAME +MiniLibX - Handle events +.SH SYNOPSYS + +.nf +.I int +.fi +.B mlx_loop +( +.I void *mlx_ptr +); + +.nf +.I int +.fi +.B mlx_key_hook +( +.I void *win_ptr, int (*funct_ptr)(), void *param +); + +.nf +.I int +.fi +.B mlx_mouse_hook +( +.I void *win_ptr, int (*funct_ptr)(), void *param +); + +.nf +.I int +.fi +.B mlx_expose_hook +( +.I void *win_ptr, int (*funct_ptr)(), void *param +); + +.nf +.I int +.fi +.B mlx_loop_hook +( +.I void *mlx_ptr, int (*funct_ptr)(), void *param +); + +.SH X-WINDOW EVENTS + +The X-Window system is bi-directionnal. On one hand, the program sends orders to +the screen to display pixels, images, and so on. On the other hand, +it can get information from the keyboard and mouse associated to +the screen. To do so, the program receives "events" from the keyboard or the +mouse. + +.SH DESCRIPTION + +To receive events, you must use +.B mlx_loop +(). This function never returns. It is an infinite loop that waits for +an event, and then calls a user-defined function associated with this event. +A single parameter is needed, the connection identifier +.I mlx_ptr +(see the +.B mlx manual). + +You can assign different functions to the three following events: +.br +- A key is pressed +.br +- The mouse button is pressed +.br +- A part of the window should be re-drawn +(this is called an "expose" event, and it is your program's job to handle it). +.br + +Each window can define a different function for the same event. + +The three functions +.B mlx_key_hook +(), +.B mlx_mouse_hook +() and +.B mlx_expose_hook +() work exactly the same way. +.I funct_ptr +is a pointer to the function you want to be called +when an event occurs. This assignment is specific to the window defined by the +.I win_ptr +identifier. The +.I param +adress will be passed to the function everytime it is called, and should be +used to store the parameters it might need. + +The syntax for the +.B mlx_loop_hook +() function is identical to the previous ones, but the given function will be +called when no event occurs. + +When it catches an event, the MiniLibX calls the corresponding function +with fixed parameters: +.nf + + expose_hook(void *param); + key_hook(int keycode,void *param); + mouse_hook(int button,int x,int y,void *param); + loop_hook(void *param); + +.fi +These function names are arbitrary. They here are used to distinguish +parameters according to the event. These functions are NOT part of the +MiniLibX. + +.I param +is the address specified in the mlx_*_hook calls. This address is never +used nor modified by the MiniLibX. On key and mouse events, additional +information is passed: +.I keycode +tells you which key is pressed (look for the X11 include file "keysymdef.h"), +( +.I x +, +.I y +) are the coordinates of the mouse click in the window, and +.I button +tells you which mouse button was pressed. + +.SH GOING FURTHER WITH EVENTS +The MiniLibX provides a much generic access to all X-Window events. The +.I mlx.h +include define +.B mlx_hook() +in the same manner mlx_*_hook functions work. The event and mask values +will be taken from the X11 include file "X.h". + +See source code of mlx_int_param_event.c to find out how the MiniLibX will +call your own function for a specific event. + +.SH SEE ALSO +mlx(3), mlx_new_window(3), mlx_pixel_put(3), mlx_new_image(3) + +.SH AUTHOR +Copyright ol@ - 2002-2014 - Olivier Crouzet diff --git a/minilibx-linux/man/man1/mlx_new_image.1 b/minilibx-linux/man/man1/mlx_new_image.1 new file mode 100644 index 0000000..f2160a2 --- /dev/null +++ b/minilibx-linux/man/man1/mlx_new_image.1 @@ -0,0 +1,192 @@ +.TH MiniLibX 3 "September 19, 2002" +.SH NAME +MiniLibX - Manipulating images +.SH SYNOPSYS + +.nf +.I void * +.fi +.B mlx_new_image +( +.I void *mlx_ptr, int width, int height +); + +.nf +.I char * +.fi +.B mlx_get_data_addr +( +.I void *img_ptr, int *bits_per_pixel, int *size_line, int *endian +); + +.nf +.I int +.fi +.B mlx_put_image_to_window +( +.I void *mlx_ptr, void *win_ptr, void *img_ptr, int x, int y +); + +.nf +.I unsigned int +.fi +.B mlx_get_color_value +( +.I void *mlx_ptr, int color +); + +.nf +.I void * +.fi +.B mlx_xpm_to_image +( +.I void *mlx_ptr, char **xpm_data, int *width, int *height +); + +.nf +.I void * +.fi +.B mlx_xpm_file_to_image +( +.I void *mlx_ptr, char *filename, int *width, int *height +); + +.nf +.I int +.fi +.B mlx_destroy_image +( +.I void *mlx_ptr, void *img_ptr +); + + +.SH DESCRIPTION + +.B mlx_new_image +() creates a new image in memory. It returns a +.I void * +identifier needed to manipulate this image later. It only needs +the size of the image to be created, using the +.I width +and +.I height +parameters, and the +.I mlx_ptr +connection identifier (see the +.B mlx +manual). + +The user can draw inside the image (see below), and +can dump the image inside a specified window at any time to +display it on the screen. This is done using +.B mlx_put_image_to_window +(). Three identifiers are needed here, for the connection to the +display, the window to use, and the image (respectively +.I mlx_ptr +, +.I win_ptr +and +.I img_ptr +). The ( +.I x +, +.I y +) coordinates define where the image should be placed in the window. + +.B mlx_get_data_addr +() returns information about the created image, allowing a user +to modify it later. The +.I img_ptr +parameter specifies the image to use. The three next parameters should +be the addresses of three different valid integers. +.I bits_per_pixel +will be filled with the number of bits needed to represent a pixel color +(also called the depth of the image). +.I size_line +is the number of bytes used to store one line of the image in memory. +This information is needed to move from one line to another in the image. +.I endian +tells you wether the pixel color in the image needs to be stored in +little endian ( +.I endian +== 0), or big endian ( +.I endian +== 1). + +.B mlx_get_data_addr +returns a +.I char * +address that represents the begining of the memory area where the image +is stored. From this adress, the first +.I bits_per_pixel +bits represent the color of the first pixel in the first line of +the image. The second group of +.I bits_per_pixel +bits represent the second pixel of the first line, and so on. +Add +.I size_line +to the adress to get the begining of the second line. You can reach any +pixels of the image that way. + +.B mlx_destroy_image +destroys the given image ( +.I img_ptr +). + +.SH STORING COLOR INSIDE IMAGES + +Depending on the display, the number of bits used to store a pixel color +can change. The user usually represents a color in RGB mode, using +one byte for each component (see +.B mlx_pixel_put +manual). This must be translated to fit the +.I bits_per_pixel +requirement of the image, and make the color understandable to the X-Server. +That is the purpose of the +.B mlx_get_color_value +() function. It takes a standard RGB +.I color +parameter, and returns an +.I unsigned int +value. +The +.I bits_per_pixel +least significant bits of this value can be stored in the image. + +Keep in mind that the least significant bits position depends on the local +computer's endian. If the endian of the image (in fact the endian of +the X-Server's computer) differs from the local endian, then the value should +be transformed before being used. + +.SH XPM IMAGES + +The +.B mlx_xpm_to_image +() and +.B mlx_xpm_file_to_image +() functions will create a new image the same way. +They will fill it using the specified +.I xpm_data +or +.I filename +, depending on which function is used. +Note that MiniLibX does not use the standard +Xpm library to deal with xpm images. You may not be able to +read all types of xpm images. It however handles transparency. + +.SH RETURN VALUES +The three functions that create images, +.B mlx_new_image() +, +.B mlx_xpm_to_image() +and +.B mlx_xpm_file_to_image() +, will return NULL if an error occurs. Otherwise they return a non-null pointer +as an image identifier. + + +.SH SEE ALSO +mlx(3), mlx_new_window(3), mlx_pixel_put(3), mlx_loop(3) + +.SH AUTHOR +Copyright ol@ - 2002-2014 - Olivier Crouzet diff --git a/minilibx-linux/man/man1/mlx_new_window.1 b/minilibx-linux/man/man1/mlx_new_window.1 new file mode 100644 index 0000000..90f6d47 --- /dev/null +++ b/minilibx-linux/man/man1/mlx_new_window.1 @@ -0,0 +1,79 @@ +.TH MiniLibX 3 "September 19, 2002" +.SH NAME +MiniLibX - Managing windows +.SH SYNOPSYS + +.nf +.I void * +.fi +.B mlx_new_window +( +.I void *mlx_ptr, int size_x, int size_y, char *title +); + +.nf +.I int +.fi +.B mlx_clear_window +( +.I void *mlx_ptr, void *win_ptr +); + +.nf +.I int +.fi +.B mlx_destroy_window +( +.I void *mlx_ptr, void *win_ptr +); + + +.SH DESCRIPTION +The +.B mlx_new_window +() function creates a new window on the screen, using the +.I size_x +and +.I size_y +parameters to determine its size, and +.I title +as the text that should be displayed in the window's title bar. +The +.I mlx_ptr +parameter is the connection identifier returned by +.B mlx_init +() (see the +.B mlx +man page). +.B mlx_new_window +() returns a +.I void * +window identifier that can be used by other MiniLibX calls. +Note that the MiniLibX +can handle an arbitrary number of separate windows. + +.B mlx_clear_window +() and +.B mlx_destroy_window +() respectively clear (in black) and destroy the given window. They both have +the same parameters: +.I mlx_ptr +is the screen connection identifier, and +.I win_ptr +is a window identifier. + +.SH RETURN VALUES +If +.B mlx_new_window() +fails to create a new window (for wathever reason), it will return NULL, +otherwise a non-null pointer is returned as a window identifier. +.B mlx_clear_window +and +.B mlx_destroy_window +right now return nothing. + +.SH SEE ALSO +mlx(3), mlx_pixel_put(3), mlx_new_image(3), mlx_loop(3) + +.SH AUTHOR +Copyright ol@ - 2002-2014 - Olivier Crouzet diff --git a/minilibx-linux/man/man1/mlx_pixel_put.1 b/minilibx-linux/man/man1/mlx_pixel_put.1 new file mode 100644 index 0000000..258df58 --- /dev/null +++ b/minilibx-linux/man/man1/mlx_pixel_put.1 @@ -0,0 +1,84 @@ +.TH MiniLibX 3 "September 19, 2002" +.SH NAME +MiniLibX - Drawing inside windows +.SH SYNOPSYS + +.nf +.I int +.fi +.B mlx_pixel_put +( +.I void *mlx_ptr, void *win_ptr, int x, int y, int color +); + +.nf +.I int +.fi +.B mlx_string_put +( +.I void *mlx_ptr, void *win_ptr, int x, int y, int color, char *string +); + + +.SH DESCRIPTION +The +.B mlx_pixel_put +() function draws a defined pixel in the window +.I win_ptr +using the ( +.I x +, +.I y +) coordinates, and the specified +.I color +\&. The origin (0,0) is the upper left corner of the window, the x and y axis +respectively pointing right and down. The connection +identifier, +.I mlx_ptr +, is needed (see the +.B mlx +man page). + +Parameters for +.B mlx_string_put +() have the same meaning. Instead of a simple pixel, the specified +.I string +will be displayed at ( +.I x +, +.I y +). + +In both functions, it is impossible to display anything outside the +specified window, nor display in another window in front of the selected one. + +.SH COLOR MANAGEMENT +The +.I color +parameter has an integer type. The displayed color needs to be encoded +in this integer, following a defined scheme. All displayable colors +can be split in 3 basic colors: red, green and blue. Three associated +values, in the 0-255 range, represent how much of each color is mixed up +to create the original color. Theses three values must be set inside the +integer to display the right color. The three least significant bytes of +this integer are filled as shown in the picture below: + +.TS +allbox; +c s s s s +r c c c c. +Color Integer +Interpretation \[*a] R G B +Bit numbers 31..24 23..16 15..8 7..0 +.TE + +While filling the integer, make sure you avoid endian problems. Remember +that the "blue" byte should always be the least significant one. + + +.SH SEE ALSO +mlx(3), mlx_new_window(3), mlx_new_image(3), mlx_loop(3) + + +.SH AUTHOR +Copyright ol@ - 2002-2014 - Olivier Crouzet diff --git a/minilibx-linux/man/man3/mlx.3 b/minilibx-linux/man/man3/mlx.3 new file mode 100644 index 0000000..9ad0ac1 --- /dev/null +++ b/minilibx-linux/man/man3/mlx.3 @@ -0,0 +1,93 @@ +.TH MiniLibX 3 "September 19, 2002" +.SH NAME +MiniLibX - Simple X-Window Interface Library for students +.SH SYNOPSYS +#include + +.nf +.I void * +.fi +.B mlx_init +(); + +.SH DESCRIPTION +MiniLibX is an easy way to create graphical software, +without any X-Window programming knowledge. It provides +simple window creation, a drawing tool, image and basic events +management. + +.SH X-WINDOW CONCEPT + +X-Window is a network-oriented graphical system for Unix. +It is based on two main parts: +.br +On one side, your software wants to draw something on the screen and/or +get keyboard & mouse entries. +.br +On the other side, the X-Server manages the screen, keyboard and mouse +(It is often refered to as a "display"). +.br +A network connection must be established between these two entities to send +drawing orders (from the software to the X-Server), and keyboard/mouse +events (from the X-Server to the software). + +.SH INCLUDE FILE +.B mlx.h +should be included for a correct use of the MiniLibX API. +It only contains function prototypes, no structure is needed. + +.SH LIBRARY FUNCTIONS +.P +First of all, you need to initialize the connection +between your software and the display. +Once this connection is established, you'll be able to +use other MiniLibX functions to send the X-Server messages, +like "I want to draw a yellow pixel in this window" or "did the +user hit a key?". +.P +The +.B mlx_init +function will create this connection. No parameters are needed, ant it will +return a +.I "void *" +identifier, used for further calls to the library routines. +.P +All other MiniLibX functions are described in the following man pages: + +.TP 20 +.B mlx_new_window +: manage windows +.TP 20 +.B mlx_pixel_put +: draw inside window +.TP 20 +.B mlx_new_image +: manipulate images +.TP 20 +.B mlx_loop +: handle keyboard or mouse events + +.SH LINKING MiniLibX +To use MiniLibX functions, you'll need to link +your software with several libraries, including the MiniLibX library itself. +To do this, simply add the following arguments at linking time: + +.B -lmlx -lXext -lX11 + +You may also need to specify the path to these libraries, using +the +.B -L +flag. + + +.SH RETURN VALUES +If +.B mlx_init() +fails to set up the connection to the X server, it will return NULL, otherwise +a non-null pointer is returned as a connection identifier. + +.SH SEE ALSO +mlx_new_window(3), mlx_pixel_put(3), mlx_new_image(3), mlx_loop(3) + +.SH AUTHOR +Copyright ol@ - 2002-2014 - Olivier Crouzet diff --git a/minilibx-linux/man/man3/mlx_loop.3 b/minilibx-linux/man/man3/mlx_loop.3 new file mode 100644 index 0000000..3397ce2 --- /dev/null +++ b/minilibx-linux/man/man3/mlx_loop.3 @@ -0,0 +1,141 @@ +.TH MiniLibX 3 "September 19, 2002" +.SH NAME +MiniLibX - Handle events +.SH SYNOPSYS + +.nf +.I int +.fi +.B mlx_loop +( +.I void *mlx_ptr +); + +.nf +.I int +.fi +.B mlx_key_hook +( +.I void *win_ptr, int (*funct_ptr)(), void *param +); + +.nf +.I int +.fi +.B mlx_mouse_hook +( +.I void *win_ptr, int (*funct_ptr)(), void *param +); + +.nf +.I int +.fi +.B mlx_expose_hook +( +.I void *win_ptr, int (*funct_ptr)(), void *param +); + +.nf +.I int +.fi +.B mlx_loop_hook +( +.I void *mlx_ptr, int (*funct_ptr)(), void *param +); + +.SH X-WINDOW EVENTS + +The X-Window system is bi-directionnal. On one hand, the program sends orders to +the screen to display pixels, images, and so on. On the other hand, +it can get information from the keyboard and mouse associated to +the screen. To do so, the program receives "events" from the keyboard or the +mouse. + +.SH DESCRIPTION + +To receive events, you must use +.B mlx_loop +(). This function never returns. It is an infinite loop that waits for +an event, and then calls a user-defined function associated with this event. +A single parameter is needed, the connection identifier +.I mlx_ptr +(see the +.B mlx manual). + +You can assign different functions to the three following events: +.br +- A key is pressed +.br +- The mouse button is pressed +.br +- A part of the window should be re-drawn +(this is called an "expose" event, and it is your program's job to handle it). +.br + +Each window can define a different function for the same event. + +The three functions +.B mlx_key_hook +(), +.B mlx_mouse_hook +() and +.B mlx_expose_hook +() work exactly the same way. +.I funct_ptr +is a pointer to the function you want to be called +when an event occurs. This assignment is specific to the window defined by the +.I win_ptr +identifier. The +.I param +adress will be passed to the function everytime it is called, and should be +used to store the parameters it might need. + +The syntax for the +.B mlx_loop_hook +() function is identical to the previous ones, but the given function will be +called when no event occurs. + +When it catches an event, the MiniLibX calls the corresponding function +with fixed parameters: +.nf + + expose_hook(void *param); + key_hook(int keycode,void *param); + mouse_hook(int button,int x,int y,void *param); + loop_hook(void *param); + +.fi +These function names are arbitrary. They here are used to distinguish +parameters according to the event. These functions are NOT part of the +MiniLibX. + +.I param +is the address specified in the mlx_*_hook calls. This address is never +used nor modified by the MiniLibX. On key and mouse events, additional +information is passed: +.I keycode +tells you which key is pressed (look for the X11 include file "keysymdef.h"), +( +.I x +, +.I y +) are the coordinates of the mouse click in the window, and +.I button +tells you which mouse button was pressed. + +.SH GOING FURTHER WITH EVENTS +The MiniLibX provides a much generic access to all X-Window events. The +.I mlx.h +include define +.B mlx_hook() +in the same manner mlx_*_hook functions work. The event and mask values +will be taken from the X11 include file "X.h". + +See source code of mlx_int_param_event.c to find out how the MiniLibX will +call your own function for a specific event. + +.SH SEE ALSO +mlx(3), mlx_new_window(3), mlx_pixel_put(3), mlx_new_image(3) + +.SH AUTHOR +Copyright ol@ - 2002-2014 - Olivier Crouzet diff --git a/minilibx-linux/man/man3/mlx_new_image.3 b/minilibx-linux/man/man3/mlx_new_image.3 new file mode 100644 index 0000000..f2160a2 --- /dev/null +++ b/minilibx-linux/man/man3/mlx_new_image.3 @@ -0,0 +1,192 @@ +.TH MiniLibX 3 "September 19, 2002" +.SH NAME +MiniLibX - Manipulating images +.SH SYNOPSYS + +.nf +.I void * +.fi +.B mlx_new_image +( +.I void *mlx_ptr, int width, int height +); + +.nf +.I char * +.fi +.B mlx_get_data_addr +( +.I void *img_ptr, int *bits_per_pixel, int *size_line, int *endian +); + +.nf +.I int +.fi +.B mlx_put_image_to_window +( +.I void *mlx_ptr, void *win_ptr, void *img_ptr, int x, int y +); + +.nf +.I unsigned int +.fi +.B mlx_get_color_value +( +.I void *mlx_ptr, int color +); + +.nf +.I void * +.fi +.B mlx_xpm_to_image +( +.I void *mlx_ptr, char **xpm_data, int *width, int *height +); + +.nf +.I void * +.fi +.B mlx_xpm_file_to_image +( +.I void *mlx_ptr, char *filename, int *width, int *height +); + +.nf +.I int +.fi +.B mlx_destroy_image +( +.I void *mlx_ptr, void *img_ptr +); + + +.SH DESCRIPTION + +.B mlx_new_image +() creates a new image in memory. It returns a +.I void * +identifier needed to manipulate this image later. It only needs +the size of the image to be created, using the +.I width +and +.I height +parameters, and the +.I mlx_ptr +connection identifier (see the +.B mlx +manual). + +The user can draw inside the image (see below), and +can dump the image inside a specified window at any time to +display it on the screen. This is done using +.B mlx_put_image_to_window +(). Three identifiers are needed here, for the connection to the +display, the window to use, and the image (respectively +.I mlx_ptr +, +.I win_ptr +and +.I img_ptr +). The ( +.I x +, +.I y +) coordinates define where the image should be placed in the window. + +.B mlx_get_data_addr +() returns information about the created image, allowing a user +to modify it later. The +.I img_ptr +parameter specifies the image to use. The three next parameters should +be the addresses of three different valid integers. +.I bits_per_pixel +will be filled with the number of bits needed to represent a pixel color +(also called the depth of the image). +.I size_line +is the number of bytes used to store one line of the image in memory. +This information is needed to move from one line to another in the image. +.I endian +tells you wether the pixel color in the image needs to be stored in +little endian ( +.I endian +== 0), or big endian ( +.I endian +== 1). + +.B mlx_get_data_addr +returns a +.I char * +address that represents the begining of the memory area where the image +is stored. From this adress, the first +.I bits_per_pixel +bits represent the color of the first pixel in the first line of +the image. The second group of +.I bits_per_pixel +bits represent the second pixel of the first line, and so on. +Add +.I size_line +to the adress to get the begining of the second line. You can reach any +pixels of the image that way. + +.B mlx_destroy_image +destroys the given image ( +.I img_ptr +). + +.SH STORING COLOR INSIDE IMAGES + +Depending on the display, the number of bits used to store a pixel color +can change. The user usually represents a color in RGB mode, using +one byte for each component (see +.B mlx_pixel_put +manual). This must be translated to fit the +.I bits_per_pixel +requirement of the image, and make the color understandable to the X-Server. +That is the purpose of the +.B mlx_get_color_value +() function. It takes a standard RGB +.I color +parameter, and returns an +.I unsigned int +value. +The +.I bits_per_pixel +least significant bits of this value can be stored in the image. + +Keep in mind that the least significant bits position depends on the local +computer's endian. If the endian of the image (in fact the endian of +the X-Server's computer) differs from the local endian, then the value should +be transformed before being used. + +.SH XPM IMAGES + +The +.B mlx_xpm_to_image +() and +.B mlx_xpm_file_to_image +() functions will create a new image the same way. +They will fill it using the specified +.I xpm_data +or +.I filename +, depending on which function is used. +Note that MiniLibX does not use the standard +Xpm library to deal with xpm images. You may not be able to +read all types of xpm images. It however handles transparency. + +.SH RETURN VALUES +The three functions that create images, +.B mlx_new_image() +, +.B mlx_xpm_to_image() +and +.B mlx_xpm_file_to_image() +, will return NULL if an error occurs. Otherwise they return a non-null pointer +as an image identifier. + + +.SH SEE ALSO +mlx(3), mlx_new_window(3), mlx_pixel_put(3), mlx_loop(3) + +.SH AUTHOR +Copyright ol@ - 2002-2014 - Olivier Crouzet diff --git a/minilibx-linux/man/man3/mlx_new_window.3 b/minilibx-linux/man/man3/mlx_new_window.3 new file mode 100644 index 0000000..90f6d47 --- /dev/null +++ b/minilibx-linux/man/man3/mlx_new_window.3 @@ -0,0 +1,79 @@ +.TH MiniLibX 3 "September 19, 2002" +.SH NAME +MiniLibX - Managing windows +.SH SYNOPSYS + +.nf +.I void * +.fi +.B mlx_new_window +( +.I void *mlx_ptr, int size_x, int size_y, char *title +); + +.nf +.I int +.fi +.B mlx_clear_window +( +.I void *mlx_ptr, void *win_ptr +); + +.nf +.I int +.fi +.B mlx_destroy_window +( +.I void *mlx_ptr, void *win_ptr +); + + +.SH DESCRIPTION +The +.B mlx_new_window +() function creates a new window on the screen, using the +.I size_x +and +.I size_y +parameters to determine its size, and +.I title +as the text that should be displayed in the window's title bar. +The +.I mlx_ptr +parameter is the connection identifier returned by +.B mlx_init +() (see the +.B mlx +man page). +.B mlx_new_window +() returns a +.I void * +window identifier that can be used by other MiniLibX calls. +Note that the MiniLibX +can handle an arbitrary number of separate windows. + +.B mlx_clear_window +() and +.B mlx_destroy_window +() respectively clear (in black) and destroy the given window. They both have +the same parameters: +.I mlx_ptr +is the screen connection identifier, and +.I win_ptr +is a window identifier. + +.SH RETURN VALUES +If +.B mlx_new_window() +fails to create a new window (for wathever reason), it will return NULL, +otherwise a non-null pointer is returned as a window identifier. +.B mlx_clear_window +and +.B mlx_destroy_window +right now return nothing. + +.SH SEE ALSO +mlx(3), mlx_pixel_put(3), mlx_new_image(3), mlx_loop(3) + +.SH AUTHOR +Copyright ol@ - 2002-2014 - Olivier Crouzet diff --git a/minilibx-linux/man/man3/mlx_pixel_put.3 b/minilibx-linux/man/man3/mlx_pixel_put.3 new file mode 100644 index 0000000..f4d131e --- /dev/null +++ b/minilibx-linux/man/man3/mlx_pixel_put.3 @@ -0,0 +1,81 @@ +.TH MiniLibX 3 "September 19, 2002" +.SH NAME +MiniLibX - Drawing inside windows +.SH SYNOPSYS + +.nf +.I int +.fi +.B mlx_pixel_put +( +.I void *mlx_ptr, void *win_ptr, int x, int y, int color +); + +.nf +.I int +.fi +.B mlx_string_put +( +.I void *mlx_ptr, void *win_ptr, int x, int y, int color, char *string +); + + +.SH DESCRIPTION +The +.B mlx_pixel_put +() function draws a defined pixel in the window +.I win_ptr +using the ( +.I x +, +.I y +) coordinates, and the specified +.I color +\&. The origin (0,0) is the upper left corner of the window, the x and y axis +respectively pointing right and down. The connection +identifier, +.I mlx_ptr +, is needed (see the +.B mlx +man page). + +Parameters for +.B mlx_string_put +() have the same meaning. Instead of a simple pixel, the specified +.I string +will be displayed at ( +.I x +, +.I y +). + +In both functions, it is impossible to display anything outside the +specified window, nor display in another window in front of the selected one. + +.SH COLOR MANAGEMENT +The +.I color +parameter has an integer type. The displayed color needs to be encoded +in this integer, following a defined scheme. All displayable colors +can be split in 3 basic colors: red, green and blue. Three associated +values, in the 0-255 range, represent how much of each color is mixed up +to create the original color. Theses three values must be set inside the +integer to display the right color. The three least significant bytes of +this integer are filled as shown in the picture below: + +.nf + | 0 | R | G | B | color integer + +---+---+---+---+ +.fi + + +While filling the integer, make sure you avoid endian problems. Remember +that the "blue" byte should always be the least significant one. + + +.SH SEE ALSO +mlx(3), mlx_new_window(3), mlx_new_image(3), mlx_loop(3) + + +.SH AUTHOR +Copyright ol@ - 2002-2014 - Olivier Crouzet diff --git a/minilibx-linux/mlx.h b/minilibx-linux/mlx.h new file mode 100644 index 0000000..b323412 --- /dev/null +++ b/minilibx-linux/mlx.h @@ -0,0 +1,139 @@ +/* +** mlx.h for MinilibX in +** +** Made by Charlie Root +** Login +** +** Started on Mon Jul 31 16:37:50 2000 Charlie Root +** Last update Tue May 15 16:23:28 2007 Olivier Crouzet +*/ + +/* +** MinilibX - Please report bugs +*/ + + +/* +** FR msg - FR msg - FR msg +** +** La MinilibX utilise 2 librairies supplementaires qu'il +** est necessaire de rajouter a la compilation : +** -lmlx -lXext -lX11 +** +** La MinilibX permet le chargement des images de type Xpm. +** Notez que cette implementation est incomplete. +** Merci de communiquer tout probleme de chargement d'image +** de ce type. +*/ + + +#ifndef MLX_H + +#define MLX_H + + +void *mlx_init(); +/* +** needed before everything else. +** return (void *)0 if failed +*/ + + +/* +** Basic actions +*/ + +void *mlx_new_window(void *mlx_ptr, int size_x, int size_y, char *title); +/* +** return void *0 if failed +*/ +int mlx_clear_window(void *mlx_ptr, void *win_ptr); +int mlx_pixel_put(void *mlx_ptr, void *win_ptr, int x, int y, int color); +/* +** origin for x & y is top left corner of the window +** y down is positive +** color is 0x00RRGGBB +*/ + + +/* +** Image stuff +*/ + +void *mlx_new_image(void *mlx_ptr,int width,int height); +/* +** return void *0 if failed +** obsolete : image2 data is stored using bit planes +** void *mlx_new_image2(void *mlx_ptr,int width,int height); +*/ +char *mlx_get_data_addr(void *img_ptr, int *bits_per_pixel, + int *size_line, int *endian); +/* +** endian : 0 = sever X is little endian, 1 = big endian +** for mlx_new_image2, 2nd arg of mlx_get_data_addr is number_of_planes +*/ +int mlx_put_image_to_window(void *mlx_ptr, void *win_ptr, void *img_ptr, + int x, int y); +int mlx_get_color_value(void *mlx_ptr, int color); + + +/* +** dealing with Events +*/ + +int mlx_mouse_hook (void *win_ptr, int (*funct_ptr)(), void *param); +int mlx_key_hook (void *win_ptr, int (*funct_ptr)(), void *param); +int mlx_expose_hook (void *win_ptr, int (*funct_ptr)(), void *param); + +int mlx_loop_hook (void *mlx_ptr, int (*funct_ptr)(), void *param); +int mlx_loop (void *mlx_ptr); +int mlx_loop_end (void *mlx_ptr); + +/* +** hook funct are called as follow : +** +** expose_hook(void *param); +** key_hook(int keycode, void *param); +** mouse_hook(int button, int x,int y, void *param); +** loop_hook(void *param); +** +*/ + + +/* +** Usually asked... +*/ + +int mlx_string_put(void *mlx_ptr, void *win_ptr, int x, int y, int color, + char *string); +void mlx_set_font(void *mlx_ptr, void *win_ptr, char *name); +void *mlx_xpm_to_image(void *mlx_ptr, char **xpm_data, + int *width, int *height); +void *mlx_xpm_file_to_image(void *mlx_ptr, char *filename, + int *width, int *height); +int mlx_destroy_window(void *mlx_ptr, void *win_ptr); + +int mlx_destroy_image(void *mlx_ptr, void *img_ptr); + +int mlx_destroy_display(void *mlx_ptr); + +/* +** generic hook system for all events, and minilibX functions that +** can be hooked. Some macro and defines from X11/X.h are needed here. +*/ + +int mlx_hook(void *win_ptr, int x_event, int x_mask, + int (*funct)(), void *param); + +int mlx_do_key_autorepeatoff(void *mlx_ptr); +int mlx_do_key_autorepeaton(void *mlx_ptr); +int mlx_do_sync(void *mlx_ptr); + +int mlx_mouse_get_pos(void *mlx_ptr, void *win_ptr, int *x, int *y); +int mlx_mouse_move(void *mlx_ptr, void *win_ptr, int x, int y); +int mlx_mouse_hide(void *mlx_ptr, void *win_ptr); +int mlx_mouse_show(void *mlx_ptr, void *win_ptr); + +int mlx_get_screen_size(void *mlx_ptr, int *sizex, int *sizey); + +#endif /* MLX_H */ diff --git a/minilibx-linux/mlx_clear_window.c b/minilibx-linux/mlx_clear_window.c new file mode 100644 index 0000000..f621090 --- /dev/null +++ b/minilibx-linux/mlx_clear_window.c @@ -0,0 +1,21 @@ +/* +** mlx_clear_window.c for MiniLibX in +** +** Made by Charlie Root +** Login +** +** Started on Thu Sep 7 19:46:15 2000 Charlie Root +** Last update Tue Sep 25 17:11:19 2001 Charlie Root +*/ + + + +#include "mlx_int.h" + + +int mlx_clear_window(t_xvar *xvar,t_win_list *win) +{ + XClearWindow(xvar->display,win->window); + if (xvar->do_flush) + XFlush(xvar->display); +} diff --git a/minilibx-linux/mlx_destroy_display.c b/minilibx-linux/mlx_destroy_display.c new file mode 100644 index 0000000..d2970b8 --- /dev/null +++ b/minilibx-linux/mlx_destroy_display.c @@ -0,0 +1,18 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* mlx_destroy_display.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: mg +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/10/03 18:56:35 by mg #+# #+# */ +/* Updated: 2020/10/04 01:55:35 by mg ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "mlx_int.h" + +int mlx_destroy_display(t_xvar *xvar) +{ + XCloseDisplay(xvar->display); +} diff --git a/minilibx-linux/mlx_destroy_image.c b/minilibx-linux/mlx_destroy_image.c new file mode 100644 index 0000000..afd4d1a --- /dev/null +++ b/minilibx-linux/mlx_destroy_image.c @@ -0,0 +1,31 @@ +/* +** mlx_destroy_image.c for MinilibX in +** +** Made by Charlie Root +** Login +** +** Started on Tue Mar 12 10:25:15 2002 Charlie Root +** Last update Tue May 15 16:45:54 2007 Olivier Crouzet +*/ + + +#include "mlx_int.h" + + +int mlx_destroy_image(t_xvar *xvar, t_img *img) +{ + if (img->type == MLX_TYPE_SHM_PIXMAP || + img->type == MLX_TYPE_SHM) + { + XShmDetach(xvar->display, &(img->shm)); + shmdt(img->shm.shmaddr); + /* shmctl IPC_RMID already done */ + } + XDestroyImage(img->image); /* For image & shm-image. Also free img->data */ + XFreePixmap(xvar->display, img->pix); + if (img->gc) + XFreeGC(xvar->display, img->gc); + free(img); + if (xvar->do_flush) + XFlush(xvar->display); +} diff --git a/minilibx-linux/mlx_destroy_window.c b/minilibx-linux/mlx_destroy_window.c new file mode 100644 index 0000000..464790c --- /dev/null +++ b/minilibx-linux/mlx_destroy_window.c @@ -0,0 +1,38 @@ +/* +** mlx_destroy_window.c for MinilibX in +** +** Made by Charlie Root +** Login +** +** Started on Tue Mar 12 10:25:15 2002 Charlie Root +** Last update Tue May 15 16:46:08 2007 Olivier Crouzet +*/ + + +#include "mlx_int.h" + + +int mlx_destroy_window(t_xvar *xvar,t_win_list *win) +{ + t_win_list *w; + t_win_list *prev; + t_win_list first; + + first.next = xvar->win_list; + prev = &first; + w = prev->next; + while (w) + { + if (w==win) + prev->next = w->next; + else + prev = w; + w = w->next; + } + xvar->win_list = first.next; + XDestroyWindow(xvar->display,win->window); + XFreeGC(xvar->display,win->gc); + free(win); + if (xvar->do_flush) + XFlush(xvar->display); +} diff --git a/minilibx-linux/mlx_expose_hook.c b/minilibx-linux/mlx_expose_hook.c new file mode 100644 index 0000000..b00b675 --- /dev/null +++ b/minilibx-linux/mlx_expose_hook.c @@ -0,0 +1,22 @@ +/* +** mlx_expose_hook.c for MiniLibX in +** +** Made by Charlie Root +** Login +** +** Started on Thu Aug 3 11:49:06 2000 Charlie Root +** Last update Fri Feb 23 17:07:42 2001 Charlie Root +*/ + + +#include "mlx_int.h" + + + + +int mlx_expose_hook(t_win_list *win,int (*funct)(),void *param) +{ + win->hooks[Expose].hook = funct; + win->hooks[Expose].param = param; + win->hooks[Expose].mask = ExposureMask; +} diff --git a/minilibx-linux/mlx_ext_randr.c b/minilibx-linux/mlx_ext_randr.c new file mode 100644 index 0000000..34ddb91 --- /dev/null +++ b/minilibx-linux/mlx_ext_randr.c @@ -0,0 +1,104 @@ + + + +#include "mlx_int.h" + +#include +#include + +/* global for independant extension */ + +RRMode saved_mode = 0; + + +int mlx_ext_fullscreen(t_xvar *xvar, t_win_list *win, int fullscreen) +{ + XWindowAttributes watt; + int i; + int j; + XRRScreenResources *res; + XRROutputInfo *o_info; + XRRCrtcInfo *crtc; + RRMode mode_candidate; + int idx_output; + int idx_candidate; + + if (!XGetWindowAttributes(xvar->display, win->window, &watt)) + return (0); + + res = XRRGetScreenResources(xvar->display, xvar->root); + o_info = NULL; + idx_output = -1; + i = res->noutput; + while (i--) + { + o_info = XRRGetOutputInfo(xvar->display, res, res->outputs[i]); + if (o_info->connection == RR_Connected) + { + idx_output = i; + i = 0; + } + else + XRRFreeOutputInfo(o_info); + } + if (!o_info) + { + XRRFreeScreenResources(res); + return (0); + } + + idx_candidate = -1; + i = o_info->nmode; + while (i--) + { + j = res->nmode; + while (j--) + if (res->modes[j].id == o_info->modes[i]) + if (res->modes[j].width >= watt.width && res->modes[j].height >= watt.height && + (idx_candidate == -1 || res->modes[idx_candidate].width > res->modes[j].width || + res->modes[idx_candidate].height > res->modes[j].height) ) + idx_candidate = i; + } + if (idx_candidate < 0) + { + XRRFreeOutputInfo(o_info); + XRRFreeScreenResources(res); + return (0); + } + if (!fullscreen && saved_mode == -1) + idx_candidate = 0; /* if no clue, uses first mode, usually part of npreferred */ + mode_candidate = o_info->modes[idx_candidate]; + if (!fullscreen) + mode_candidate = saved_mode; + + crtc = XRRGetCrtcInfo(xvar->display, res, o_info->crtc); + saved_mode = crtc->mode; + + i = XRRSetCrtcConfig(xvar->display, res, o_info->crtc, CurrentTime, 0, 0, mode_candidate, + crtc->rotation, &res->outputs[idx_output], 1); + if (fullscreen) + printf("found mode : %d x %d\n Status %d\n", res->modes[idx_candidate].width, res->modes[idx_candidate].height, i); + else + printf("back previous mode\n"); + + XMoveWindow(xvar->display, win->window, 0, 0); + XMapRaised(xvar->display, win->window); + + if (fullscreen) + { + // XGrabPointer(xvar->display, win->window, True, 0, GrabModeAsync, GrabModeAsync, win->window, 0L, CurrentTime); + XGrabKeyboard(xvar->display, win->window, False, GrabModeAsync, GrabModeAsync, CurrentTime); + } + else + { + XUngrabPointer(xvar->display, CurrentTime); + XUngrabKeyboard(xvar->display, CurrentTime); + } + + XSync(xvar->display, False); + sleep(1); + + XRRFreeCrtcInfo(crtc); + XRRFreeOutputInfo(o_info); + XRRFreeScreenResources(res); +} diff --git a/minilibx-linux/mlx_flush_event.c b/minilibx-linux/mlx_flush_event.c new file mode 100644 index 0000000..1e586ad --- /dev/null +++ b/minilibx-linux/mlx_flush_event.c @@ -0,0 +1,25 @@ +/* +** mlx_flush_event.c for MiniLibX in +** +** Made by Charlie Root +** Login +** +** Started on Wed Aug 2 18:58:11 2000 Charlie Root +** Last update Fri Feb 23 17:08:48 2001 Charlie Root +*/ + + +#include "mlx_int.h" + + + + +int mlx_flush_event(t_xvar *xvar) +{ + XEvent ev; + + while (XPending(xvar->display)) + { + XNextEvent(xvar->display,&ev); + } +} diff --git a/minilibx-linux/mlx_get_color_value.c b/minilibx-linux/mlx_get_color_value.c new file mode 100644 index 0000000..b620970 --- /dev/null +++ b/minilibx-linux/mlx_get_color_value.c @@ -0,0 +1,33 @@ +/* +** mlx_get_color_value.c for MiniLibX in +** +** Made by Charlie Root +** Login +** +** Started on Mon Jul 31 19:01:33 2000 Charlie Root +** Last update Thu Oct 4 15:04:13 2001 Charlie Root +*/ + + +#include "mlx_int.h" + + +int mlx_get_color_value(t_xvar *xvar,int color) +{ + return(mlx_int_get_good_color(xvar,color)); +} + +int mlx_int_get_good_color(t_xvar *xvar,int color) +{ + XColor xc; + + if (xvar->depth>=24) + return (color); + xc.red = (color>>8)&0xFF00; + xc.green = color&0xFF00; + xc.blue = (color<<8)&0xFF00; + xc.pixel = ((xc.red>>(16-xvar->decrgb[1]))<decrgb[0])+ + ((xc.green>>(16-xvar->decrgb[3]))<decrgb[2])+ + ((xc.blue>>(16-xvar->decrgb[5]))<decrgb[4]); + return (xc.pixel); +} diff --git a/minilibx-linux/mlx_get_data_addr.c b/minilibx-linux/mlx_get_data_addr.c new file mode 100644 index 0000000..45e7a85 --- /dev/null +++ b/minilibx-linux/mlx_get_data_addr.c @@ -0,0 +1,23 @@ +/* +** mlx_get_data_addr.c for MiniLibX in raytraceur +** +** Made by Charlie Root +** Login +** +** Started on Mon Aug 14 15:45:57 2000 Charlie Root +** Last update Thu Sep 27 19:05:25 2001 Charlie Root +*/ + + + +#include "mlx_int.h" + + +char *mlx_get_data_addr(t_img *img,int *bits_per_pixel, + int *size_line,int *endian) +{ + *bits_per_pixel = img->bpp; + *size_line = img->size_line; + *endian = img->image->byte_order; + return (img->data); +} diff --git a/minilibx-linux/mlx_hook.c b/minilibx-linux/mlx_hook.c new file mode 100644 index 0000000..98e509a --- /dev/null +++ b/minilibx-linux/mlx_hook.c @@ -0,0 +1,40 @@ +/* +** mlx_hook.c for MiniLibX in +** +** Made by Charlie Root +** Login +** +** Started on Thu Aug 3 11:49:06 2000 Charlie Root +** Last update Fri Jan 28 17:05:28 2005 Olivier Crouzet +*/ + + +#include "mlx_int.h" + + + + +int mlx_hook(t_win_list *win, int x_event, int x_mask, + int (*funct)(),void *param) +{ + win->hooks[x_event].hook = funct; + win->hooks[x_event].param = param; + win->hooks[x_event].mask = x_mask; +} + + +int mlx_do_key_autorepeatoff(t_xvar *xvar) +{ + XAutoRepeatOff(xvar->display); +} + +int mlx_do_key_autorepeaton(t_xvar *xvar) +{ + XAutoRepeatOn(xvar->display); +} + + +int mlx_do_sync(t_xvar *xvar) +{ + XSync(xvar->display, False); +} diff --git a/minilibx-linux/mlx_init.c b/minilibx-linux/mlx_init.c new file mode 100644 index 0000000..c9d7463 --- /dev/null +++ b/minilibx-linux/mlx_init.c @@ -0,0 +1,99 @@ +/* +** mlx_init.c for MiniLibX in +** +** Made by Charlie Root +** Login +** +** Started on Mon Jul 31 16:52:42 2000 Charlie Root +** Last update Fri Jan 28 17:05:09 2005 Olivier Crouzet +*/ + + +#include "mlx_int.h" + + + +void *mlx_init() +{ + t_xvar *xvar; + + if (!(xvar = malloc(sizeof(*xvar)))) + return ((void*)0); + if ((xvar->display = XOpenDisplay("")) == 0) + { + free(xvar); + return ((void*)0); + } + xvar->screen = DefaultScreen(xvar->display); + xvar->root = DefaultRootWindow(xvar->display); + xvar->cmap = DefaultColormap(xvar->display,xvar->screen); + xvar->depth = DefaultDepth(xvar->display,xvar->screen); + if (mlx_int_get_visual(xvar)==-1) + { + printf(ERR_NO_TRUECOLOR); + exit(1); + } + xvar->win_list = 0; + xvar->loop_hook = 0; + xvar->loop_param = (void *)0; + xvar->do_flush = 1; + xvar->wm_delete_window = XInternAtom (xvar->display, "WM_DELETE_WINDOW", False); + xvar->wm_protocols = XInternAtom (xvar->display, "WM_PROTOCOLS", False); + mlx_int_deal_shm(xvar); + if (xvar->private_cmap) + xvar->cmap = XCreateColormap(xvar->display,xvar->root, + xvar->visual,AllocNone); + mlx_int_rgb_conversion(xvar); + xvar->end_loop = 0; + return (xvar); +} + + +/* +** pshm_format of -1 : Not XYBitmap|XYPixmap|ZPixmap +** alpha libX need a check of the DISPLAY env var, or shm is allowed +** in remote Xserver connections. +*/ + +int mlx_int_deal_shm(t_xvar *xvar) +{ + int use_pshm; + int bidon; + char *dpy; + char buff[33]; + + xvar->use_xshm = XShmQueryVersion(xvar->display,&bidon,&bidon,&(use_pshm)); + if (xvar->use_xshm && use_pshm) + xvar->pshm_format = XShmPixmapFormat(xvar->display); + else + xvar->pshm_format = -1; + gethostname(buff,32); + dpy = getenv(ENV_DISPLAY); + if (dpy && strlen(dpy) && *dpy!=':' && strncmp(dpy,buff,strlen(buff)) && + strncmp(dpy,LOCALHOST,strlen(LOCALHOST)) ) + { + xvar->pshm_format = -1; + xvar->use_xshm = 0; + } +} + +/* +** TrueColor Visual is needed to have *_mask correctly set +*/ + +int mlx_int_rgb_conversion(t_xvar *xvar) +{ + bzero(xvar->decrgb,sizeof(int)*6); + while (!(xvar->visual->red_mask&1)) + { xvar->visual->red_mask >>= 1; xvar->decrgb[0] ++; } + while (xvar->visual->red_mask&1) + { xvar->visual->red_mask >>= 1; xvar->decrgb[1] ++; } + while (!(xvar->visual->green_mask&1)) + { xvar->visual->green_mask >>= 1; xvar->decrgb[2] ++; } + while (xvar->visual->green_mask&1) + { xvar->visual->green_mask >>= 1; xvar->decrgb[3] ++; } + while (!(xvar->visual->blue_mask&1)) + { xvar->visual->blue_mask >>= 1; xvar->decrgb[4] ++; } + while (xvar->visual->blue_mask&1) + { xvar->visual->blue_mask >>= 1; xvar->decrgb[5] ++; } +} diff --git a/minilibx-linux/mlx_int.h b/minilibx-linux/mlx_int.h new file mode 100644 index 0000000..c49d1b7 --- /dev/null +++ b/minilibx-linux/mlx_int.h @@ -0,0 +1,140 @@ +/* +** mlx_int.h for mlx in +** +** Made by Charlie Root +** Login +** +** Started on Mon Jul 31 16:45:48 2000 Charlie Root +** Last update Wed May 25 16:44:16 2011 Olivier Crouzet +*/ + + + +/* +** Internal settings for MiniLibX +*/ + +#ifndef MLX_INT_H + +# define MLX_INT_H + +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +/* #include */ + + +# define MLX_TYPE_SHM_PIXMAP 3 +# define MLX_TYPE_SHM 2 +# define MLX_TYPE_XIMAGE 1 + +# define MLX_MAX_EVENT LASTEvent + + +# define ENV_DISPLAY "DISPLAY" +# define LOCALHOST "localhost" +# define ERR_NO_TRUECOLOR "MinilibX Error : No TrueColor Visual available.\n" +# define WARN_SHM_ATTACH "MinilibX Warning : X server can't attach shared memory.\n" + + +typedef struct s_xpm_col +{ + int name; + int col; +} t_xpm_col; + + +struct s_col_name +{ + char *name; + int color; +}; + +typedef struct s_event_list +{ + int mask; + int (*hook)(); + void *param; +} t_event_list; + + +typedef struct s_win_list +{ + Window window; + GC gc; + struct s_win_list *next; + int (*mouse_hook)(); + int (*key_hook)(); + int (*expose_hook)(); + void *mouse_param; + void *key_param; + void *expose_param; + t_event_list hooks[MLX_MAX_EVENT]; +} t_win_list; + + +typedef struct s_img +{ + XImage *image; + Pixmap pix; + GC gc; + int size_line; + int bpp; + int width; + int height; + int type; + int format; + char *data; + XShmSegmentInfo shm; +} t_img; + +typedef struct s_xvar +{ + Display *display; + Window root; + int screen; + int depth; + Visual *visual; + Colormap cmap; + int private_cmap; + t_win_list *win_list; + int (*loop_hook)(); + void *loop_param; + int use_xshm; + int pshm_format; + int do_flush; + int decrgb[6]; + Atom wm_delete_window; + Atom wm_protocols; + int end_loop; +} t_xvar; + + +int mlx_int_do_nothing(); +int mlx_get_color_value(); +int mlx_int_get_good_color(); +int mlx_int_find_in_pcm(); +int mlx_int_anti_resize_win(); +int mlx_int_wait_first_expose(); +int mlx_int_rgb_conversion(); +int mlx_int_deal_shm(); +void *mlx_int_new_xshm_image(); +char **mlx_int_str_to_wordtab(); +void *mlx_new_image(); +int shm_att_pb(); +int mlx_int_get_visual(t_xvar *xvar); +int mlx_int_set_win_event_mask(t_xvar *xvar); +int mlx_int_str_str_cote(char *str,char *find,int len); +int mlx_int_str_str(char *str,char *find,int len); + + +#endif diff --git a/minilibx-linux/mlx_int_anti_resize_win.c b/minilibx-linux/mlx_int_anti_resize_win.c new file mode 100644 index 0000000..2f20b44 --- /dev/null +++ b/minilibx-linux/mlx_int_anti_resize_win.c @@ -0,0 +1,28 @@ +/* +** mlx_int_anti_resize_win.c for MiniLibX in +** +** Made by Charlie Root +** Login +** +** Started on Tue Aug 8 14:31:05 2000 Charlie Root +** Last update Tue Sep 25 15:56:58 2001 Charlie Root +*/ + +#include "mlx_int.h" + + +int mlx_int_anti_resize_win(t_xvar *xvar,Window win,int w,int h) +{ + XSizeHints hints; + long toto; + + XGetWMNormalHints(xvar->display,win,&hints,&toto); + hints.width = w; + hints.height = h; + hints.min_width = w; + hints.min_height = h; + hints.max_width = w; + hints.max_height = h; + hints.flags = PPosition | PSize | PMinSize | PMaxSize; + XSetWMNormalHints(xvar->display,win,&hints); +} diff --git a/minilibx-linux/mlx_int_do_nothing.c b/minilibx-linux/mlx_int_do_nothing.c new file mode 100644 index 0000000..49524e4 --- /dev/null +++ b/minilibx-linux/mlx_int_do_nothing.c @@ -0,0 +1,16 @@ +/* +** mlx_int_do_nothing.c for MiniLibX in +** +** Made by Charlie Root +** Login +** +** Started on Tue Aug 8 12:58:24 2000 Charlie Root +** Last update Tue Sep 25 15:56:22 2001 Charlie Root +*/ + + + +int mlx_int_do_nothing(void *param) +{ + +} diff --git a/minilibx-linux/mlx_int_get_visual.c b/minilibx-linux/mlx_int_get_visual.c new file mode 100644 index 0000000..440a7ca --- /dev/null +++ b/minilibx-linux/mlx_int_get_visual.c @@ -0,0 +1,39 @@ +/* +** mlx_int_get_visual.c for MinilibX in +** +** Made by Charlie Root +** Login +** +** Started on Wed Oct 3 17:01:51 2001 Charlie Root +** Last update Thu Oct 4 15:00:45 2001 Charlie Root +*/ + + + +#include "mlx_int.h" + + +/* +** We need a private colormap for non-default Visual. +*/ + + +int mlx_int_get_visual(t_xvar *xvar) +{ + XVisualInfo *vi; + XVisualInfo template; + int nb_item; + + xvar->private_cmap = 0; + xvar->visual = DefaultVisual(xvar->display,xvar->screen); + if (xvar->visual->class == TrueColor) + return (0); + template.class = TrueColor; + template.depth = xvar->depth; + if (!(vi = XGetVisualInfo(xvar->display,VisualDepthMask|VisualClassMask, + &template,&nb_item)) ) + return (-1); + xvar->visual = vi->visual; + xvar->private_cmap = 1; + return (0); +} diff --git a/minilibx-linux/mlx_int_param_event.c b/minilibx-linux/mlx_int_param_event.c new file mode 100644 index 0000000..8756a22 --- /dev/null +++ b/minilibx-linux/mlx_int_param_event.c @@ -0,0 +1,100 @@ +/* +** mlx_int_param_event.c for MinilibX in +** +** Made by Charlie Root +** Login +** +** Started on Mon Jul 31 16:37:50 2000 Charlie Root +** Last update Wed Oct 6 13:14:52 2004 Olivier Crouzet +*/ + +#include "mlx_int.h" + +int mlx_int_param_undef() +{ +} + +int mlx_int_param_KeyPress(t_xvar *xvar, XEvent *ev, t_win_list *win) +{ + win->hooks[KeyPress].hook(XkbKeycodeToKeysym(xvar->display, + ev->xkey.keycode, 0, 0), + win->hooks[KeyPress].param); +} + +int mlx_int_param_KeyRelease(t_xvar *xvar, XEvent *ev, t_win_list *win) +{ + win->hooks[KeyRelease].hook(XkbKeycodeToKeysym(xvar->display, + ev->xkey.keycode, 0, 0), + win->hooks[KeyRelease].param); +} + +int mlx_int_param_ButtonPress(t_xvar *xvar, XEvent *ev, t_win_list *win) +{ + win->hooks[ButtonPress].hook(ev->xbutton.button,ev->xbutton.x,ev->xbutton.y, + win->hooks[ButtonPress].param); +} + +int mlx_int_param_ButtonRelease(t_xvar *xvar, XEvent *ev, t_win_list *win) +{ + win->hooks[ButtonRelease].hook(ev->xbutton.button, + ev->xbutton.x, ev->xbutton.y, + win->hooks[ButtonRelease].param); +} + +int mlx_int_param_MotionNotify(t_xvar *xvar, XEvent *ev, t_win_list *win) +{ + win->hooks[MotionNotify].hook(ev->xbutton.x,ev->xbutton.y, + win->hooks[MotionNotify].param); +} + +int mlx_int_param_Expose(t_xvar *xvar, XEvent *ev, t_win_list *win) +{ + if (!ev->xexpose.count) + win->hooks[Expose].hook(win->hooks[Expose].param); +} + + +int mlx_int_param_generic(t_xvar *xvar, XEvent *ev, t_win_list *win) +{ + win->hooks[ev->type].hook(win->hooks[ev->type].param); +} + +int (*(mlx_int_param_event[]))() = +{ + mlx_int_param_undef, /* 0 */ + mlx_int_param_undef, + mlx_int_param_KeyPress, + mlx_int_param_KeyRelease, /* 3 */ + mlx_int_param_ButtonPress, + mlx_int_param_ButtonRelease, + mlx_int_param_MotionNotify, /* 6 */ + mlx_int_param_generic, + mlx_int_param_generic, + mlx_int_param_generic, + mlx_int_param_generic, + mlx_int_param_generic, + mlx_int_param_Expose, /* 12 */ + mlx_int_param_generic, + mlx_int_param_generic, + mlx_int_param_generic, + mlx_int_param_generic, + mlx_int_param_generic, + mlx_int_param_generic, + mlx_int_param_generic, + mlx_int_param_generic, + mlx_int_param_generic, + mlx_int_param_generic, + mlx_int_param_generic, + mlx_int_param_generic, + mlx_int_param_generic, + mlx_int_param_generic, + mlx_int_param_generic, + mlx_int_param_generic, + mlx_int_param_generic, + mlx_int_param_generic, + mlx_int_param_generic, + mlx_int_param_generic, + mlx_int_param_generic, + mlx_int_param_generic, + mlx_int_param_generic +}; diff --git a/minilibx-linux/mlx_int_set_win_event_mask.c b/minilibx-linux/mlx_int_set_win_event_mask.c new file mode 100644 index 0000000..55650cd --- /dev/null +++ b/minilibx-linux/mlx_int_set_win_event_mask.c @@ -0,0 +1,34 @@ +/* +** mlx_int_set_win_event_mask.c for MiniLibX in +** +** Made by Charlie Root +** Login +** +** Started on Thu Aug 3 11:49:06 2000 Charlie Root +** Last update Fri Feb 23 17:07:42 2001 Charlie Root +*/ + + +#include "mlx_int.h" + + + + +int mlx_int_set_win_event_mask(t_xvar *xvar) +{ + t_win_list *win; + int mask; + int i; + XSetWindowAttributes xwa; + + win = xvar->win_list; + while (win) + { + xwa.event_mask = 0; + i = MLX_MAX_EVENT; + while (i--) + xwa.event_mask |= win->hooks[i].mask; + XChangeWindowAttributes(xvar->display, win->window, CWEventMask, &xwa); + win = win->next; + } +} diff --git a/minilibx-linux/mlx_int_str_to_wordtab.c b/minilibx-linux/mlx_int_str_to_wordtab.c new file mode 100644 index 0000000..7f92089 --- /dev/null +++ b/minilibx-linux/mlx_int_str_to_wordtab.c @@ -0,0 +1,113 @@ +/* +** mlx_int_str_to_wordtab.c for MinilibX in +** +** Made by Charlie Root +** Login +** +** Started on Wed Sep 13 11:36:09 2000 Charlie Root +** Last update Fri Dec 14 11:02:09 2001 Charlie Root +*/ + + +#include "mlx_int.h" + + +int mlx_int_str_str(char *str,char *find,int len) +{ + int len_f; + int pos; + char *s; + char *f; + + len_f = strlen(find); + if (len_f>len) + return (-1); + pos = 0; + while (*(str+len_f-1)) + { + s = str; + f = find; + while (*(f++) == *(s++)) + if (!*f) + return (pos); + str ++; + pos ++; + } + return (-1); +} + + + +int mlx_int_str_str_cote(char *str,char *find,int len) +{ + int len_f; + int pos; + char *s; + char *f; + int cote; + + len_f = strlen(find); + if (len_f>len) + return (-1); + cote = 0; + pos = 0; + while (*(str+len_f-1)) + { + if (*str=='"') + cote = 1-cote; + if (!cote) + { + s = str; + f = find; + while (*(f++) == *(s++)) + if (!*f) + return (pos); + } + str ++; + pos ++; + } + return (-1); +} + + +char **mlx_int_str_to_wordtab(char *str) +{ + char **tab; + int pos; + int nb_word; + int len; + + len = strlen(str); + nb_word = 0; + pos = 0; + while (pos +** +** Started on Tue Oct 17 09:26:45 2000 olivier crouzet +** Last update Fri Feb 23 17:27:10 2001 Charlie Root +*/ + + + +#include "mlx_int.h" + + + +int mlx_int_wait_first_expose(t_xvar *xvar,Window win) +{ + XEvent ev; + + XWindowEvent(xvar->display,win,ExposureMask,&ev); + XPutBackEvent(xvar->display,&ev); +} diff --git a/minilibx-linux/mlx_key_hook.c b/minilibx-linux/mlx_key_hook.c new file mode 100644 index 0000000..eea6484 --- /dev/null +++ b/minilibx-linux/mlx_key_hook.c @@ -0,0 +1,22 @@ +/* +** mlx_key_hook.c for MiniLibX in +** +** Made by Charlie Root +** Login +** +** Started on Thu Aug 3 11:49:06 2000 Charlie Root +** Last update Fri Feb 23 17:10:09 2001 Charlie Root +*/ + + +#include "mlx_int.h" + + + + +int mlx_key_hook(t_win_list *win,int (*funct)(),void *param) +{ + win->hooks[KeyRelease].hook = funct; + win->hooks[KeyRelease].param = param; + win->hooks[KeyRelease].mask = KeyReleaseMask; +} diff --git a/minilibx-linux/mlx_lib_xpm.c b/minilibx-linux/mlx_lib_xpm.c new file mode 100644 index 0000000..b8cf184 --- /dev/null +++ b/minilibx-linux/mlx_lib_xpm.c @@ -0,0 +1,96 @@ +/* +** mlx_xpm.c for minilibX in +** +** Made by Charlie Root +** Login +** +** Started on Fri Dec 8 11:07:24 2000 Charlie Root +** Last update Thu Oct 4 16:00:22 2001 Charlie Root +*/ + + +#include "mlx_int.h" + + + + +void *mlx_int_xpm_f_image(t_xvar *xvar,int *width,int *height, + int (*xpm_func)(),void *param) +{ + XImage *img1; + XImage *img2; + t_img *im2; + XpmAttributes xpm_att; + + xpm_att.visual = xvar->visual; + xpm_att.colormap = xvar->cmap; + xpm_att.depth = xvar->depth; + xpm_att.bitmap_format = ZPixmap; + xpm_att.valuemask = XpmDepth|XpmBitmapFormat|XpmVisual|XpmColormap; + if (xpm_func(xvar->display,param,&img1,&img2,&xpm_att)) + return ((void *)0); + if (img2) + XDestroyImage(img2); + + if (!(im2 = (void *)mlx_new_image(xvar,img1->width,img1->height))) + { + XDestroyImage(img1); + return ((void *)0); + } + *width = img1->width; + *height = img1->height; + if (mlx_int_egal_img(im2->image,img1)) + { + bcopy(img1->data,im2->data,img1->height*img1->bytes_per_line); + XDestroyImage(img1); + return (im2); + } + if (im2->type==MLX_TYPE_SHM_PIXMAP) + { + XFreePixmap(xvar->display,im2->pix); + im2->pix = XCreatePixmap(xvar->display,xvar->root, + *width,*height,xvar->depth); + } + if (im2->type>MLX_TYPE_XIMAGE) + { + XShmDetach(xvar->display,&(im2->shm)); + shmdt(im2->data); + } + XDestroyImage(im2->image); + im2->image = img1; + im2->data = img1->data; + im2->type = MLX_TYPE_XIMAGE; + im2->size_line = img1->bytes_per_line; + im2->bpp = img1->bits_per_pixel; + return (im2); +} + + +int mlx_int_egal_img(XImage *img1,XImage *img2) +{ + if (img1->width!=img2->width || img1->height!=img2->height || + img1->xoffset!=img2->xoffset || img1->format!=img2->format || + img1->byte_order!=img2->byte_order || + img1->bitmap_unit!=img2->bitmap_unit || + img1->bitmap_bit_order!=img2->bitmap_bit_order || + img1->bitmap_pad!=img2->bitmap_pad || img1->depth!=img2->depth || + img1->bytes_per_line!=img2->bytes_per_line || + img1->bits_per_pixel!=img2->bits_per_pixel || + img1->red_mask!=img2->red_mask || img1->green_mask!=img2->green_mask || + img1->blue_mask!=img2->blue_mask ) + return (0); + return (1); +} + + +void *mlx_xpm_file_to_image(t_xvar *xvar,char *filename, + int *width,int *height) +{ + return (mlx_int_xpm_f_image(xvar,width,height,XpmReadFileToImage,filename)); +} + + +void *mlx_xpm_to_image(t_xvar *xvar,char **data,int *width,int *height) +{ + return (mlx_int_xpm_f_image(xvar,width,height,XpmCreateImageFromData,(void *)data)); +} diff --git a/minilibx-linux/mlx_loop.c b/minilibx-linux/mlx_loop.c new file mode 100644 index 0000000..cc4e119 --- /dev/null +++ b/minilibx-linux/mlx_loop.c @@ -0,0 +1,63 @@ +/* +** mlx_loop.c for MiniLibX in +** +** Made by Charlie Root +** Login +** +** Started on Wed Aug 2 18:58:11 2000 Charlie Root +** Last update Fri Sep 30 14:47:41 2005 Olivier Crouzet +*/ + + +#include "mlx_int.h" + +extern int (*(mlx_int_param_event[]))(); + +static int win_count(t_xvar *xvar) +{ + int i; + t_win_list *win; + + i = 0; + win = xvar->win_list; + while (win) + { + win = win->next; + ++i; + } + return (i); +} + +int mlx_loop_end(t_xvar *xvar) +{ + xvar->end_loop = 1; + return (1); +} + +int mlx_loop(t_xvar *xvar) +{ + XEvent ev; + t_win_list *win; + + mlx_int_set_win_event_mask(xvar); + xvar->do_flush = 0; + while (win_count(xvar) && !xvar->end_loop) + { + while (!xvar->end_loop && (!xvar->loop_hook || XPending(xvar->display))) + { + XNextEvent(xvar->display,&ev); + win = xvar->win_list; + while (win && (win->window!=ev.xany.window)) + win = win->next; + + if (win && ev.type == ClientMessage && ev.xclient.message_type == xvar->wm_protocols && ev.xclient.data.l[0] == xvar->wm_delete_window && win->hooks[DestroyNotify].hook) + win->hooks[DestroyNotify].hook(win->hooks[DestroyNotify].param); + if (win && ev.type < MLX_MAX_EVENT && win->hooks[ev.type].hook) + mlx_int_param_event[ev.type](xvar, &ev, win); + } + XSync(xvar->display, False); + if (xvar->loop_hook) + xvar->loop_hook(xvar->loop_param); + } + return (0); +} diff --git a/minilibx-linux/mlx_loop_hook.c b/minilibx-linux/mlx_loop_hook.c new file mode 100644 index 0000000..1f8b9ed --- /dev/null +++ b/minilibx-linux/mlx_loop_hook.c @@ -0,0 +1,21 @@ +/* +** mlx_loop_hook.c for MiniLibX in +** +** Made by Charlie Root +** Login +** +** Started on Thu Aug 3 11:49:06 2000 Charlie Root +** Last update Fri Feb 23 17:11:39 2001 Charlie Root +*/ + + +#include "mlx_int.h" + + + + +int mlx_loop_hook(t_xvar *xvar,int (*funct)(),void *param) +{ + xvar->loop_hook = funct; + xvar->loop_param = param; +} diff --git a/minilibx-linux/mlx_mouse.c b/minilibx-linux/mlx_mouse.c new file mode 100644 index 0000000..ce0d4c9 --- /dev/null +++ b/minilibx-linux/mlx_mouse.c @@ -0,0 +1,48 @@ +#include "mlx_int.h" + +int mlx_mouse_move(t_xvar *xvar, t_win_list *win, int x, int y) +{ + XWarpPointer(xvar->display, None, win->window, 0, 0, 0, 0, x, y); + return (0); +} + +int mlx_mouse_hide(t_xvar *xvar, t_win_list *win) +{ + static char data[1] = {0}; + Cursor cursor; + Pixmap blank; + XColor dummy; + + blank = XCreateBitmapFromData(xvar->display, win->window, data, 1, 1); + cursor = XCreatePixmapCursor(xvar->display, blank, blank, &dummy, &dummy, 0, 0); + XDefineCursor(xvar->display, win->window, cursor); + XFreePixmap(xvar->display, blank); + XFreeCursor(xvar->display, cursor); +} + +int mlx_mouse_show(t_xvar *xvar, t_win_list *win) +{ + XUndefineCursor(xvar->display, win->window); +} + +/* +** Queries the position of the mouse pointer relative to the origin of the +** specified window and saves it to the provided location. +** +** If the pointer is not on the same screen as the specified window, both +** win_x_return and win_y_return are set to zero and the function returns 0. +*/ + +int mlx_mouse_get_pos(t_xvar *xvar, t_win_list *win, \ + int *win_x_return, int *win_y_return) +{ + Window root_return; + Window child_return; + int root_x_return; + int root_y_return; + unsigned mask_return; + + return (XQueryPointer(xvar->display, win->window, \ + &root_return, &child_return, &root_x_return, &root_y_return, \ + win_x_return, win_y_return, &mask_return)); +} diff --git a/minilibx-linux/mlx_mouse_hook.c b/minilibx-linux/mlx_mouse_hook.c new file mode 100644 index 0000000..cb567ab --- /dev/null +++ b/minilibx-linux/mlx_mouse_hook.c @@ -0,0 +1,22 @@ +/* +** mlx_mouse_hook.c for MiniLibX in +** +** Made by Charlie Root +** Login +** +** Started on Thu Aug 3 11:49:06 2000 Charlie Root +** Last update Fri Feb 23 17:11:05 2001 Charlie Root +*/ + + +#include "mlx_int.h" + + + + +int mlx_mouse_hook(t_win_list *win,int (*funct)(),void *param) +{ + win->hooks[ButtonPress].hook = funct; + win->hooks[ButtonPress].param = param; + win->hooks[ButtonPress].mask = ButtonPressMask; +} diff --git a/minilibx-linux/mlx_new_image.c b/minilibx-linux/mlx_new_image.c new file mode 100644 index 0000000..d2cbfc1 --- /dev/null +++ b/minilibx-linux/mlx_new_image.c @@ -0,0 +1,159 @@ +/* +** mlx_new_image.c for MiniLibX in raytraceur +** +** Made by Charlie Root +** Login +** +** Started on Mon Aug 14 15:29:14 2000 Charlie Root +** Last update Wed May 25 16:46:31 2011 Olivier Crouzet +*/ + + + + +#include "mlx_int.h" + +/* +** To handle X errors +*/ + +#define X_ShmAttach 1 + +int mlx_X_error; + +int shm_att_pb(Display *d,XErrorEvent *ev) +{ + if (ev->request_code==146 && ev->minor_code==X_ShmAttach) + write(2,WARN_SHM_ATTACH,strlen(WARN_SHM_ATTACH)); + mlx_X_error = 1; +} + + +/* +** Data malloc : width+32 ( bitmap_pad=32 ), *4 = *32 / 8bit +*/ + + +void *mlx_int_new_xshm_image(t_xvar *xvar,int width,int height,int format) +{ + t_img *img; + int (*save_handler)(); + + if (!(img = malloc(sizeof(*img)))) + return ((void *)0); + bzero(img,sizeof(*img)); + img->data = 0; + img->image = XShmCreateImage(xvar->display,xvar->visual,xvar->depth, + format,img->data,&(img->shm),width,height); + if (!img->image) + { + free(img); + return ((void *)0); + } + img->width = width; + img->height = height; + img->size_line = img->image->bytes_per_line; + img->bpp = img->image->bits_per_pixel; + img->format = format; + img->shm.shmid = shmget(IPC_PRIVATE,(width+32)*height*4,IPC_CREAT|0777); + if (img->shm.shmid==-1) + { + XDestroyImage(img->image); + free(img); + return ((void *)0); + } + img->data = img->shm.shmaddr = img->image->data = shmat(img->shm.shmid,0,0); + if (img->data==(void *)-1) + { + shmctl(img->shm.shmid,IPC_RMID,0); + XDestroyImage(img->image); + free(img); + return ((void *)0); + } + img->shm.readOnly = False; + mlx_X_error = 0; + save_handler = XSetErrorHandler(shm_att_pb); + if (!XShmAttach(xvar->display,&(img->shm)) || + 0&XSync(xvar->display,False) || mlx_X_error) + { + XSetErrorHandler(save_handler); + shmdt(img->data); + shmctl(img->shm.shmid,IPC_RMID,0); + XDestroyImage(img->image); + free(img); + return ((void *)0); + } + XSetErrorHandler(save_handler); + shmctl(img->shm.shmid,IPC_RMID,0); + if (xvar->pshm_format==format) + { + img->pix = XShmCreatePixmap(xvar->display,xvar->root,img->shm.shmaddr, + &(img->shm),width,height,xvar->depth); + img->type = MLX_TYPE_SHM_PIXMAP; + } + else + { + img->pix = XCreatePixmap(xvar->display,xvar->root, + width,height,xvar->depth); + img->type = MLX_TYPE_SHM; + } + if (xvar->do_flush) + XFlush(xvar->display); + return (img); +} + + + +void *mlx_int_new_image(t_xvar *xvar,int width, int height,int format) +{ + t_img *img; + + if (!(img = malloc(sizeof(*img)))) + return ((void *)0); + if (!(img->data = malloc((width+32)*height*4))) + { + free(img); + return ((void *)0); + } + bzero(img->data,(width+32)*height*4); + img->image = XCreateImage(xvar->display,xvar->visual,xvar->depth,format,0, + img->data,width,height,32,0); + if (!img->image) + { + free(img->data); + free(img); + return ((void *)0); + } + img->gc = 0; + img->size_line = img->image->bytes_per_line; + img->bpp = img->image->bits_per_pixel; + img->width = width; + img->height = height; + img->pix = XCreatePixmap(xvar->display,xvar->root,width,height,xvar->depth); + img->format = format; + img->type = MLX_TYPE_XIMAGE; + if (xvar->do_flush) + XFlush(xvar->display); + return (img); +} + + +void *mlx_new_image(t_xvar *xvar,int width, int height) +{ + t_img *img; + + if (xvar->use_xshm) + if (img = mlx_int_new_xshm_image(xvar,width,height,ZPixmap)) + return (img); + return (mlx_int_new_image(xvar,width,height,ZPixmap)); +} + +void *mlx_new_image2(t_xvar *xvar,int width, int height) +{ + t_img *img; + + if (xvar->use_xshm) + if (img = mlx_int_new_xshm_image(xvar,width,height,XYPixmap)) + return (img); + return (mlx_int_new_image(xvar,width,height,XYPixmap)); +} diff --git a/minilibx-linux/mlx_new_window.c b/minilibx-linux/mlx_new_window.c new file mode 100644 index 0000000..3f05914 --- /dev/null +++ b/minilibx-linux/mlx_new_window.c @@ -0,0 +1,62 @@ +/* +** mlx_new_window.c for MiniLibX in +** +** Made by Charlie Root +** Login +** +** Started on Mon Jul 31 17:29:02 2000 Charlie Root +** Last update Thu Oct 4 15:44:43 2001 Charlie Root +*/ + + +/* +** We do not use White/BlackPixel macro, TrueColor Visual make sure +** 0 is black & -1 is white +** +** With mlx_int_wait_first_expose, no flush is needed. +*/ + +#include "mlx_int.h" + + +void *mlx_new_window(t_xvar *xvar,int size_x,int size_y,char *title) +{ + t_win_list *new_win; + XSetWindowAttributes xswa; + XGCValues xgcv; + + xswa.background_pixel = 0; + xswa.border_pixel = -1; + xswa.colormap = xvar->cmap; + /* + xswa.event_mask = ButtonPressMask | ButtonReleaseMask | ExposureMask | + KeyPressMask | KeyReleaseMask | StructureNotifyMask; + */ + /* xswa.event_mask = ExposureMask; */ + xswa.event_mask = 0xFFFFFF; /* all events */ + if (!(new_win = malloc(sizeof(*new_win)))) + return ((void *)0); + new_win->window = XCreateWindow(xvar->display,xvar->root,0,0,size_x,size_y, + 0,CopyFromParent,InputOutput,xvar->visual, + CWEventMask|CWBackPixel|CWBorderPixel| + CWColormap,&xswa); + mlx_int_anti_resize_win(xvar,new_win->window,size_x,size_y); + XStoreName(xvar->display,new_win->window,title); + XSetWMProtocols(xvar->display, new_win->window, &(xvar->wm_delete_window), 1); + xgcv.foreground = -1; + xgcv.function = GXcopy; + xgcv.plane_mask = AllPlanes; + new_win->gc = XCreateGC(xvar->display,new_win->window, + GCFunction|GCPlaneMask|GCForeground,&xgcv); + new_win->next = xvar->win_list; + xvar->win_list = new_win; + /* + new_win->mouse_hook = mlx_int_do_nothing; + new_win->key_hook = mlx_int_do_nothing; + new_win->expose_hook = mlx_int_do_nothing; + */ + bzero(&(new_win->hooks), sizeof(new_win->hooks)); + XMapRaised(xvar->display,new_win->window); + mlx_int_wait_first_expose(xvar,new_win->window); + return (new_win); +} diff --git a/minilibx-linux/mlx_pixel_put.c b/minilibx-linux/mlx_pixel_put.c new file mode 100644 index 0000000..c411f36 --- /dev/null +++ b/minilibx-linux/mlx_pixel_put.c @@ -0,0 +1,26 @@ +/* + ** mlx_pixel_put.c for MiniLibX in + ** + ** Made by Charlie Root + ** Login + ** + ** Started on Mon Jul 31 19:01:33 2000 Charlie Root +** Last update Tue Sep 25 17:09:49 2001 Charlie Root + */ + + +#include "mlx_int.h" + + + +int mlx_pixel_put(t_xvar *xvar,t_win_list *win, + int x,int y,int color) +{ + XGCValues xgcv; + + xgcv.foreground = mlx_int_get_good_color(xvar,color); + XChangeGC(xvar->display,win->gc,GCForeground,&xgcv); + XDrawPoint(xvar->display,win->window,win->gc,x,y); + if (xvar->do_flush) + XFlush(xvar->display); +} diff --git a/minilibx-linux/mlx_put_image_to_window.c b/minilibx-linux/mlx_put_image_to_window.c new file mode 100644 index 0000000..86ba3f4 --- /dev/null +++ b/minilibx-linux/mlx_put_image_to_window.c @@ -0,0 +1,37 @@ +/* +** mlx_put_image_to_window.c for MiniLibX in raytraceur +** +** Made by Charlie Root +** Login +** +** Started on Mon Aug 14 15:55:49 2000 Charlie Root +** Last update Sun Oct 2 09:53:00 2005 Olivier Crouzet +*/ + + + +#include "mlx_int.h" + + +int mlx_put_image_to_window(t_xvar *xvar,t_win_list *win,t_img *img, + int x,int y) +{ + GC gc; + + gc = win->gc; + if (img->gc) + { + gc = img->gc; + XSetClipOrigin(xvar->display, gc, x, y); + } + if (img->type==MLX_TYPE_SHM) + XShmPutImage(xvar->display,img->pix, win->gc, img->image,0,0,0,0, + img->width,img->height,False); + if (img->type==MLX_TYPE_XIMAGE) + XPutImage(xvar->display,img->pix, win->gc, img->image,0,0,0,0, + img->width,img->height); + XCopyArea(xvar->display,img->pix,win->window, gc, + 0,0,img->width,img->height,x,y); + if (xvar->do_flush) + XFlush(xvar->display); +} diff --git a/minilibx-linux/mlx_rgb.c b/minilibx-linux/mlx_rgb.c new file mode 100644 index 0000000..0cfccf6 --- /dev/null +++ b/minilibx-linux/mlx_rgb.c @@ -0,0 +1,764 @@ +/* +** This is a generated file with rgb2c.pl and rgb.txt from +** the XFree86 distribution. +*/ + +#include "mlx_int.h" + +struct s_col_name mlx_col_name[] = +{ + { "snow" , 0xfffafa }, + { "ghost white" , 0xf8f8ff }, + { "ghostwhite" , 0xf8f8ff }, + { "white smoke" , 0xf5f5f5 }, + { "whitesmoke" , 0xf5f5f5 }, + { "gainsboro" , 0xdcdcdc }, + { "floral white" , 0xfffaf0 }, + { "floralwhite" , 0xfffaf0 }, + { "old lace" , 0xfdf5e6 }, + { "oldlace" , 0xfdf5e6 }, + { "linen" , 0xfaf0e6 }, + { "antique white" , 0xfaebd7 }, + { "antiquewhite" , 0xfaebd7 }, + { "papaya whip" , 0xffefd5 }, + { "papayawhip" , 0xffefd5 }, + { "blanched almond" , 0xffebcd }, + { "blanchedalmond" , 0xffebcd }, + { "bisque" , 0xffe4c4 }, + { "peach puff" , 0xffdab9 }, + { "peachpuff" , 0xffdab9 }, + { "navajo white" , 0xffdead }, + { "navajowhite" , 0xffdead }, + { "moccasin" , 0xffe4b5 }, + { "cornsilk" , 0xfff8dc }, + { "ivory" , 0xfffff0 }, + { "lemon chiffon" , 0xfffacd }, + { "lemonchiffon" , 0xfffacd }, + { "seashell" , 0xfff5ee }, + { "honeydew" , 0xf0fff0 }, + { "mint cream" , 0xf5fffa }, + { "mintcream" , 0xf5fffa }, + { "azure" , 0xf0ffff }, + { "alice blue" , 0xf0f8ff }, + { "aliceblue" , 0xf0f8ff }, + { "lavender" , 0xe6e6fa }, + { "lavender blush" , 0xfff0f5 }, + { "lavenderblush" , 0xfff0f5 }, + { "misty rose" , 0xffe4e1 }, + { "mistyrose" , 0xffe4e1 }, + { "white" , 0xffffff }, + { "black" , 0x0 }, + { "dark slate" , 0x2f4f4f }, + { "darkslategray" , 0x2f4f4f }, + { "dark slate" , 0x2f4f4f }, + { "darkslategrey" , 0x2f4f4f }, + { "dim gray" , 0x696969 }, + { "dimgray" , 0x696969 }, + { "dim grey" , 0x696969 }, + { "dimgrey" , 0x696969 }, + { "slate gray" , 0x708090 }, + { "slategray" , 0x708090 }, + { "slate grey" , 0x708090 }, + { "slategrey" , 0x708090 }, + { "light slate" , 0x778899 }, + { "lightslategray" , 0x778899 }, + { "light slate" , 0x778899 }, + { "lightslategrey" , 0x778899 }, + { "gray" , 0xbebebe }, + { "grey" , 0xbebebe }, + { "light grey" , 0xd3d3d3 }, + { "lightgrey" , 0xd3d3d3 }, + { "light gray" , 0xd3d3d3 }, + { "lightgray" , 0xd3d3d3 }, + { "midnight blue" , 0x191970 }, + { "midnightblue" , 0x191970 }, + { "navy" , 0x80 }, + { "navy blue" , 0x80 }, + { "navyblue" , 0x80 }, + { "cornflower blue" , 0x6495ed }, + { "cornflowerblue" , 0x6495ed }, + { "dark slate" , 0x483d8b }, + { "darkslateblue" , 0x483d8b }, + { "slate blue" , 0x6a5acd }, + { "slateblue" , 0x6a5acd }, + { "medium slate" , 0x7b68ee }, + { "mediumslateblue" , 0x7b68ee }, + { "light slate" , 0x8470ff }, + { "lightslateblue" , 0x8470ff }, + { "medium blue" , 0xcd }, + { "mediumblue" , 0xcd }, + { "royal blue" , 0x4169e1 }, + { "royalblue" , 0x4169e1 }, + { "blue" , 0xff }, + { "dodger blue" , 0x1e90ff }, + { "dodgerblue" , 0x1e90ff }, + { "deep sky" , 0xbfff }, + { "deepskyblue" , 0xbfff }, + { "sky blue" , 0x87ceeb }, + { "skyblue" , 0x87ceeb }, + { "light sky" , 0x87cefa }, + { "lightskyblue" , 0x87cefa }, + { "steel blue" , 0x4682b4 }, + { "steelblue" , 0x4682b4 }, + { "light steel" , 0xb0c4de }, + { "lightsteelblue" , 0xb0c4de }, + { "light blue" , 0xadd8e6 }, + { "lightblue" , 0xadd8e6 }, + { "powder blue" , 0xb0e0e6 }, + { "powderblue" , 0xb0e0e6 }, + { "pale turquoise" , 0xafeeee }, + { "paleturquoise" , 0xafeeee }, + { "dark turquoise" , 0xced1 }, + { "darkturquoise" , 0xced1 }, + { "medium turquoise" , 0x48d1cc }, + { "mediumturquoise" , 0x48d1cc }, + { "turquoise" , 0x40e0d0 }, + { "cyan" , 0xffff }, + { "light cyan" , 0xe0ffff }, + { "lightcyan" , 0xe0ffff }, + { "cadet blue" , 0x5f9ea0 }, + { "cadetblue" , 0x5f9ea0 }, + { "medium aquamarine" , 0x66cdaa }, + { "mediumaquamarine" , 0x66cdaa }, + { "aquamarine" , 0x7fffd4 }, + { "dark green" , 0x6400 }, + { "darkgreen" , 0x6400 }, + { "dark olive" , 0x556b2f }, + { "darkolivegreen" , 0x556b2f }, + { "dark sea" , 0x8fbc8f }, + { "darkseagreen" , 0x8fbc8f }, + { "sea green" , 0x2e8b57 }, + { "seagreen" , 0x2e8b57 }, + { "medium sea" , 0x3cb371 }, + { "mediumseagreen" , 0x3cb371 }, + { "light sea" , 0x20b2aa }, + { "lightseagreen" , 0x20b2aa }, + { "pale green" , 0x98fb98 }, + { "palegreen" , 0x98fb98 }, + { "spring green" , 0xff7f }, + { "springgreen" , 0xff7f }, + { "lawn green" , 0x7cfc00 }, + { "lawngreen" , 0x7cfc00 }, + { "green" , 0xff00 }, + { "chartreuse" , 0x7fff00 }, + { "medium spring" , 0xfa9a }, + { "mediumspringgreen" , 0xfa9a }, + { "green yellow" , 0xadff2f }, + { "greenyellow" , 0xadff2f }, + { "lime green" , 0x32cd32 }, + { "limegreen" , 0x32cd32 }, + { "yellow green" , 0x9acd32 }, + { "yellowgreen" , 0x9acd32 }, + { "forest green" , 0x228b22 }, + { "forestgreen" , 0x228b22 }, + { "olive drab" , 0x6b8e23 }, + { "olivedrab" , 0x6b8e23 }, + { "dark khaki" , 0xbdb76b }, + { "darkkhaki" , 0xbdb76b }, + { "khaki" , 0xf0e68c }, + { "pale goldenrod" , 0xeee8aa }, + { "palegoldenrod" , 0xeee8aa }, + { "light goldenrod" , 0xfafad2 }, + { "lightgoldenrodyellow" , 0xfafad2 }, + { "light yellow" , 0xffffe0 }, + { "lightyellow" , 0xffffe0 }, + { "yellow" , 0xffff00 }, + { "gold" , 0xffd700 }, + { "light goldenrod" , 0xeedd82 }, + { "lightgoldenrod" , 0xeedd82 }, + { "goldenrod" , 0xdaa520 }, + { "dark goldenrod" , 0xb8860b }, + { "darkgoldenrod" , 0xb8860b }, + { "rosy brown" , 0xbc8f8f }, + { "rosybrown" , 0xbc8f8f }, + { "indian red" , 0xcd5c5c }, + { "indianred" , 0xcd5c5c }, + { "saddle brown" , 0x8b4513 }, + { "saddlebrown" , 0x8b4513 }, + { "sienna" , 0xa0522d }, + { "peru" , 0xcd853f }, + { "burlywood" , 0xdeb887 }, + { "beige" , 0xf5f5dc }, + { "wheat" , 0xf5deb3 }, + { "sandy brown" , 0xf4a460 }, + { "sandybrown" , 0xf4a460 }, + { "tan" , 0xd2b48c }, + { "chocolate" , 0xd2691e }, + { "firebrick" , 0xb22222 }, + { "brown" , 0xa52a2a }, + { "dark salmon" , 0xe9967a }, + { "darksalmon" , 0xe9967a }, + { "salmon" , 0xfa8072 }, + { "light salmon" , 0xffa07a }, + { "lightsalmon" , 0xffa07a }, + { "orange" , 0xffa500 }, + { "dark orange" , 0xff8c00 }, + { "darkorange" , 0xff8c00 }, + { "coral" , 0xff7f50 }, + { "light coral" , 0xf08080 }, + { "lightcoral" , 0xf08080 }, + { "tomato" , 0xff6347 }, + { "orange red" , 0xff4500 }, + { "orangered" , 0xff4500 }, + { "red" , 0xff0000 }, + { "hot pink" , 0xff69b4 }, + { "hotpink" , 0xff69b4 }, + { "deep pink" , 0xff1493 }, + { "deeppink" , 0xff1493 }, + { "pink" , 0xffc0cb }, + { "light pink" , 0xffb6c1 }, + { "lightpink" , 0xffb6c1 }, + { "pale violet" , 0xdb7093 }, + { "palevioletred" , 0xdb7093 }, + { "maroon" , 0xb03060 }, + { "medium violet" , 0xc71585 }, + { "mediumvioletred" , 0xc71585 }, + { "violet red" , 0xd02090 }, + { "violetred" , 0xd02090 }, + { "magenta" , 0xff00ff }, + { "violet" , 0xee82ee }, + { "plum" , 0xdda0dd }, + { "orchid" , 0xda70d6 }, + { "medium orchid" , 0xba55d3 }, + { "mediumorchid" , 0xba55d3 }, + { "dark orchid" , 0x9932cc }, + { "darkorchid" , 0x9932cc }, + { "dark violet" , 0x9400d3 }, + { "darkviolet" , 0x9400d3 }, + { "blue violet" , 0x8a2be2 }, + { "blueviolet" , 0x8a2be2 }, + { "purple" , 0xa020f0 }, + { "medium purple" , 0x9370db }, + { "mediumpurple" , 0x9370db }, + { "thistle" , 0xd8bfd8 }, + { "snow1" , 0xfffafa }, + { "snow2" , 0xeee9e9 }, + { "snow3" , 0xcdc9c9 }, + { "snow4" , 0x8b8989 }, + { "seashell1" , 0xfff5ee }, + { "seashell2" , 0xeee5de }, + { "seashell3" , 0xcdc5bf }, + { "seashell4" , 0x8b8682 }, + { "antiquewhite1" , 0xffefdb }, + { "antiquewhite2" , 0xeedfcc }, + { "antiquewhite3" , 0xcdc0b0 }, + { "antiquewhite4" , 0x8b8378 }, + { "bisque1" , 0xffe4c4 }, + { "bisque2" , 0xeed5b7 }, + { "bisque3" , 0xcdb79e }, + { "bisque4" , 0x8b7d6b }, + { "peachpuff1" , 0xffdab9 }, + { "peachpuff2" , 0xeecbad }, + { "peachpuff3" , 0xcdaf95 }, + { "peachpuff4" , 0x8b7765 }, + { "navajowhite1" , 0xffdead }, + { "navajowhite2" , 0xeecfa1 }, + { "navajowhite3" , 0xcdb38b }, + { "navajowhite4" , 0x8b795e }, + { "lemonchiffon1" , 0xfffacd }, + { "lemonchiffon2" , 0xeee9bf }, + { "lemonchiffon3" , 0xcdc9a5 }, + { "lemonchiffon4" , 0x8b8970 }, + { "cornsilk1" , 0xfff8dc }, + { "cornsilk2" , 0xeee8cd }, + { "cornsilk3" , 0xcdc8b1 }, + { "cornsilk4" , 0x8b8878 }, + { "ivory1" , 0xfffff0 }, + { "ivory2" , 0xeeeee0 }, + { "ivory3" , 0xcdcdc1 }, + { "ivory4" , 0x8b8b83 }, + { "honeydew1" , 0xf0fff0 }, + { "honeydew2" , 0xe0eee0 }, + { "honeydew3" , 0xc1cdc1 }, + { "honeydew4" , 0x838b83 }, + { "lavenderblush1" , 0xfff0f5 }, + { "lavenderblush2" , 0xeee0e5 }, + { "lavenderblush3" , 0xcdc1c5 }, + { "lavenderblush4" , 0x8b8386 }, + { "mistyrose1" , 0xffe4e1 }, + { "mistyrose2" , 0xeed5d2 }, + { "mistyrose3" , 0xcdb7b5 }, + { "mistyrose4" , 0x8b7d7b }, + { "azure1" , 0xf0ffff }, + { "azure2" , 0xe0eeee }, + { "azure3" , 0xc1cdcd }, + { "azure4" , 0x838b8b }, + { "slateblue1" , 0x836fff }, + { "slateblue2" , 0x7a67ee }, + { "slateblue3" , 0x6959cd }, + { "slateblue4" , 0x473c8b }, + { "royalblue1" , 0x4876ff }, + { "royalblue2" , 0x436eee }, + { "royalblue3" , 0x3a5fcd }, + { "royalblue4" , 0x27408b }, + { "blue1" , 0xff }, + { "blue2" , 0xee }, + { "blue3" , 0xcd }, + { "blue4" , 0x8b }, + { "dodgerblue1" , 0x1e90ff }, + { "dodgerblue2" , 0x1c86ee }, + { "dodgerblue3" , 0x1874cd }, + { "dodgerblue4" , 0x104e8b }, + { "steelblue1" , 0x63b8ff }, + { "steelblue2" , 0x5cacee }, + { "steelblue3" , 0x4f94cd }, + { "steelblue4" , 0x36648b }, + { "deepskyblue1" , 0xbfff }, + { "deepskyblue2" , 0xb2ee }, + { "deepskyblue3" , 0x9acd }, + { "deepskyblue4" , 0x688b }, + { "skyblue1" , 0x87ceff }, + { "skyblue2" , 0x7ec0ee }, + { "skyblue3" , 0x6ca6cd }, + { "skyblue4" , 0x4a708b }, + { "lightskyblue1" , 0xb0e2ff }, + { "lightskyblue2" , 0xa4d3ee }, + { "lightskyblue3" , 0x8db6cd }, + { "lightskyblue4" , 0x607b8b }, + { "slategray1" , 0xc6e2ff }, + { "slategray2" , 0xb9d3ee }, + { "slategray3" , 0x9fb6cd }, + { "slategray4" , 0x6c7b8b }, + { "lightsteelblue1" , 0xcae1ff }, + { "lightsteelblue2" , 0xbcd2ee }, + { "lightsteelblue3" , 0xa2b5cd }, + { "lightsteelblue4" , 0x6e7b8b }, + { "lightblue1" , 0xbfefff }, + { "lightblue2" , 0xb2dfee }, + { "lightblue3" , 0x9ac0cd }, + { "lightblue4" , 0x68838b }, + { "lightcyan1" , 0xe0ffff }, + { "lightcyan2" , 0xd1eeee }, + { "lightcyan3" , 0xb4cdcd }, + { "lightcyan4" , 0x7a8b8b }, + { "paleturquoise1" , 0xbbffff }, + { "paleturquoise2" , 0xaeeeee }, + { "paleturquoise3" , 0x96cdcd }, + { "paleturquoise4" , 0x668b8b }, + { "cadetblue1" , 0x98f5ff }, + { "cadetblue2" , 0x8ee5ee }, + { "cadetblue3" , 0x7ac5cd }, + { "cadetblue4" , 0x53868b }, + { "turquoise1" , 0xf5ff }, + { "turquoise2" , 0xe5ee }, + { "turquoise3" , 0xc5cd }, + { "turquoise4" , 0x868b }, + { "cyan1" , 0xffff }, + { "cyan2" , 0xeeee }, + { "cyan3" , 0xcdcd }, + { "cyan4" , 0x8b8b }, + { "darkslategray1" , 0x97ffff }, + { "darkslategray2" , 0x8deeee }, + { "darkslategray3" , 0x79cdcd }, + { "darkslategray4" , 0x528b8b }, + { "aquamarine1" , 0x7fffd4 }, + { "aquamarine2" , 0x76eec6 }, + { "aquamarine3" , 0x66cdaa }, + { "aquamarine4" , 0x458b74 }, + { "darkseagreen1" , 0xc1ffc1 }, + { "darkseagreen2" , 0xb4eeb4 }, + { "darkseagreen3" , 0x9bcd9b }, + { "darkseagreen4" , 0x698b69 }, + { "seagreen1" , 0x54ff9f }, + { "seagreen2" , 0x4eee94 }, + { "seagreen3" , 0x43cd80 }, + { "seagreen4" , 0x2e8b57 }, + { "palegreen1" , 0x9aff9a }, + { "palegreen2" , 0x90ee90 }, + { "palegreen3" , 0x7ccd7c }, + { "palegreen4" , 0x548b54 }, + { "springgreen1" , 0xff7f }, + { "springgreen2" , 0xee76 }, + { "springgreen3" , 0xcd66 }, + { "springgreen4" , 0x8b45 }, + { "green1" , 0xff00 }, + { "green2" , 0xee00 }, + { "green3" , 0xcd00 }, + { "green4" , 0x8b00 }, + { "chartreuse1" , 0x7fff00 }, + { "chartreuse2" , 0x76ee00 }, + { "chartreuse3" , 0x66cd00 }, + { "chartreuse4" , 0x458b00 }, + { "olivedrab1" , 0xc0ff3e }, + { "olivedrab2" , 0xb3ee3a }, + { "olivedrab3" , 0x9acd32 }, + { "olivedrab4" , 0x698b22 }, + { "darkolivegreen1" , 0xcaff70 }, + { "darkolivegreen2" , 0xbcee68 }, + { "darkolivegreen3" , 0xa2cd5a }, + { "darkolivegreen4" , 0x6e8b3d }, + { "khaki1" , 0xfff68f }, + { "khaki2" , 0xeee685 }, + { "khaki3" , 0xcdc673 }, + { "khaki4" , 0x8b864e }, + { "lightgoldenrod1" , 0xffec8b }, + { "lightgoldenrod2" , 0xeedc82 }, + { "lightgoldenrod3" , 0xcdbe70 }, + { "lightgoldenrod4" , 0x8b814c }, + { "lightyellow1" , 0xffffe0 }, + { "lightyellow2" , 0xeeeed1 }, + { "lightyellow3" , 0xcdcdb4 }, + { "lightyellow4" , 0x8b8b7a }, + { "yellow1" , 0xffff00 }, + { "yellow2" , 0xeeee00 }, + { "yellow3" , 0xcdcd00 }, + { "yellow4" , 0x8b8b00 }, + { "gold1" , 0xffd700 }, + { "gold2" , 0xeec900 }, + { "gold3" , 0xcdad00 }, + { "gold4" , 0x8b7500 }, + { "goldenrod1" , 0xffc125 }, + { "goldenrod2" , 0xeeb422 }, + { "goldenrod3" , 0xcd9b1d }, + { "goldenrod4" , 0x8b6914 }, + { "darkgoldenrod1" , 0xffb90f }, + { "darkgoldenrod2" , 0xeead0e }, + { "darkgoldenrod3" , 0xcd950c }, + { "darkgoldenrod4" , 0x8b6508 }, + { "rosybrown1" , 0xffc1c1 }, + { "rosybrown2" , 0xeeb4b4 }, + { "rosybrown3" , 0xcd9b9b }, + { "rosybrown4" , 0x8b6969 }, + { "indianred1" , 0xff6a6a }, + { "indianred2" , 0xee6363 }, + { "indianred3" , 0xcd5555 }, + { "indianred4" , 0x8b3a3a }, + { "sienna1" , 0xff8247 }, + { "sienna2" , 0xee7942 }, + { "sienna3" , 0xcd6839 }, + { "sienna4" , 0x8b4726 }, + { "burlywood1" , 0xffd39b }, + { "burlywood2" , 0xeec591 }, + { "burlywood3" , 0xcdaa7d }, + { "burlywood4" , 0x8b7355 }, + { "wheat1" , 0xffe7ba }, + { "wheat2" , 0xeed8ae }, + { "wheat3" , 0xcdba96 }, + { "wheat4" , 0x8b7e66 }, + { "tan1" , 0xffa54f }, + { "tan2" , 0xee9a49 }, + { "tan3" , 0xcd853f }, + { "tan4" , 0x8b5a2b }, + { "chocolate1" , 0xff7f24 }, + { "chocolate2" , 0xee7621 }, + { "chocolate3" , 0xcd661d }, + { "chocolate4" , 0x8b4513 }, + { "firebrick1" , 0xff3030 }, + { "firebrick2" , 0xee2c2c }, + { "firebrick3" , 0xcd2626 }, + { "firebrick4" , 0x8b1a1a }, + { "brown1" , 0xff4040 }, + { "brown2" , 0xee3b3b }, + { "brown3" , 0xcd3333 }, + { "brown4" , 0x8b2323 }, + { "salmon1" , 0xff8c69 }, + { "salmon2" , 0xee8262 }, + { "salmon3" , 0xcd7054 }, + { "salmon4" , 0x8b4c39 }, + { "lightsalmon1" , 0xffa07a }, + { "lightsalmon2" , 0xee9572 }, + { "lightsalmon3" , 0xcd8162 }, + { "lightsalmon4" , 0x8b5742 }, + { "orange1" , 0xffa500 }, + { "orange2" , 0xee9a00 }, + { "orange3" , 0xcd8500 }, + { "orange4" , 0x8b5a00 }, + { "darkorange1" , 0xff7f00 }, + { "darkorange2" , 0xee7600 }, + { "darkorange3" , 0xcd6600 }, + { "darkorange4" , 0x8b4500 }, + { "coral1" , 0xff7256 }, + { "coral2" , 0xee6a50 }, + { "coral3" , 0xcd5b45 }, + { "coral4" , 0x8b3e2f }, + { "tomato1" , 0xff6347 }, + { "tomato2" , 0xee5c42 }, + { "tomato3" , 0xcd4f39 }, + { "tomato4" , 0x8b3626 }, + { "orangered1" , 0xff4500 }, + { "orangered2" , 0xee4000 }, + { "orangered3" , 0xcd3700 }, + { "orangered4" , 0x8b2500 }, + { "red1" , 0xff0000 }, + { "red2" , 0xee0000 }, + { "red3" , 0xcd0000 }, + { "red4" , 0x8b0000 }, + { "deeppink1" , 0xff1493 }, + { "deeppink2" , 0xee1289 }, + { "deeppink3" , 0xcd1076 }, + { "deeppink4" , 0x8b0a50 }, + { "hotpink1" , 0xff6eb4 }, + { "hotpink2" , 0xee6aa7 }, + { "hotpink3" , 0xcd6090 }, + { "hotpink4" , 0x8b3a62 }, + { "pink1" , 0xffb5c5 }, + { "pink2" , 0xeea9b8 }, + { "pink3" , 0xcd919e }, + { "pink4" , 0x8b636c }, + { "lightpink1" , 0xffaeb9 }, + { "lightpink2" , 0xeea2ad }, + { "lightpink3" , 0xcd8c95 }, + { "lightpink4" , 0x8b5f65 }, + { "palevioletred1" , 0xff82ab }, + { "palevioletred2" , 0xee799f }, + { "palevioletred3" , 0xcd6889 }, + { "palevioletred4" , 0x8b475d }, + { "maroon1" , 0xff34b3 }, + { "maroon2" , 0xee30a7 }, + { "maroon3" , 0xcd2990 }, + { "maroon4" , 0x8b1c62 }, + { "violetred1" , 0xff3e96 }, + { "violetred2" , 0xee3a8c }, + { "violetred3" , 0xcd3278 }, + { "violetred4" , 0x8b2252 }, + { "magenta1" , 0xff00ff }, + { "magenta2" , 0xee00ee }, + { "magenta3" , 0xcd00cd }, + { "magenta4" , 0x8b008b }, + { "orchid1" , 0xff83fa }, + { "orchid2" , 0xee7ae9 }, + { "orchid3" , 0xcd69c9 }, + { "orchid4" , 0x8b4789 }, + { "plum1" , 0xffbbff }, + { "plum2" , 0xeeaeee }, + { "plum3" , 0xcd96cd }, + { "plum4" , 0x8b668b }, + { "mediumorchid1" , 0xe066ff }, + { "mediumorchid2" , 0xd15fee }, + { "mediumorchid3" , 0xb452cd }, + { "mediumorchid4" , 0x7a378b }, + { "darkorchid1" , 0xbf3eff }, + { "darkorchid2" , 0xb23aee }, + { "darkorchid3" , 0x9a32cd }, + { "darkorchid4" , 0x68228b }, + { "purple1" , 0x9b30ff }, + { "purple2" , 0x912cee }, + { "purple3" , 0x7d26cd }, + { "purple4" , 0x551a8b }, + { "mediumpurple1" , 0xab82ff }, + { "mediumpurple2" , 0x9f79ee }, + { "mediumpurple3" , 0x8968cd }, + { "mediumpurple4" , 0x5d478b }, + { "thistle1" , 0xffe1ff }, + { "thistle2" , 0xeed2ee }, + { "thistle3" , 0xcdb5cd }, + { "thistle4" , 0x8b7b8b }, + { "gray0" , 0x0 }, + { "grey0" , 0x0 }, + { "gray1" , 0x30303 }, + { "grey1" , 0x30303 }, + { "gray2" , 0x50505 }, + { "grey2" , 0x50505 }, + { "gray3" , 0x80808 }, + { "grey3" , 0x80808 }, + { "gray4" , 0xa0a0a }, + { "grey4" , 0xa0a0a }, + { "gray5" , 0xd0d0d }, + { "grey5" , 0xd0d0d }, + { "gray6" , 0xf0f0f }, + { "grey6" , 0xf0f0f }, + { "gray7" , 0x121212 }, + { "grey7" , 0x121212 }, + { "gray8" , 0x141414 }, + { "grey8" , 0x141414 }, + { "gray9" , 0x171717 }, + { "grey9" , 0x171717 }, + { "gray10" , 0x1a1a1a }, + { "grey10" , 0x1a1a1a }, + { "gray11" , 0x1c1c1c }, + { "grey11" , 0x1c1c1c }, + { "gray12" , 0x1f1f1f }, + { "grey12" , 0x1f1f1f }, + { "gray13" , 0x212121 }, + { "grey13" , 0x212121 }, + { "gray14" , 0x242424 }, + { "grey14" , 0x242424 }, + { "gray15" , 0x262626 }, + { "grey15" , 0x262626 }, + { "gray16" , 0x292929 }, + { "grey16" , 0x292929 }, + { "gray17" , 0x2b2b2b }, + { "grey17" , 0x2b2b2b }, + { "gray18" , 0x2e2e2e }, + { "grey18" , 0x2e2e2e }, + { "gray19" , 0x303030 }, + { "grey19" , 0x303030 }, + { "gray20" , 0x333333 }, + { "grey20" , 0x333333 }, + { "gray21" , 0x363636 }, + { "grey21" , 0x363636 }, + { "gray22" , 0x383838 }, + { "grey22" , 0x383838 }, + { "gray23" , 0x3b3b3b }, + { "grey23" , 0x3b3b3b }, + { "gray24" , 0x3d3d3d }, + { "grey24" , 0x3d3d3d }, + { "gray25" , 0x404040 }, + { "grey25" , 0x404040 }, + { "gray26" , 0x424242 }, + { "grey26" , 0x424242 }, + { "gray27" , 0x454545 }, + { "grey27" , 0x454545 }, + { "gray28" , 0x474747 }, + { "grey28" , 0x474747 }, + { "gray29" , 0x4a4a4a }, + { "grey29" , 0x4a4a4a }, + { "gray30" , 0x4d4d4d }, + { "grey30" , 0x4d4d4d }, + { "gray31" , 0x4f4f4f }, + { "grey31" , 0x4f4f4f }, + { "gray32" , 0x525252 }, + { "grey32" , 0x525252 }, + { "gray33" , 0x545454 }, + { "grey33" , 0x545454 }, + { "gray34" , 0x575757 }, + { "grey34" , 0x575757 }, + { "gray35" , 0x595959 }, + { "grey35" , 0x595959 }, + { "gray36" , 0x5c5c5c }, + { "grey36" , 0x5c5c5c }, + { "gray37" , 0x5e5e5e }, + { "grey37" , 0x5e5e5e }, + { "gray38" , 0x616161 }, + { "grey38" , 0x616161 }, + { "gray39" , 0x636363 }, + { "grey39" , 0x636363 }, + { "gray40" , 0x666666 }, + { "grey40" , 0x666666 }, + { "gray41" , 0x696969 }, + { "grey41" , 0x696969 }, + { "gray42" , 0x6b6b6b }, + { "grey42" , 0x6b6b6b }, + { "gray43" , 0x6e6e6e }, + { "grey43" , 0x6e6e6e }, + { "gray44" , 0x707070 }, + { "grey44" , 0x707070 }, + { "gray45" , 0x737373 }, + { "grey45" , 0x737373 }, + { "gray46" , 0x757575 }, + { "grey46" , 0x757575 }, + { "gray47" , 0x787878 }, + { "grey47" , 0x787878 }, + { "gray48" , 0x7a7a7a }, + { "grey48" , 0x7a7a7a }, + { "gray49" , 0x7d7d7d }, + { "grey49" , 0x7d7d7d }, + { "gray50" , 0x7f7f7f }, + { "grey50" , 0x7f7f7f }, + { "gray51" , 0x828282 }, + { "grey51" , 0x828282 }, + { "gray52" , 0x858585 }, + { "grey52" , 0x858585 }, + { "gray53" , 0x878787 }, + { "grey53" , 0x878787 }, + { "gray54" , 0x8a8a8a }, + { "grey54" , 0x8a8a8a }, + { "gray55" , 0x8c8c8c }, + { "grey55" , 0x8c8c8c }, + { "gray56" , 0x8f8f8f }, + { "grey56" , 0x8f8f8f }, + { "gray57" , 0x919191 }, + { "grey57" , 0x919191 }, + { "gray58" , 0x949494 }, + { "grey58" , 0x949494 }, + { "gray59" , 0x969696 }, + { "grey59" , 0x969696 }, + { "gray60" , 0x999999 }, + { "grey60" , 0x999999 }, + { "gray61" , 0x9c9c9c }, + { "grey61" , 0x9c9c9c }, + { "gray62" , 0x9e9e9e }, + { "grey62" , 0x9e9e9e }, + { "gray63" , 0xa1a1a1 }, + { "grey63" , 0xa1a1a1 }, + { "gray64" , 0xa3a3a3 }, + { "grey64" , 0xa3a3a3 }, + { "gray65" , 0xa6a6a6 }, + { "grey65" , 0xa6a6a6 }, + { "gray66" , 0xa8a8a8 }, + { "grey66" , 0xa8a8a8 }, + { "gray67" , 0xababab }, + { "grey67" , 0xababab }, + { "gray68" , 0xadadad }, + { "grey68" , 0xadadad }, + { "gray69" , 0xb0b0b0 }, + { "grey69" , 0xb0b0b0 }, + { "gray70" , 0xb3b3b3 }, + { "grey70" , 0xb3b3b3 }, + { "gray71" , 0xb5b5b5 }, + { "grey71" , 0xb5b5b5 }, + { "gray72" , 0xb8b8b8 }, + { "grey72" , 0xb8b8b8 }, + { "gray73" , 0xbababa }, + { "grey73" , 0xbababa }, + { "gray74" , 0xbdbdbd }, + { "grey74" , 0xbdbdbd }, + { "gray75" , 0xbfbfbf }, + { "grey75" , 0xbfbfbf }, + { "gray76" , 0xc2c2c2 }, + { "grey76" , 0xc2c2c2 }, + { "gray77" , 0xc4c4c4 }, + { "grey77" , 0xc4c4c4 }, + { "gray78" , 0xc7c7c7 }, + { "grey78" , 0xc7c7c7 }, + { "gray79" , 0xc9c9c9 }, + { "grey79" , 0xc9c9c9 }, + { "gray80" , 0xcccccc }, + { "grey80" , 0xcccccc }, + { "gray81" , 0xcfcfcf }, + { "grey81" , 0xcfcfcf }, + { "gray82" , 0xd1d1d1 }, + { "grey82" , 0xd1d1d1 }, + { "gray83" , 0xd4d4d4 }, + { "grey83" , 0xd4d4d4 }, + { "gray84" , 0xd6d6d6 }, + { "grey84" , 0xd6d6d6 }, + { "gray85" , 0xd9d9d9 }, + { "grey85" , 0xd9d9d9 }, + { "gray86" , 0xdbdbdb }, + { "grey86" , 0xdbdbdb }, + { "gray87" , 0xdedede }, + { "grey87" , 0xdedede }, + { "gray88" , 0xe0e0e0 }, + { "grey88" , 0xe0e0e0 }, + { "gray89" , 0xe3e3e3 }, + { "grey89" , 0xe3e3e3 }, + { "gray90" , 0xe5e5e5 }, + { "grey90" , 0xe5e5e5 }, + { "gray91" , 0xe8e8e8 }, + { "grey91" , 0xe8e8e8 }, + { "gray92" , 0xebebeb }, + { "grey92" , 0xebebeb }, + { "gray93" , 0xededed }, + { "grey93" , 0xededed }, + { "gray94" , 0xf0f0f0 }, + { "grey94" , 0xf0f0f0 }, + { "gray95" , 0xf2f2f2 }, + { "grey95" , 0xf2f2f2 }, + { "gray96" , 0xf5f5f5 }, + { "grey96" , 0xf5f5f5 }, + { "gray97" , 0xf7f7f7 }, + { "grey97" , 0xf7f7f7 }, + { "gray98" , 0xfafafa }, + { "grey98" , 0xfafafa }, + { "gray99" , 0xfcfcfc }, + { "grey99" , 0xfcfcfc }, + { "gray100" , 0xffffff }, + { "grey100" , 0xffffff }, + { "dark grey" , 0xa9a9a9 }, + { "darkgrey" , 0xa9a9a9 }, + { "dark gray" , 0xa9a9a9 }, + { "darkgray" , 0xa9a9a9 }, + { "dark blue" , 0x8b }, + { "darkblue" , 0x8b }, + { "dark cyan" , 0x8b8b }, + { "darkcyan" , 0x8b8b }, + { "dark magenta" , 0x8b008b }, + { "darkmagenta" , 0x8b008b }, + { "dark red" , 0x8b0000 }, + { "darkred" , 0x8b0000 }, + { "light green" , 0x90ee90 }, + { "lightgreen" , 0x90ee90 }, + { "none", -1 }, + { 0, 0 } +}; diff --git a/minilibx-linux/mlx_screen_size.c b/minilibx-linux/mlx_screen_size.c new file mode 100644 index 0000000..835730d --- /dev/null +++ b/minilibx-linux/mlx_screen_size.c @@ -0,0 +1,13 @@ +#include "mlx_int.h" + +int mlx_get_screen_size(void *mlx_ptr, int *sizex, int *sizey) +{ + XWindowAttributes xwAttr; + Status ret; + t_xvar *xvar; + + xvar = mlx_ptr; + ret = XGetWindowAttributes(xvar->display, xvar->root, &xwAttr); + (*sizex) = xwAttr.width; + (*sizey) = xwAttr.height; +} diff --git a/minilibx-linux/mlx_set_font.c b/minilibx-linux/mlx_set_font.c new file mode 100644 index 0000000..111e3b8 --- /dev/null +++ b/minilibx-linux/mlx_set_font.c @@ -0,0 +1,30 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* mlx_set_font.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: amalliar +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/09/30 13:30:47 by amalliar #+# #+# */ +/* Updated: 2020/09/30 17:08:36 by amalliar ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "mlx_int.h" + +/* +** Allows to specify the font that will be used by mlx_string_put. +** +** Note: only fixed-width bitmap fonts are supported by Xlib, refer to xfontsel +** utility to get valid font names for this function. +*/ + +void mlx_set_font(t_xvar *xvar, t_win_list *win, char *name) +{ + static Font font = 0; + + if (font) + XUnloadFont(xvar->display, font); + font = XLoadFont(xvar->display, name); + XSetFont(xvar->display, win->gc, font); +} diff --git a/minilibx-linux/mlx_string_put.c b/minilibx-linux/mlx_string_put.c new file mode 100644 index 0000000..8492a09 --- /dev/null +++ b/minilibx-linux/mlx_string_put.c @@ -0,0 +1,26 @@ +/* + ** mlx_string_put.c for MiniLibX in + ** + ** Made by Charlie Root + ** Login + ** + ** Started on Mon Jul 31 19:01:33 2000 Charlie Root +** Last update Tue Sep 25 17:11:47 2001 Charlie Root + */ + + +#include "mlx_int.h" + + + +int mlx_string_put(t_xvar *xvar,t_win_list *win, + int x,int y,int color,char *string) +{ + XGCValues xgcv; + + xgcv.foreground = mlx_int_get_good_color(xvar,color); + XChangeGC(xvar->display,win->gc,GCForeground,&xgcv); + XDrawString(xvar->display,win->window,win->gc,x,y,string,strlen(string)); + if (xvar->do_flush) + XFlush(xvar->display); +} diff --git a/minilibx-linux/mlx_xpm.c b/minilibx-linux/mlx_xpm.c new file mode 100644 index 0000000..688cc94 --- /dev/null +++ b/minilibx-linux/mlx_xpm.c @@ -0,0 +1,345 @@ +/* + ** xpm-read.c for MinilibX in + ** + ** Made by Charlie Root + ** Login + ** + ** Started on Tue Dec 11 15:25:27 2001 olivier crouzet + ** Last update Sat Oct 1 14:56:13 2005 Olivier Crouzet + */ + + +#include "mlx_int.h" + +extern struct s_col_name mlx_col_name[]; + + +#define RETURN { if (colors) free(colors); if (tab) free(tab); \ + tab = (void *)0; if (colors_direct) free(colors_direct); \ + if (img) {XDestroyImage(img->image); \ + XFreePixmap(xvar->display,img->pix);free(img);} \ + return ((void *)0);} + + + + +char *mlx_int_get_line(char *ptr,int *pos,int size) +{ + int pos2; + int pos3; + int pos4; + + if ((pos2 = mlx_int_str_str(ptr+*pos,"\"",size-*pos))==-1) + return ((char *)0); + if ((pos3 = mlx_int_str_str(ptr+*pos+pos2+1,"\"",size-*pos-pos2-1))==-1) + return ((char *)0); + *(ptr+*pos+pos2) = 0; + *(ptr+*pos+pos2+1+pos3) = 0; + pos4 = *pos+pos2+1; + *pos += pos2+pos3+2; + return (ptr+pos4); +} + + +unsigned int strlcpy_is_not_posix(char *dest, char *src, unsigned int size) +{ + unsigned count; + unsigned i; + + count = 0; + while (src[count] != '\0') + ++count; + i = 0; + while (src[i] != '\0' && i < (size - 1)) + { + dest[i] = src[i]; + ++i; + } + dest[i] = '\0'; + return (count); +} + +char *mlx_int_static_line(char **xpm_data,int *pos,int size) +{ + static char *copy = 0; + static int len = 0; + int len2; + char *str; + + str = xpm_data[(*pos)++]; + if ((len2 = strlen(str))>len) + { + if (copy) + free(copy); + if (!(copy = malloc(len2+1))) + return ((char *)0); + len = len2; + } + strlcpy_is_not_posix(copy, str, len2); + + return (copy); +} + + +int mlx_int_get_col_name(char *str,int size) +{ + int result; + + result = 0; + while (size--) + result = (result<<8)+*(str++); + + return (result); +} + +int mlx_int_get_text_rgb(char *name, char *end) +{ + int i; + char buff[64]; + + if (*name == '#') + return (strtol(name+1,0,16)); + if (end) + { + snprintf(buff, 64, "%s %s", name, end); + name = buff; + } + i = 0; + while (mlx_col_name[i].name) + { + if (!strcasecmp(mlx_col_name[i].name, name)) + return (mlx_col_name[i].color); + i ++; + } + return (0); +} + + +int mlx_int_xpm_set_pixel(t_img *img, char *data, int opp, int col, int x) +{ + int dec; + + dec = opp; + while (dec--) + { + if (img->image->byte_order) + *(data+x*opp+dec) = col&0xFF; + else + *(data+x*opp+opp-dec-1) = col&0xFF; + col >>= 8; + } +} + + +void *mlx_int_parse_xpm(t_xvar *xvar,void *info,int info_size,char *(*f)()) +{ + int pos; + char *line; + char **tab; + char *data; + char *clip_data; + int nc; + int opp; + int cpp; + int col; + int rgb_col; + int col_name; + int method; + int x; + int i; + int j; + t_img *img; + t_xpm_col *colors; + int *colors_direct; + int width; + int height; + XImage *clip_img; + XGCValues xgcv; + Pixmap clip_pix; + + colors = 0; + colors_direct = 0; + img = 0; + tab = 0; + pos = 0; + if (!(line = f(info,&pos,info_size)) || + !(tab = mlx_int_str_to_wordtab(line)) || !(width = atoi(tab[0])) || + !(height = atoi(tab[1])) || !(nc = atoi(tab[2])) || + !(cpp = atoi(tab[3])) ) + RETURN; + free(tab); + tab = 0; + + method = 0; + if (cpp<=2) + { + method = 1; + if (!(colors_direct = malloc((cpp==2?65536:256)*sizeof(int)))) + RETURN; + } + else + if (!(colors = malloc(nc*sizeof(*colors)))) + RETURN; + + clip_data = 0; + + i = nc; + while (i--) + { + if (!(line = f(info,&pos,info_size)) || + !(tab = mlx_int_str_to_wordtab(line+cpp)) ) + RETURN; + j = 0; + while (tab[j] && strcmp(tab[j++],"c")); + + if (!tab[j]) + RETURN; + rgb_col = mlx_int_get_text_rgb(tab[j], tab[j+1]); + /* + if ((rgb_col = mlx_int_get_text_rgb(tab[j], tab[j+1]))==-1) + { + if (!(clip_data = malloc(4*width*height)) || ok, nice size .. + !(clip_img = XCreateImage(xvar->display, xvar->visual, + 1, XYPixmap, 0, clip_data, + width, height, 8, (width+7)/8)) ) + RETURN; + memset(clip_data, 0xFF, 4*width*height); + } + */ + if (method) + colors_direct[mlx_int_get_col_name(line,cpp)] = rgb_col; + // rgb_col>=0?mlx_get_color_value(xvar, rgb_col):rgb_col; + else + { + colors[i].name = mlx_int_get_col_name(line,cpp); + colors[i].col = rgb_col; //rgb_col>=0?mlx_get_color_value(xvar,rgb_col):rgb_col; + } + free(tab); + tab = (void *)0; + } + + if (!(img = mlx_new_image(xvar,width,height))) + RETURN; + opp = img->bpp/8; + + + i = height; + data = img->data; + while (i--) + { + if (!(line = f(info,&pos,info_size))) + RETURN; + x = 0; + while (xsize_line; + } + /* + if (clip_data) + { + if (!(clip_pix = XCreatePixmap(xvar->display, xvar->root, + width, height, 1)) ) + RETURN; + img->gc = XCreateGC(xvar->display, clip_pix, 0, &xgcv); + XPutImage(xvar->display, clip_pix, img->gc, clip_img, + 0, 0, 0, 0, width, height); + XFreeGC(xvar->display, img->gc); + xgcv.clip_mask = clip_pix; + xgcv.function = GXcopy; + xgcv.plane_mask = AllPlanes; + img->gc = XCreateGC(xvar->display, xvar->root, GCClipMask|GCFunction| + GCPlaneMask, &xgcv); + XSync(xvar->display, False); + XDestroyImage(clip_img); + } + */ + if (colors) + free(colors); + if (colors_direct) + free(colors_direct); + return (img); +} + + +int mlx_int_file_get_rid_comment(char *ptr, int size) +{ + int com_begin; + int com_end; + + while ((com_begin = mlx_int_str_str_cote(ptr,"/*",size))!=-1) + { + com_end = mlx_int_str_str(ptr+com_begin+2,"*/",size-com_begin-2); + memset(ptr+com_begin,' ',com_end+4); + } + while ((com_begin = mlx_int_str_str_cote(ptr,"//",size))!=-1) + { + com_end = mlx_int_str_str(ptr+com_begin+2,"\n",size-com_begin-2); + memset(ptr+com_begin,' ',com_end+3); + } +} + + +void *mlx_xpm_file_to_image(t_xvar *xvar,char *file,int *width,int *height) +{ + int fd; + int size; + char *ptr; + t_img *img; + + fd = -1; + if ((fd = open(file,O_RDONLY))==-1 || (size = lseek(fd,0,SEEK_END))==-1 || + (ptr = mmap(0,size,PROT_WRITE|PROT_READ,MAP_PRIVATE,fd,0))== + (void *)MAP_FAILED) + { + if (fd>=0) + close(fd); + return ((void *)0); + } + mlx_int_file_get_rid_comment(ptr, size); + if (img = mlx_int_parse_xpm(xvar,ptr,size,mlx_int_get_line)) + { + *width = img->width; + *height = img->height; + } + munmap(ptr,size); + close(fd); + return (img); +} + +void *mlx_xpm_to_image(t_xvar *xvar,char **xpm_data,int *width,int *height) +{ + t_img *img; + + if (img = mlx_int_parse_xpm(xvar,xpm_data,0,mlx_int_static_line)) + { + *width = img->width; + *height = img->height; + } + return (img); +} diff --git a/minilibx-linux/mlx_xpm.c.ok b/minilibx-linux/mlx_xpm.c.ok new file mode 100644 index 0000000..225ea3c --- /dev/null +++ b/minilibx-linux/mlx_xpm.c.ok @@ -0,0 +1,310 @@ +/* +** xpm-read.c for MinilibX in +** +** Made by Charlie Root +** Login +** +** Started on Tue Dec 11 15:25:27 2001 olivier crouzet +** Last update Sat Oct 1 14:40:55 2005 Olivier Crouzet +*/ + + +#include "mlx_int.h" + +extern struct s_col_name mlx_col_name[]; + + +#define RETURN { if (colors) free(colors); if (tab) free(tab); \ + if (colors_direct) free(colors_direct); \ + if (img) {XDestroyImage(img->image); \ + XFreePixmap(xvar->display,img->pix);free(img);} \ + return ((void *)0);} + + + + +char *mlx_int_get_line(char *ptr,int *pos,int size) +{ + int pos2; + int pos3; + int pos4; + + if ((pos2 = mlx_int_str_str(ptr+*pos,"\"",size-*pos))==-1) + return ((char *)0); + if ((pos3 = mlx_int_str_str(ptr+*pos+pos2+1,"\"",size-*pos-pos2-1))==-1) + return ((char *)0); + *(ptr+*pos+pos2) = 0; + *(ptr+*pos+pos2+1+pos3) = 0; + pos4 = *pos+pos2+1; + *pos += pos2+pos3+2; + return (ptr+pos4); +} + + + +char *mlx_int_static_line(char **xpm_data,int *pos,int size) +{ + static char *copy = 0; + static int len = 0; + int len2; + char *str; + + str = xpm_data[(*pos)++]; + if ((len2 = strlen(str))>len) + { + if (copy) + free(copy); + if (!(copy = malloc(len2+1))) + return ((char *)0); + len = len2; + } + /* strcpy(copy,str); */ + strlcpy(copy, str, len2+1); + return (copy); +} + + +int mlx_int_get_col_name(char *str,int size) +{ + int result; + + result = 0; + while (size--) + result = (result<<8)+*(str++); + return (result); +} + +int mlx_int_get_text_rgb(char *name) +{ + int i; + + if (*name == '#') + return (strtol(name+1,0,16)); + i = 0; + while (mlx_col_name[i].name) + { + if (!strcasecmp(mlx_col_name[i].name, name)) + return (mlx_col_name[i].color); + i ++; + } + return (0); +} + + +int mlx_int_xpm_set_pixel(t_img *img, char *data, int opp, int col, int x) +{ + int dec; + + dec = opp; + while (dec--) + { + if (img->image->byte_order) + *(data+x*opp+dec) = col&0xFF; + else + *(data+x*opp+opp-dec-1) = col&0xFF; + col >>= 8; + } +} + + +void *mlx_int_parse_xpm(t_xvar *xvar,void *info,int info_size,char *(*f)()) +{ + int pos; + char *line; + char **tab; + char *data; + char *clip_data; + int nc; + int opp; + int cpp; + int col; + int rgb_col; + int col_name; + int method; + int x; + int i; + int j; + t_img *img; + t_xpm_col *colors; + int *colors_direct; + int width; + int height; + XImage *clip_img; + XGCValues xgcv; + Pixmap clip_pix; + + colors = 0; + colors_direct = 0; + img = 0; + tab = 0; + pos = 0; + if (!(line = f(info,&pos,info_size)) || + !(tab = mlx_int_str_to_wordtab(line)) || !(width = atoi(tab[0])) || + !(height = atoi(tab[1])) || !(nc = atoi(tab[2])) || + !(cpp = atoi(tab[3])) ) + RETURN; + free(tab); + tab = 0; + + method = 0; + if (cpp<=2) + { + method = 1; + if (!(colors_direct = malloc((cpp==2?65536:256)*sizeof(int)))) + RETURN; + } + else + if (!(colors = malloc(nc*sizeof(*colors)))) + RETURN; + + clip_data = 0; + + i = nc; + while (i--) + { + if (!(line = f(info,&pos,info_size)) || + !(tab = mlx_int_str_to_wordtab(line+cpp)) ) + RETURN; + j = 0; + while (tab[j] && strcmp(tab[j++],"c")); + if (!tab[j]) + RETURN; + + if ((rgb_col = mlx_int_get_text_rgb(tab[j]))==-1) + { + if (!(clip_data = malloc(4*width*height)) || /* ok, nice size .. */ + !(clip_img = XCreateImage(xvar->display, xvar->visual, + 1, XYPixmap, 0, clip_data, + width, height, 8, (width+7)/8)) ) + RETURN; + memset(clip_data, 0xFF, 4*width*height); + } + + if (method) + colors_direct[mlx_int_get_col_name(line,cpp)] = + rgb_col>=0?mlx_get_color_value(xvar, rgb_col):rgb_col; + else + { + colors[i].name = mlx_int_get_col_name(line,cpp); + colors[i].col = rgb_col>=0?mlx_get_color_value(xvar,rgb_col):rgb_col; + } + free(tab); + } + + if (!(img = mlx_new_image(xvar,width,height))) + RETURN; + opp = img->bpp/8; + + + i = height; + data = img->data; + while (i--) + { + if (!(line = f(info,&pos,info_size))) + RETURN; + x = 0; + while (xsize_line; + } + if (clip_data) + { + if (!(clip_pix = XCreatePixmap(xvar->display, xvar->root, + width, height, 1)) ) + RETURN; + img->gc = XCreateGC(xvar->display, clip_pix, 0, &xgcv); + XPutImage(xvar->display, clip_pix, img->gc, clip_img, + 0, 0, 0, 0, width, height); + XFreeGC(xvar->display, img->gc); + xgcv.clip_mask = clip_pix; + xgcv.function = GXcopy; + xgcv.plane_mask = AllPlanes; + img->gc = XCreateGC(xvar->display, xvar->root, GCClipMask|GCFunction| + GCPlaneMask, &xgcv); + XSync(xvar->display, False); + XDestroyImage(clip_img); + } + if (colors) + free(colors); + if (colors_direct) + free(colors_direct); + return (img); +} + + +int mlx_int_file_get_rid_comment(char *ptr, int size) +{ + int com_begin; + int com_end; + + while ((com_begin = mlx_int_str_str_cote(ptr,"/*",size))!=-1) + { + com_end = mlx_int_str_str(ptr+com_begin+2,"*/",size-com_begin-2); + memset(ptr+com_begin,' ',com_end+4); + } + while ((com_begin = mlx_int_str_str_cote(ptr,"//",size))!=-1) + { + com_end = mlx_int_str_str(ptr+com_begin+2,"\n",size-com_begin-2); + memset(ptr+com_begin,' ',com_end+3); + } +} + + +void *mlx_xpm_file_to_image(t_xvar *xvar,char *file,int *width,int *height) +{ + int fd; + int size; + char *ptr; + t_img *img; + + fd = -1; + if ((fd = open(file,O_RDONLY))==-1 || (size = lseek(fd,0,SEEK_END))==-1 || + (ptr = mmap(0,size,PROT_WRITE|PROT_READ,MAP_PRIVATE,fd,0))== + (void *)MAP_FAILED) + { + if (fd>=0) + close(fd); + return ((void *)0); + } + mlx_int_file_get_rid_comment(ptr, size); + if (img = mlx_int_parse_xpm(xvar,ptr,size,mlx_int_get_line)) + { + *width = img->width; + *height = img->height; + } + munmap(ptr,size); + close(fd); + return (img); +} + +void *mlx_xpm_to_image(t_xvar *xvar,char **xpm_data,int *width,int *height) +{ + t_img *img; + + if (img = mlx_int_parse_xpm(xvar,xpm_data,0,mlx_int_static_line)) + { + *width = img->width; + *height = img->height; + } + return (img); +} diff --git a/minilibx-linux/rgb2c.pl b/minilibx-linux/rgb2c.pl new file mode 100755 index 0000000..9ef39a0 --- /dev/null +++ b/minilibx-linux/rgb2c.pl @@ -0,0 +1,38 @@ +#!/usr/bin/perl +# +## rgb2c.pl for MiniLibX in /home/boulon/work/c/raytraceur/minilibx +## +## Made by Olivier Crouzet +## Login +## +## Started on Tue Oct 5 16:33:46 2004 Olivier Crouzet +## Last update Tue Oct 5 16:36:11 2004 Olivier Crouzet +## + + +# +# Generate a .c file with encoded colors, from the XFree86 rgb.txt file. +# + +open(RGB, "/usr/X11/lib/X11/rgb.txt"); + + +printf("/*\n** This is a generated file with rgb2c.pl and rgb.txt from\n"); +printf("** the XFree86 distribution.\n*/\n\n"); +printf("struct s_col_name mlx_col_name[] =\n{\n"); + +while () +{ + @tab = split; + if ($tab[0] ne "!") + { + $color = $tab[3]; + if ("$tab[4]" ne "") + { + $color = "$tab[3] $tab[4]"; + } + printf(" { \"%s\" , 0x%x },\n", $color, $tab[0]*65536+$tab[1]*256+$tab[2]); + } +} + +printf(" { 0, 0 }\n};\n"); diff --git a/minilibx-linux/test/Makefile.mk b/minilibx-linux/test/Makefile.mk new file mode 100644 index 0000000..256235b --- /dev/null +++ b/minilibx-linux/test/Makefile.mk @@ -0,0 +1,45 @@ + +INC=%%%% + +INCLIB=$(INC)/../lib + +UNAME := $(shell uname) + +CFLAGS= -I$(INC) -O3 -I.. -g + +NAME= mlx-test +SRC = main.c +OBJ = $(SRC:%.c=%.o) + +LFLAGS = -L.. -lmlx -L$(INCLIB) -lXext -lX11 -lm + +ifeq ($(UNAME), Darwin) + # mac + CC = clang +else ifeq ($(UNAME), FreeBSD) + # FreeBSD + CC = clang +else + #Linux and others... + CC = gcc + LFLAGS += -lbsd +endif + +all: $(NAME) + +$(NAME): $(OBJ) + $(CC) -o $(NAME) $(OBJ) $(LFLAGS) + +show: + @printf "UNAME : $(UNAME)\n" + @printf "NAME : $(NAME)\n" + @printf "CC : $(CC)\n" + @printf "CFLAGS : $(CFLAGS)\n" + @printf "LFLAGS : $(LFLAGS)\n" + @printf "SRC :\n $(SRC)\n" + @printf "OBJ :\n $(OBJ)\n" + +clean: + rm -f $(NAME) $(OBJ) *~ core *.core + +re: clean all diff --git a/minilibx-linux/test/main.c b/minilibx-linux/test/main.c new file mode 100644 index 0000000..578eaae --- /dev/null +++ b/minilibx-linux/test/main.c @@ -0,0 +1,287 @@ + +#include "mlx.h" +#include "mlx_int.h" + +#define WIN1_SX 242 +#define WIN1_SY 242 +#define IM1_SX 42 +#define IM1_SY 42 +#define IM3_SX 242 +#define IM3_SY 242 + +void *mlx; +void *win1; +void *win2; +void *win3; +void *im1; +void *im2; +void *im3; +void *im4; +int bpp1; +int bpp2; +int bpp3; +int bpp4; +int sl1; +int sl2; +int sl3; +int sl4; +int endian1; +int endian2; +int endian3; +int endian4; +char *data1; +char *data2; +char *data3; +char *data4; +int xpm1_x; +int xpm1_y; + +int local_endian; + +int color_map_1(void *win,int w,int h); +int color_map_2(unsigned char *data,int bpp,int sl,int w,int h,int endian, int type); + +int expose_win1(void *p) +{ + mlx_put_image_to_window(mlx,win1,im3,0,0); +} + +int expose_win2(void *p) +{ + mlx_put_image_to_window(mlx,win2,im4,0,0); + mlx_put_image_to_window(mlx,win2,im2,0,0); +} + +int key_win1(int key,void *p) +{ + printf("Key in Win1 : %d\n",key); + if (key==0xFF1B) + exit(0); +} + +int key_win2(int key,void *p) +{ + printf("Key in Win2 : %d\n",key); + if (key==0xFF1B) + exit(0); +} + +int key_win3(int key,void *p) +{ + printf("Key in Win3 : %d\n",key); + if (key==0xFF1B) + mlx_destroy_window(mlx,win3); +} + +int mouse_win1(int button,int x,int y, void *p) +{ + printf("Mouse in Win1, button %d at %dx%d.\n",button,x,y); +} + +int mouse_win2(int button,int x,int y, void *p) +{ + printf("Mouse in Win2, button %d at %dx%d.\n",button,x,y); +} + +int mouse_win3(int x,int y, void *p) +{ + printf("Mouse moving in Win3, at %dx%d.\n",x,y); +} + + +int main() +{ + int a; + + printf("MinilibX Test Program\n"); + a = 0x11223344; + if (((unsigned char *)&a)[0] == 0x11) + local_endian = 1; + else + local_endian = 0; + printf(" => Local Endian : %d\n",local_endian); + + printf(" => Connection ..."); + if (!(mlx = mlx_init())) + { + printf(" !! KO !!\n"); + exit(1); + } + printf("OK (use_xshm %d pshm_format %d)\n",((t_xvar *)mlx)->use_xshm,((t_xvar *)mlx)->pshm_format); + + printf(" => Window1 %dx%d \"Title 1\" ...",WIN1_SX,WIN1_SY); + if (!(win1 = mlx_new_window(mlx,WIN1_SX,WIN1_SY,"Title1"))) + { + printf(" !! KO !!\n"); + exit(1); + } + printf("OK\n"); + + printf(" => Colormap sans event ..."); + color_map_1(win1,WIN1_SX,WIN1_SY); + printf("OK\n"); + sleep(2); + + printf(" => Clear Window ..."); + mlx_clear_window(mlx,win1); + printf("OK\n"); + sleep(2); + + printf(" => Image1 ZPixmap %dx%d ...",IM1_SX,IM1_SY); + if (!(im1 = mlx_new_image(mlx,IM1_SX,IM1_SY))) + { + printf(" !! KO !!\n"); + exit(1); + } + data1 = mlx_get_data_addr(im1,&bpp1,&sl1,&endian1); + printf("OK (bpp1: %d, sizeline1: %d endian: %d type: %d)\n",bpp1,sl1,endian1, + ((t_img *)im1)->type); + + printf(" => Fill Image1 ..."); + color_map_2(data1,bpp1,sl1,IM1_SX,IM1_SY,endian1, 1); + printf("OK (pixmap : %d)\n",(int)((t_img *)im1)->pix); + + printf(" => Put Image1 ..."); + mlx_put_image_to_window(mlx,win1,im1,20,20); + printf("OK\n"); + sleep(2); + + printf(" => Destroy Image1 ... "); + mlx_destroy_image(mlx, im1); + printf("OK\n"); + sleep(2); + + printf(" => Image3 ZPixmap %dx%d ...",IM3_SX,IM3_SY); + if (!(im3 = mlx_new_image(mlx,IM3_SX,IM3_SY))) + { + printf(" !! KO !!\n"); + exit(1); + } + data3 = mlx_get_data_addr(im3,&bpp3,&sl3,&endian3); + printf("OK (bpp3 %d, sizeline3 %d endian3 %d type %d)\n",bpp3,sl3,endian3, + ((t_img *)im3)->type); + + printf(" => Fill Image3 ..."); + color_map_2(data3,bpp3,sl3,IM3_SX,IM3_SY,endian3, 1); + printf("OK (pixmap : %d)\n",(int)((t_img *)im3)->pix); + + printf(" => Put Image3 ..."); + mlx_put_image_to_window(mlx,win1,im3,20,20); + printf("OK\n"); + sleep(2); + + printf(" => String ..."); + mlx_string_put(mlx,win1,5,WIN1_SY/2,0xFF99FF,"String output"); + mlx_string_put(mlx,win1,15,WIN1_SY/2+20,0x00FFFF,"MinilibX test"); + printf("OK\n"); + sleep(2); + + printf(" => Xpm from file ..."); + if (!(im2 = mlx_xpm_file_to_image(mlx,"open.xpm",&xpm1_x,&xpm1_y))) + { + printf(" !! KO !!\n"); + exit(1); + } + data2 = mlx_get_data_addr(im2,&bpp2,&sl2,&endian2); + printf("OK (xpm %dx%d)(img bpp2: %d, sizeline2: %d endian: %d type: %d)\n", + xpm1_x,xpm1_y,bpp2,sl2,endian2,((t_img *)im2)->type); + sleep(2); + + printf(" => Put xpm ..."); + mlx_put_image_to_window(mlx,win1,im2,0,0); + mlx_put_image_to_window(mlx,win1,im2,100,100); + printf("OK\n"); + sleep(2); + + printf(" => 2nd window,"); + win2 = mlx_new_window(mlx,WIN1_SX,WIN1_SY,"Title2"); + if (!(im4 = mlx_new_image(mlx,IM3_SX, IM3_SY))) + { + printf(" !! KO !!\n"); + exit(1); + } + data4 = mlx_get_data_addr(im4,&bpp4,&sl4,&endian4); + color_map_2(data4,bpp4,sl4,IM3_SX,IM3_SY,endian4, 2); + + printf(" 3rd window, Installing hooks ..."); + win3 = mlx_new_window(mlx,WIN1_SX,WIN1_SY,"Title3"); + mlx_expose_hook(win1,expose_win1,0); + mlx_mouse_hook(win1,mouse_win1,0); + mlx_key_hook(win1,key_win1,0); + mlx_expose_hook(win2,expose_win2,0); + mlx_mouse_hook(win2,mouse_win2,0); + mlx_key_hook(win2,key_win2,0); + mlx_key_hook(win3,key_win3,0); + + mlx_hook(win3, MotionNotify, PointerMotionMask, mouse_win3, 0); + + printf("OK\nNow in Loop. Just play. Esc in 3 to destroy, 1&2 to quit.\n"); + + mlx_loop(mlx); +} + + +int color_map_1(void *win,int w,int h) +{ + int x; + int y; + int color; + + x = w; + while (x--) + { + y = h; + while (y--) + { + color = (x*255)/w+((((w-x)*255)/w)<<16)+(((y*255)/h)<<8); + mlx_pixel_put(mlx,win,x,y,color); + } + } +} + + +int color_map_2(unsigned char *data,int bpp,int sl,int w,int h,int endian, int type) +{ + int x; + int y; + int opp; + int dec; + int color; + int color2; + unsigned char *ptr; + + opp = bpp/8; + printf("(opp : %d) ",opp); + y = h; + while (y--) + { + ptr = data+y*sl; + x = w; + while (x--) + { + if (type==2) + color = (y*255)/w+((((w-x)*255)/w)<<16) + +(((y*255)/h)<<8); + else + color = (x*255)/w+((((w-x)*255)/w)<<16)+(((y*255)/h)<<8); + color2 = mlx_get_color_value(mlx,color); + dec = opp; + while (dec--) + if (endian==local_endian) + { + if (endian) + *(ptr+x*opp+dec) = ((unsigned char *)(&color2))[4-opp+dec]; + else + *(ptr+x*opp+dec) = ((unsigned char *)(&color2))[dec]; + } + else + { + if (endian) + *(ptr+x*opp+dec) = ((unsigned char *)(&color2))[opp-1-dec]; + else + *(ptr+x*opp+dec) = ((unsigned char *)(&color2))[3-dec]; + } + } + } + +} diff --git a/minilibx-linux/test/new_win.c b/minilibx-linux/test/new_win.c new file mode 100644 index 0000000..62bed4b --- /dev/null +++ b/minilibx-linux/test/new_win.c @@ -0,0 +1,31 @@ + + + +#include "mlx.h" + + +void *mlx; +void *win1; +void *win2; + + + +int gere_mouse(int x,int y,int button,void*toto) +{ + printf("Mouse event - new win\n"); + mlx_destroy_window(mlx,win1); + win1 = mlx_new_window(mlx,random()%500,random()%500,"new win"); + mlx_mouse_hook(win1,gere_mouse,0); +} + + +int main() +{ + srandom(time(0)); + mlx = mlx_init(); + win1 = mlx_new_window(mlx,300,300,"win1"); + win2 = mlx_new_window(mlx,600,600,"win2"); + mlx_mouse_hook(win1,gere_mouse,0); + mlx_mouse_hook(win2,gere_mouse,0); + mlx_loop(mlx); +} diff --git a/minilibx-linux/test/open.xpm b/minilibx-linux/test/open.xpm new file mode 100644 index 0000000..87be371 --- /dev/null +++ b/minilibx-linux/test/open.xpm @@ -0,0 +1,1439 @@ +/* XPM */ +static char * open30_2_xpm[] = { +"64 64 1372 2", +" c None", +". c #08090D", +"+ c #1A1E23", +"@ c #1F2124", +"# c #060809", +"$ c #1A1E21", +"% c #4F606C", +"& c #3D4145", +"* c #868D93", +"= c #454E56", +"- c #627481", +"; c #667C8A", +"> c #2D3031", +", c #D7E1E7", +"' c #4D5157", +") c #8997A5", +"! c #282E31", +"~ c #333B41", +"{ c #A5C6DB", +"] c #718C9B", +"^ c #000000", +"/ c #181B1F", +"( c #262828", +"_ c #D2DEE7", +": c #B8C5D0", +"< c #151719", +"[ c #08090B", +"} c #272B30", +"| c #2D3037", +"1 c #26282C", +"2 c #1A1D1F", +"3 c #B1CADB", +"4 c #56646E", +"5 c #080809", +"6 c #080A0C", +"7 c #1E2126", +"8 c #98B7C9", +"9 c #A2CAE2", +"0 c #7FA1B5", +"a c #06080A", +"b c #252729", +"c c #A7ADB2", +"d c #272B2E", +"e c #1E2023", +"f c #C8D8E5", +"g c #C9DDED", +"h c #8996A3", +"i c #6B7782", +"j c #C7DFF0", +"k c #CCE0F0", +"l c #AFC1CF", +"m c #47535B", +"n c #B0D3E8", +"o c #7E99A9", +"p c #738493", +"q c #97B4C7", +"r c #53606A", +"s c #6E8996", +"t c #A1CBE3", +"u c #9CC6DE", +"v c #90B5CB", +"w c #171D22", +"x c #1E2629", +"y c #020202", +"z c #ABB3BA", +"A c #BBC4C8", +"B c #222323", +"C c #141617", +"D c #5D6164", +"E c #ACB5BC", +"F c #676D74", +"G c #BDD4E5", +"H c #B3D1E7", +"I c #B0D1E7", +"J c #728A99", +"K c #94AEBF", +"L c #B1D1E7", +"M c #505C64", +"N c #7B98A9", +"O c #A1CBE0", +"P c #99C3D9", +"Q c #475863", +"R c #A0C9DE", +"S c #9CC6DA", +"T c #9ECAE1", +"U c #9CC5DD", +"V c #9AC4DC", +"W c #263137", +"X c #3C4A55", +"Y c #658190", +"Z c #66686B", +"` c #7D8085", +" . c #363839", +".. c #797E81", +"+. c #D2DBE1", +"@. c #DDE9F4", +"#. c #CADEEF", +"$. c #778593", +"%. c #AED0E5", +"&. c #9EC9DE", +"*. c #9EC8DF", +"=. c #9BC1D8", +"-. c #9EC8DE", +";. c #6B8596", +">. c #9BC5DC", +",. c #9BC6DF", +"'. c #9CC5DC", +"). c #688595", +"!. c #6B8698", +"~. c #9CC4DC", +"{. c #9BC4DC", +"]. c #9DC5DD", +"^. c #647D8C", +"/. c #485864", +"(. c #161A1D", +"_. c #36444C", +":. c #95BDD5", +"<. c #566E7E", +"[. c #A4AAAD", +"}. c #E9F2F7", +"|. c #DEEAF6", +"1. c #B5D4E9", +"2. c #A9CFE3", +"3. c #90B3C9", +"4. c #9FCAE1", +"5. c #9BC4DD", +"6. c #7490A2", +"7. c #99C2DB", +"8. c #81A5BA", +"9. c #9CC5DE", +"0. c #98C1DA", +"a. c #5F7889", +"b. c #96BFD8", +"c. c #44545F", +"d. c #565A5E", +"e. c #DFE6EC", +"f. c #E6EEF7", +"g. c #D6E4F2", +"h. c #BFD6E9", +"i. c #A9CCE3", +"j. c #9FC8DD", +"k. c #9DC6DD", +"l. c #9CC4DD", +"m. c #7D9FB0", +"n. c #98C0D6", +"o. c #9AC5DD", +"p. c #97BFD8", +"q. c #9BC5DF", +"r. c #2D3840", +"s. c #626567", +"t. c #E7ECF5", +"u. c #E1EAF5", +"v. c #CEE3F3", +"w. c #B7D6EA", +"x. c #A4CBE0", +"y. c #8AAFC5", +"z. c #647F90", +"A. c #648092", +"B. c #89B0C7", +"C. c #9CC6DF", +"D. c #5D7486", +"E. c #7B9BAF", +"F. c #84A8BF", +"G. c #9BC5DD", +"H. c #96BED5", +"I. c #4B5D69", +"J. c #9BC5DE", +"K. c #536B77", +"L. c #2E3B41", +"M. c #1B2124", +"N. c #3F4F58", +"O. c #4D5152", +"P. c #E7EEF3", +"Q. c #E2EAF5", +"R. c #CEE2F2", +"S. c #BAD5E9", +"T. c #9DC2D7", +"U. c #5C7281", +"V. c #232A31", +"W. c #08090A", +"X. c #121418", +"Y. c #131619", +"Z. c #131719", +"`. c #87ACC3", +" + c #7B9BAE", +".+ c #87ADC3", +"++ c #8FB5CB", +"@+ c #678295", +"#+ c #96C0D8", +"$+ c #607787", +"%+ c #6B8595", +"&+ c #96C1DB", +"*+ c #6A8595", +"=+ c #35424A", +"-+ c #7090A1", +";+ c #15191C", +">+ c #2D3033", +",+ c #DDE5EB", +"'+ c #D2E3F1", +")+ c #BAD7EB", +"!+ c #A9CFE5", +"~+ c #272F35", +"{+ c #1C2227", +"]+ c #4F697B", +"^+ c #6B8FA9", +"/+ c #759CB6", +"(+ c #7BA0BB", +"_+ c #80A5BC", +":+ c #88B0C8", +"<+ c #96C3DB", +"[+ c #8FB6CD", +"}+ c #80A1B3", +"|+ c #556876", +"1+ c #96BFD7", +"2+ c #566B77", +"3+ c #93B8CD", +"4+ c #637A8D", +"5+ c #9DC6DE", +"6+ c #8FB4CA", +"7+ c #55697A", +"8+ c #6F8F9F", +"9+ c #91BDD5", +"0+ c #283239", +"a+ c #050406", +"b+ c #767B80", +"c+ c #BDC6CE", +"d+ c #D4E5F3", +"e+ c #C1D7EA", +"f+ c #A7CDE4", +"g+ c #9FC9DE", +"h+ c #668596", +"i+ c #6D90AA", +"j+ c #5C7994", +"k+ c #60849F", +"l+ c #6286A1", +"m+ c #688CA8", +"n+ c #7298B2", +"o+ c #82A8C2", +"p+ c #8FBAD5", +"q+ c #96C2DB", +"r+ c #89ADC4", +"s+ c #96BED6", +"t+ c #99C2DA", +"u+ c #6C899A", +"v+ c #92BBD2", +"w+ c #9AC4DD", +"x+ c #5B717D", +"y+ c #9EC6DE", +"z+ c #8BB1C9", +"A+ c #718EA0", +"B+ c #94C3DB", +"C+ c #536B78", +"D+ c #3E505F", +"E+ c #4E6373", +"F+ c #2C333C", +"G+ c #070708", +"H+ c #040404", +"I+ c #1A1C1E", +"J+ c #202326", +"K+ c #050606", +"L+ c #23292E", +"M+ c #A1C0D4", +"N+ c #9FC9DD", +"O+ c #97C2DB", +"P+ c #80A8C1", +"Q+ c #668AA6", +"R+ c #4B5D72", +"S+ c #4C647A", +"T+ c #5F80A0", +"U+ c #60859E", +"V+ c #678AA6", +"W+ c #739BB5", +"X+ c #85AEC7", +"Y+ c #92BDD7", +"Z+ c #96BFD5", +"`+ c #627B8A", +" @ c #89B1C9", +".@ c #2B353C", +"+@ c #7597B2", +"@@ c #779CB8", +"#@ c #52697C", +"$@ c #1D2328", +"%@ c #445663", +"&@ c #5E7A8D", +"*@ c #252F37", +"=@ c #090909", +"-@ c #859BB2", +";@ c #859DB8", +">@ c #6E8396", +",@ c #252C33", +"'@ c #9CC4D7", +")@ c #92C0D9", +"!@ c #79A0BA", +"~@ c #6487A3", +"{@ c #566979", +"]@ c #8CB0C2", +"^@ c #51697C", +"/@ c #60849D", +"(@ c #6D8EAC", +"_@ c #7BA0BC", +":@ c #8AB4CE", +"<@ c #95C2DB", +"[@ c #9AC5DC", +"}@ c #95C1DA", +"|@ c #607B8C", +"1@ c #597488", +"2@ c #7EA6BF", +"3@ c #597587", +"4@ c #455664", +"5@ c #668598", +"6@ c #82A9C4", +"7@ c #617F92", +"8@ c #1A2328", +"9@ c #2B3137", +"0@ c #728FAC", +"a@ c #51657B", +"b@ c #6B8AA8", +"c@ c #8EAEC7", +"d@ c #A8C8E2", +"e@ c #92BDD6", +"f@ c #769DBA", +"g@ c #526E87", +"h@ c #7490A0", +"i@ c #A6CDE4", +"j@ c #97BFD4", +"k@ c #55697D", +"l@ c #6286A0", +"m@ c #7399B3", +"n@ c #84ACC5", +"o@ c #92BFD9", +"p@ c #99C4DC", +"q@ c #94C0DA", +"r@ c #4F6575", +"s@ c #7DA5BF", +"t@ c #7FA2BC", +"u@ c #8FB6CE", +"v@ c #95C3DB", +"w@ c #8EB8D2", +"x@ c #6A879D", +"y@ c #111318", +"z@ c #252A30", +"A@ c #81868C", +"B@ c #A5ABAD", +"C@ c #70767C", +"D@ c #38434F", +"E@ c #637F9B", +"F@ c #516980", +"G@ c #799AB5", +"H@ c #A5C3D9", +"I@ c #93BDD6", +"J@ c #779EBA", +"K@ c #445A6B", +"L@ c #93B5C9", +"M@ c #B6D3E8", +"N@ c #AECFE4", +"O@ c #95BDD2", +"P@ c #52687A", +"Q@ c #6486A3", +"R@ c #7092B0", +"S@ c #90BCD6", +"T@ c #97C4DC", +"U@ c #A0C9E0", +"V@ c #99C5DD", +"W@ c #86AEC6", +"X@ c #8FBAD4", +"Y@ c #91BDD6", +"Z@ c #7094AC", +"`@ c #2A353E", +" # c #0B0E10", +".# c #888D90", +"+# c #787D82", +"@# c #465360", +"## c #56697F", +"$# c #A6CADD", +"%# c #5A7382", +"&# c #6C8CAA", +"*# c #A5BED3", +"=# c #A7CAE0", +"-# c #94C1DA", +";# c #7EA4BF", +"># c #415160", +",# c #9DC3D5", +"'# c #B3CFE1", +")# c #AAC3D4", +"!# c #A8CDE4", +"~# c #89ACBE", +"{# c #567088", +"]# c #6C91AC", +"^# c #81A7C2", +"/# c #96C4DC", +"(# c #85A9BD", +"_# c #708C9B", +":# c #5A6E7B", +"<# c #6C8695", +"[# c #97C3DB", +"}# c #8BB5CE", +"|# c #425461", +"1# c #63819E", +"2# c #415465", +"3# c #0B0D0E", +"4# c #607387", +"5# c #687D8C", +"6# c #B8D6E9", +"7# c #7893A2", +"8# c #576F85", +"9# c #A7BACF", +"0# c #B0CEE5", +"a# c #98C4DC", +"b# c #88B1CA", +"c# c #36444E", +"d# c #8FA0AD", +"e# c #73818D", +"f# c #596D81", +"g# c #B4D0E4", +"h# c #A3CDE2", +"i# c #658296", +"j# c #6A8DAB", +"k# c #7BA5C0", +"l# c #94BAD2", +"m# c #6D899B", +"n# c #99C3DC", +"o# c #8EB9D2", +"p# c #7AA0BA", +"q# c #6C8FAB", +"r# c #6484A1", +"s# c #1F252C", +"t# c #121619", +"u# c #7E96B0", +"v# c #7A8A96", +"w# c #BCD7EA", +"x# c #A0C5D9", +"y# c #3C4B57", +"z# c #A9BACD", +"A# c #BCD5E8", +"B# c #84A6BA", +"C# c #8EA1AE", +"D# c #CFD1D4", +"E# c #ECF6FA", +"F# c #ABB7C2", +"G# c #556F84", +"H# c #57626A", +"I# c #5C7078", +"J# c #6C8AA7", +"K# c #80A6C0", +"L# c #91B8D0", +"M# c #94BFD8", +"N# c #87B0CA", +"O# c #7CA2BB", +"P# c #7097AF", +"Q# c #495E6F", +"R# c #0C0E11", +"S# c #3A3F43", +"T# c #8AA3BB", +"U# c #778592", +"V# c #C0D8EB", +"W# c #B3D5E9", +"X# c #404A53", +"Y# c #B2C2D3", +"Z# c #96A1AC", +"`# c #9DB2C3", +" $ c #AEBECE", +".$ c #EDEFF3", +"+$ c #F7FAFC", +"@$ c #B6BFC7", +"#$ c #556E85", +"$$ c #121314", +"%$ c #2B2E2F", +"&$ c #555A5E", +"*$ c #3B4C5B", +"=$ c #6F8EA4", +"-$ c #92BED8", +";$ c #9DC7DF", +">$ c #87ACC1", +",$ c #546A78", +"'$ c #516874", +")$ c #4E6570", +"!$ c #4D6271", +"~$ c #4C6271", +"{$ c #4E677A", +"]$ c #38454E", +"^$ c #6C7278", +"/$ c #86A1B6", +"($ c #5C656C", +"_$ c #A4B0BA", +":$ c #555D64", +"<$ c #657178", +"[$ c #A6B0B5", +"}$ c #939CA1", +"|$ c #D4E4F1", +"1$ c #A0BACE", +"2$ c #B9C7D7", +"3$ c #F6F7F9", +"4$ c #C6CED1", +"5$ c #506A7C", +"6$ c #060607", +"7$ c #676A6B", +"8$ c #91999F", +"9$ c #7CA3BE", +"0$ c #96BCD4", +"a$ c #5B717E", +"b$ c #4B5F6C", +"c$ c #455864", +"d$ c #5B717F", +"e$ c #81A5B9", +"f$ c #98C4DD", +"g$ c #93BFD8", +"h$ c #87B1CA", +"i$ c #7BA1BC", +"j$ c #5A7489", +"k$ c #222A33", +"l$ c #838A92", +"m$ c #9DADBC", +"n$ c #ECF0F5", +"o$ c #F1F9FB", +"p$ c #818A8D", +"q$ c #4A5155", +"r$ c #6A6F72", +"s$ c #7E898F", +"t$ c #E6F1F7", +"u$ c #CADCED", +"v$ c #A0B7CC", +"w$ c #C6D1DF", +"x$ c #AFB3B4", +"y$ c #5F707D", +"z$ c #CBCFD1", +"A$ c #F4F5F6", +"B$ c #66737F", +"C$ c #87B2CB", +"D$ c #90B7CD", +"E$ c #596E7B", +"F$ c #586F7E", +"G$ c #8BB0C8", +"H$ c #91BED6", +"I$ c #83ADC7", +"J$ c #6D8EA7", +"K$ c #3F5161", +"L$ c #2D3A45", +"M$ c #1F2020", +"N$ c #BDC5CC", +"O$ c #E0EDF5", +"P$ c #BBCAD8", +"Q$ c #E1E4E7", +"R$ c #5E6368", +"S$ c #5B5F62", +"T$ c #D9E7F3", +"U$ c #A4C3D6", +"V$ c #89A3B3", +"W$ c #7B91A1", +"X$ c #627990", +"Y$ c #42505A", +"Z$ c #CACCCE", +"`$ c #F9F9F9", +" % c #FDFDFD", +".% c #BCBEC0", +"+% c #5C7689", +"@% c #8DB9D3", +"#% c #8FB5CC", +"$% c #536471", +"%% c #98C1D9", +"&% c #91BED7", +"*% c #81AAC5", +"=% c #597386", +"-% c #41535F", +";% c #6486A2", +">% c #4D667D", +",% c #070809", +"'% c #44484E", +")% c #BEC8D0", +"!% c #8096A6", +"~% c #516473", +"{% c #A9ACAF", +"]% c #8B8F91", +"^% c #A8B3BD", +"/% c #C5DAEB", +"(% c #9FC8E1", +"_% c #8FBCD6", +":% c #81A8C2", +"<% c #6C90AC", +"[% c #56728C", +"}% c #585B5F", +"|% c #CBCDCD", +"1% c #C1C3C6", +"2% c #4F565F", +"3% c #82ABC3", +"4% c #93BCD3", +"5% c #95BED7", +"6% c #8EB9D3", +"7% c #5B788B", +"8% c #627E91", +"9% c #7FA7C1", +"0% c #6C91AB", +"a% c #546F87", +"b% c #6F7376", +"c% c #D5E2EF", +"d% c #A9C4D8", +"e% c #81A1BA", +"f% c #333940", +"g% c #5F6B76", +"h% c #C0D5E8", +"i% c #AACCE2", +"j% c #8EB8D3", +"k% c #7FA5BF", +"l% c #7095B0", +"m% c #4E697E", +"n% c #07090A", +"o% c #0D0F10", +"p% c #7193A6", +"q% c #96C3DC", +"r% c #8EBCD7", +"s% c #91BDD7", +"t% c #8FBBD6", +"u% c #7699AD", +"v% c #4D626F", +"w% c #252D33", +"x% c #101215", +"y% c #0C0D0E", +"z% c #0A0C0E", +"A% c #06090A", +"B% c #7F8488", +"C% c #D7E3F1", +"D% c #B6D0E4", +"E% c #A3C2D7", +"F% c #596872", +"G% c #A9BED0", +"H% c #B4D0E5", +"I% c #9EC8DC", +"J% c #8FB9D4", +"K% c #85ADC7", +"L% c #7FA4BE", +"M% c #4B606F", +"N% c #4E6372", +"O% c #89B6D0", +"P% c #92C1DA", +"Q% c #9DC7DD", +"R% c #95C0DA", +"S% c #94BED8", +"T% c #8BB8D1", +"U% c #7AA0B9", +"V% c #4E667A", +"W% c #344151", +"X% c #0C0D0F", +"Y% c #8A8F92", +"Z% c #D4E6F5", +"`% c #BCD5E9", +" & c #8599A5", +".& c #939DA6", +"+& c #C4DAEB", +"@& c #89A6B9", +"#& c #7D9FB5", +"$& c #98C3DC", +"%& c #95C0D9", +"&& c #7CA2B9", +"*& c #7697AE", +"=& c #698498", +"-& c #7394A8", +";& c #9EC7DF", +">& c #8DB1C4", +",& c #6B8594", +"'& c #50636C", +")& c #50626C", +"!& c #7F9FB1", +"~& c #93B8D0", +"{& c #627A88", +"]& c #90B6CC", +"^& c #93BDD7", +"/& c #87AFC9", +"(& c #7291A7", +"_& c #384651", +":& c #121618", +"<& c #12171B", +"[& c #4F6986", +"}& c #597998", +"|& c #324052", +"1& c #969CA1", +"2& c #D6E6F5", +"3& c #C6DCEE", +"4& c #505A64", +"5& c #82929F", +"6& c #99ABBB", +"7& c #A1B9CA", +"8& c #87A0B0", +"9& c #718EA1", +"0& c #8DB2C9", +"a& c #8BAEC4", +"b& c #586D7D", +"c& c #97C0D9", +"d& c #8DB3C9", +"e& c #95B8CD", +"f& c #9DC0D6", +"g& c #6F8B9C", +"h& c #354249", +"i& c #464E54", +"j& c #8A98A5", +"k& c #AABAC7", +"l& c #86939E", +"m& c #41494F", +"n& c #4A5861", +"o& c #97C1DA", +"p& c #5E7888", +"q& c #5C7482", +"r& c #88ACC2", +"s& c #91BFD7", +"t& c #799CB5", +"u& c #47596A", +"v& c #0D0F12", +"w& c #1A2127", +"x& c #56778D", +"y& c #688BA9", +"z& c #5D7F9E", +"A& c #547391", +"B& c #0E1013", +"C& c #9DA6AB", +"D& c #C8DCED", +"E& c #7A8996", +"F& c #B5CEE0", +"G& c #BCDBEC", +"H& c #B9D5EA", +"I& c #8BA2B2", +"J& c #6C8A9D", +"K& c #97BFD7", +"L& c #3E4E59", +"M& c #92B5CB", +"N& c #535F68", +"O& c #454F56", +"P& c #6F7C87", +"Q& c #ABC0D1", +"R& c #C7DCEE", +"S& c #C5DBED", +"T& c #C2D7EA", +"U& c #BFD8EA", +"V& c #BCD7EB", +"W& c #62717B", +"X& c #5B6F7B", +"Y& c #95C3DC", +"Z& c #8BB2C9", +"`& c #485761", +" * c #42525F", +".* c #6686A1", +"+* c #587896", +"@* c #1B2129", +"#* c #5C7A94", +"$* c #7DA2BD", +"%* c #84AEC7", +"&* c #749BB5", +"** c #5C7E9C", +"=* c #27343F", +"-* c #A4A9B2", +";* c #D9E7F4", +">* c #C8DBEC", +",* c #B1C8DA", +"'* c #5D6C76", +")* c #A8C5D8", +"!* c #A6BDD0", +"~* c #B9D6EA", +"{* c #B9D4E9", +"]* c #8198A8", +"^* c #8AADC3", +"/* c #8CB1CA", +"(* c #96C2D8", +"_* c #A3C7DF", +":* c #ADCDE3", +"<* c #ABD0E4", +"[* c #ADCFE3", +"}* c #AACEE4", +"|* c #A4CDE3", +"1* c #A1CBE1", +"2* c #A3CCE3", +"3* c #A2C9DF", +"4* c #41515A", +"5* c #81A2B5", +"6* c #94C0D7", +"7* c #5E7789", +"8* c #526777", +"9* c #516777", +"0* c #6B8CA5", +"a* c #759CBA", +"b* c #658AA5", +"c* c #587798", +"d* c #1B242B", +"e* c #0E1110", +"f* c #101214", +"g* c #202931", +"h* c #59758E", +"i* c #799FBB", +"j* c #84B1CA", +"k* c #86ACC6", +"l* c #354758", +"m* c #A0A6AE", +"n* c #DAE6F2", +"o* c #C4DCEE", +"p* c #B4D2E8", +"q* c #3E4A53", +"r* c #698091", +"s* c #5D7581", +"t* c #A3CAE0", +"u* c #A6CFE5", +"v* c #A5CCE5", +"w* c #718A9C", +"x* c #98C3DB", +"y* c #83ABC7", +"z* c #2E3B46", +"A* c #33414A", +"B* c #678398", +"C* c #8AB3CE", +"D* c #93BED7", +"E* c #97C4DB", +"F* c #42525E", +"G* c #88ACC0", +"H* c #789EB9", +"I* c #7A9FBB", +"J* c #7EA2BD", +"K* c #779DB5", +"L* c #577081", +"M* c #5B7B9B", +"N* c #1D2229", +"O* c #547390", +"P* c #54728D", +"Q* c #6082A0", +"R* c #688EA9", +"S* c #6689A7", +"T* c #6086A0", +"U* c #6285A1", +"V* c #6B8DAA", +"W* c #718FAB", +"X* c #3E5568", +"Y* c #969DA1", +"Z* c #DBE8F4", +"`* c #95ACBD", +" = c #758B9A", +".= c #A4C9DE", +"+= c #698190", +"@= c #667E8A", +"#= c #7D99AA", +"$= c #7B9BAD", +"%= c #6F8C9A", +"&= c #536976", +"*= c #84ADC6", +"== c #6D92AD", +"-= c #62829E", +";= c #43576A", +">= c #2F3B46", +",= c #5C788A", +"'= c #86AFC8", +")= c #93BED8", +"!= c #93BAD5", +"~= c #93BAD2", +"{= c #92BCD4", +"]= c #7EA2B6", +"^= c #3D4D56", +"/= c #485B67", +"(= c #7596A9", +"_= c #8CBBD4", +":= c #90BCD5", +"<= c #91BFD9", +"[= c #789BAD", +"}= c #465B6A", +"|= c #59789A", +"1= c #5D7F9D", +"2= c #5E839C", +"3= c #59799A", +"4= c #415569", +"5= c #2D3A46", +"6= c #2E3B49", +"7= c #4A647C", +"8= c #587690", +"9= c #39485A", +"0= c #7F8589", +"a= c #D9E8F5", +"b= c #CCDEEE", +"c= c #8597A5", +"d= c #B3D2E3", +"e= c #9BB3C4", +"f= c #B2CEE1", +"g= c #B2D1E7", +"h= c #ABCFE6", +"i= c #94B7CB", +"j= c #495C6A", +"k= c #688498", +"l= c #617B8A", +"m= c #85ADC8", +"n= c #78A0B9", +"o= c #62819B", +"p= c #2E3843", +"q= c #485A6C", +"r= c #67889C", +"s= c #8AB5CF", +"t= c #8EB9D1", +"u= c #6C899B", +"v= c #6E91A7", +"w= c #678399", +"x= c #6888A1", +"y= c #323E48", +"z= c #5B7585", +"A= c #98C5DD", +"B= c #83ACC1", +"C= c #2D373F", +"D= c #4B637C", +"E= c #567694", +"F= c #26313C", +"G= c #15191F", +"H= c #4D647A", +"I= c #252F39", +"J= c #5D6163", +"K= c #DDE9F5", +"L= c #CEDFEE", +"M= c #8898A5", +"N= c #B0CBDC", +"O= c #BFDAEC", +"P= c #BFDBEC", +"Q= c #BBDAEC", +"R= c #BAD7EA", +"S= c #6B808F", +"T= c #7297B0", +"U= c #8CB8D1", +"V= c #95C1D9", +"W= c #91BCD6", +"X= c #86AEC8", +"Y= c #7496B3", +"Z= c #6587A2", +"`= c #384958", +" - c #323F4B", +".- c #546A7C", +"+- c #6C88A1", +"@- c #779AB1", +"#- c #658297", +"$- c #3B4A58", +"%- c #33404B", +"&- c #202830", +"*- c #577287", +"=- c #86B1CC", +"-- c #86ACC0", +";- c #6E8797", +">- c #9CC7DF", +",- c #92BCD5", +"'- c #91BCD5", +")- c #8EB6CE", +"!- c #344453", +"~- c #263039", +"{- c #364452", +"]- c #2B3643", +"^- c #2A2D2E", +"/- c #E1EBF4", +"(- c #D2E4F3", +"_- c #A0B2C3", +":- c #8094A1", +"<- c #BAD8EB", +"[- c #B8D6EA", +"}- c #485A6A", +"|- c #789FB9", +"1- c #90BBD3", +"2- c #94C4DC", +"3- c #88B3CD", +"4- c #7A9EB9", +"5- c #698BA8", +"6- c #4D677C", +"7- c #151A1E", +"8- c #1A2125", +"9- c #171C21", +"0- c #1D2329", +"a- c #1D262E", +"b- c #486073", +"c- c #6A8CAA", +"d- c #7CA2BE", +"e- c #90BDD7", +"f- c #9AC5DE", +"g- c #7493A2", +"h- c #708B99", +"i- c #8CB7D1", +"j- c #7494AB", +"k- c #68889F", +"l- c #6A8FA5", +"m- c #7BA2BC", +"n- c #171D21", +"o- c #1D262F", +"p- c #212B36", +"q- c #09090B", +"r- c #BBC2C9", +"s- c #D4E4F2", +"t- c #C1D9EB", +"u- c #44515A", +"v- c #92B5C9", +"w- c #6B8795", +"x- c #4E687E", +"y- c #7EA6C0", +"z- c #91BED8", +"A- c #93BFD9", +"B- c #8CB5D0", +"C- c #7DA4BE", +"D- c #6F92AE", +"E- c #6687A5", +"F- c #526C85", +"G- c #415669", +"H- c #384655", +"I- c #6589A4", +"J- c #6E92AE", +"K- c #80A8C2", +"L- c #92BCD6", +"M- c #91BFD8", +"N- c #799AAF", +"O- c #6A8796", +"P- c #81AAC3", +"Q- c #577187", +"R- c #1F2930", +"S- c #192027", +"T- c #1B2227", +"U- c #0D1010", +"V- c #0E1012", +"W- c #070709", +"X- c #5C6062", +"Y- c #DCE8F3", +"Z- c #C4DCEF", +"`- c #9BB3C6", +" ; c #3A424F", +".; c #313A44", +"+; c #35424C", +"@; c #374655", +"#; c #6E91AD", +"$; c #87B2CC", +"%; c #799EBA", +"&; c #618298", +"*; c #7095AF", +"=; c #435663", +"-; c #80A7C0", +";; c #95C4DC", +">; c #779CB3", +",; c #526D7E", +"'; c #516A7A", +"); c #526B7B", +"!; c #465764", +"~; c #34414E", +"{; c #5C7E9A", +"]; c #2B3741", +"^; c #4B657F", +"/; c #5C7D9C", +"(; c #557088", +"_; c #0F0F10", +":; c #B9C2CA", +"<; c #CCDFEF", +"[; c #B4CDE1", +"}; c #8DAEC8", +"|; c #6F93AE", +"1; c #678CA6", +"2; c #6E92AF", +"3; c #81A8C1", +"4; c #8FBBD5", +"5; c #8DB9D2", +"6; c #6D8FA2", +"7; c #586F82", +"8; c #394851", +"9; c #86B0C6", +"0; c #85AFC8", +"a; c #6F94AF", +"b; c #698DA8", +"c; c #6889A7", +"d; c #5E7E9F", +"e; c #475D75", +"f; c #2E3C4A", +"g; c #5D7E9D", +"h; c #405465", +"i; c #36393B", +"j; c #D7E5F1", +"k; c #A4C5DC", +"l; c #668496", +"m; c #7595AB", +"n; c #7798AE", +"o; c #97C2DA", +"p; c #789DB3", +"q; c #8BB1C8", +"r; c #93C0D9", +"s; c #8BB5CF", +"t; c #85AFC9", +"u; c #82AAC6", +"v; c #5F7C95", +"w; c #1E252C", +"x; c #54728E", +"y; c #587899", +"z; c #5A7B9B", +"A; c #2D3843", +"B; c #798086", +"C; c #D1E3F1", +"D; c #B7D3E8", +"E; c #7E98AB", +"F; c #181C1F", +"G; c #46525F", +"H; c #80A1B8", +"I; c #99C3DB", +"J; c #85ACC2", +"K; c #21272D", +"L; c #0A0B0D", +"M; c #53718C", +"N; c #577797", +"O; c #1B2229", +"P; c #0D0E0F", +"Q; c #B3BDC4", +"R; c #CADDED", +"S; c #B4D3E7", +"T; c #2B3339", +"U; c #2F3840", +"V; c #7899AC", +"W; c #93C1D9", +"X; c #8FBCD5", +"Y; c #8BB6D1", +"Z; c #8DB8D2", +"`; c #92BFD8", +" > c #678092", +".> c #547089", +"+> c #5C7F9B", +"@> c #1F262E", +"#> c #202223", +"$> c #B1BECB", +"%> c #C3D9EB", +"&> c #7B8D99", +"*> c #708B9A", +"=> c #85ABC1", +"-> c #7FA3BA", +";> c #92BBD3", +">> c #7CA0B4", +",> c #97BDD4", +"'> c #657E8F", +")> c #93BDD4", +"!> c #88ADC7", +"~> c #6F94AE", +"{> c #526A7E", +"]> c #65849B", +"^> c #799DBB", +"/> c #84AFC9", +"(> c #8FB9D2", +"_> c #323C45", +":> c #516C84", +"<> c #658AA4", +"[> c #5B7C9B", +"}> c #2E3A49", +"|> c #2A3038", +"1> c #252D3A", +"2> c #1B1E20", +"3> c #ADBFCF", +"4> c #C0D6E7", +"5> c #B0CDE2", +"6> c #8EB3C9", +"7> c #526975", +"8> c #6B899D", +"9> c #597183", +"0> c #90BAD5", +"a> c #94C2DA", +"b> c #82ABC5", +"c> c #495E6E", +"d> c #82A8C3", +"e> c #81A4BA", +"f> c #7594A5", +"g> c #87ABC3", +"h> c #4D6573", +"i> c #6689A6", +"j> c #526E85", +"k> c #243037", +"l> c #607B96", +"m> c #7699B6", +"n> c #789EB5", +"o> c #303D48", +"p> c #7498B4", +"q> c #7094AF", +"r> c #597792", +"s> c #242F39", +"t> c #1A1D25", +"u> c #374553", +"v> c #4D677D", +"w> c #14191E", +"x> c #040505", +"y> c #171A1D", +"z> c #8A9FAD", +"A> c #BCD9EC", +"B> c #B5D3E7", +"C> c #A2CAE1", +"D> c #9DC7DE", +"E> c #9EC7DD", +"F> c #3B4A57", +"G> c #455867", +"H> c #98C2DB", +"I> c #85B0CC", +"J> c #7496B2", +"K> c #4C606F", +"L> c #6E8EA3", +"M> c #7EA0B6", +"N> c #91BBD3", +"O> c #8DB7D1", +"P> c #90BAD4", +"Q> c #96C1DA", +"R> c #3B4853", +"S> c #688AA5", +"T> c #4C657A", +"U> c #1B2026", +"V> c #2B3C44", +"W> c #5F7A90", +"X> c #587284", +"Y> c #536978", +"Z> c #88B1CC", +"`> c #759AB8", +" , c #617E9A", +"., c #556F85", +"+, c #20272E", +"@, c #323D48", +"#, c #333E4A", +"$, c #060707", +"%, c #4A5159", +"&, c #ACC3D5", +"*, c #ACCFE5", +"=, c #5A6874", +"-, c #AACDE1", +";, c #9CC6DC", +">, c #35414C", +",, c #769AB2", +"', c #80AAC5", +"), c #6F92AB", +"!, c #38464F", +"~, c #7EA4B9", +"{, c #97C3DC", +"], c #7A9FB6", +"^, c #3F505C", +"/, c #6D8DA6", +"(, c #1E282E", +"_, c #080909", +":, c #090A0C", +"<, c #344452", +"[, c #3B4857", +"}, c #7799AE", +"|, c #8DB6D1", +"1, c #66869E", +"2, c #3D4957", +"3, c #536C84", +"4, c #353F4C", +"5, c #111215", +"6, c #65727E", +"7, c #A6BCCD", +"8, c #5D6972", +"9, c #AED0E6", +"0, c #99C5DC", +"a, c #8DB5D0", +"b, c #8DB5CE", +"c, c #90BBD5", +"d, c #84AAC5", +"e, c #8EBBD5", +"f, c #80A7C1", +"g, c #6C8DA2", +"h, c #85AFC6", +"i, c #61839B", +"j, c #374352", +"k, c #576D83", +"l, c #80A6C1", +"m, c #81A4BB", +"n, c #111315", +"o, c #111418", +"p, c #4C6378", +"q, c #33424C", +"r, c #37454D", +"s, c #8DB4CF", +"t, c #7397B3", +"u, c #3A495A", +"v, c #0D0F13", +"w, c #27303A", +"x, c #272E36", +"y, c #0F1012", +"z, c #90A4B2", +"A, c #A8CBE2", +"B, c #91BCD4", +"C, c #80ABC3", +"D, c #567083", +"E, c #67899D", +"F, c #94C2DB", +"G, c #95C1DB", +"H, c #779CB2", +"I, c #60849E", +"J, c #64849F", +"K, c #1A1F22", +"L, c #405061", +"M, c #79A1BD", +"N, c #324051", +"O, c #6183A1", +"P, c #6B8FAD", +"Q, c #6485A2", +"R, c #34444F", +"S, c #060606", +"T, c #2D3339", +"U, c #B2CBDF", +"V, c #94BCD5", +"W, c #7DA2BA", +"X, c #3F5264", +"Y, c #5A7991", +"Z, c #7195B3", +"`, c #7BA5BD", +" ' c #81AAC6", +".' c #88B2CC", +"+' c #8EBBD4", +"@' c #8AB2CC", +"#' c #82ADC7", +"$' c #7092A5", +"%' c #95C2DA", +"&' c #41525F", +"*' c #6387A3", +"=' c #475F72", +"-' c #21282F", +";' c #5B7288", +">' c #0D0F11", +",' c #0B0E11", +"'' c #212C36", +")' c #26323C", +"!' c #161B20", +"~' c #55616D", +"{' c #9BB9D0", +"]' c #799EB6", +"^' c #27313A", +"/' c #1A222B", +"(' c #5D7E99", +"_' c #6587A4", +":' c #6789A6", +"<' c #6B8EAB", +"[' c #628097", +"}' c #6D8B9D", +"|' c #769AAF", +"1' c #6E91A9", +"2' c #6C8EAD", +"3' c #6E91AF", +"4' c #3C4D59", +"5' c #8BB1CB", +"6' c #232D32", +"7' c #13171B", +"8' c #232B32", +"9' c #839AAF", +"0' c #789BB3", +"a' c #283138", +"b' c #0C0E0F", +"c' c #242B33", +"d' c #3D4D5B", +"e' c #435768", +"f' c #4B6176", +"g' c #283137", +"h' c #8DB4CC", +"i' c #41535E", +"j' c #405362", +"k' c #3C4F60", +"l' c #3C4E5B", +"m' c #2B353E", +"n' c #526876", +"o' c #92BAD3", +"p' c #1B1F23", +"q' c #31383F", +"r' c #7F9CB6", +"s' c #21292F", +"t' c #29333F", +"u' c #1F252E", +"v' c #090A0E", +"w' c #4D626E", +"x' c #96BDD3", +"y' c #191D20", +"z' c #13181B", +"A' c #80A4BC", +"B' c #1B2027", +"C' c #5D7182", +"D' c #2C383F", +"E' c #364857", +"F' c #1A2028", +"G' c #333F49", +"H' c #7FA2B5", +"I' c #4A5E6E", +"J' c #232E35", +"K' c #252D35", +"L' c #2F3A41", +"M' c #0A0B0E", +"N' c #14191D", +"O' c #5A717F", +"P' c #212931", +"Q' c #222B34", +"R' c #101216", +"S' c #21272B", +" ", +" ", +" ", +" . ", +" + ", +" @ # $ % ", +" & * = - ; ", +" > , ' ) ! ~ { ] ", +" ^ / ( _ : < [ } | 1 2 3 4 5 6 7 8 9 0 a ", +" b c d e f g h i j k l m n o p q r s t u v w x ", +" y z A B C D E F G H I J K L M N O P Q R S T U U V W X Y ", +" Z ` ...+.@.#.$.%.O &.*.=.-.;.>.,.'.).!.~.~.~.{.].^./.(._.:.<. ", +" b [.}.|.#.1.2.3.4.{.~.~.~.~.5.6.5.~.7.8.{.~.~.~.~.9.0.a.b.].c. ", +" d.e.f.g.h.i.j.k.{.~.~.~.~.l.~.m.% n.~.o.{.{.~.~.~.~.p.V 9.~.q.r. ", +" s.t.u.v.w.x.u y.z.A.B.5.~.~.5.C.D.E.F.~.~.G.~.~.~.G.H.I.J.~.~.J.K.L. M.N. ", +" O.P.Q.R.S.T.U.V.W.X.Y.Z.`.~.~.5. +.+++@+U ~.~.~.~.~.#+$+%+,.~.~.G.&+*+=+-+;+ ", +" >+,+Q.'+)+!+~+{+]+^+/+(+_+:+<+~.[+}+U 9.|+5.~.~.~.~.1+2+3+4+5+~.].6+7+8+9+0+ ", +" a+b+c+d+e+f+g+h+i+j+k+l+m+n+o+p+q+5.U ~.U r+s+~.~.~.t+u+v+w+x+y+~.z+A+t+B+C+D+E+ F+G+ ", +" H+I+J+K+L+M+N+O+P+Q+R+S+T+U+V+W+X+Y+V ~.~.~.~.U ~.~.~.o.9.{.Z+`+9.~.~.~.V @.@+@@@#@ $@%@&@*@ ", +" =@-@;@>@,@'@'.)@!@~@{@]@^@/@l+(@_@:@<@~.~.~.U {.~.~.~.{.~.~.{.[@~.~.~.~.}@|@1@2@3@4@5@6@7@8@ ", +" 9@0@a@b@c@d@-.e@f@g@h@i@j@k@l@V+m@n@o@p@~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.{.q@r@s@t@u@v@w@x@y@ ", +"z@A@B@C@D@E@X F@G@H@R I@J@K@L@M@N@O@P@Q@R@o+S@T@~.~.~.~.~.~.~.~.~.~.~.~.~.~.9.U@V@W@X@<+V Y@Z@`@ # ", +" .#+#@###$#%#&#*#=#-#;#>#,#'#)#!#~#{#]#^#S@/#~.~.~.~.~.~.~.~.~.~.~.~.~.U (#_#:#<#p@{.[#}#|#1#2# ", +" 3#4#5#6#7#8#9#0#a#b#c#d#e#f#g#h#i#j#k#S@/#~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.l#m#9.{.~.n#o#p#q#r#s# ", +" t#u#v#w#x#y#z#A#B#C#D#E#F#G#H#I#% J#K#S@T@~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.L#0.l.~.~.{.M#N#O#P#Q#R# ", +" S#T#U#V#W#X#Y#Z#`# $.$+$@$#$$$%$&$*$=$-$a#~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.o.o.;$9.G.~.>$,$'$)$!$~${$]$ ", +" ^$/$($_$:$<$[$}$|$1$2$3$4$5$6$7$8$9$:+<+~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.G.0$a$b$c$d$e$f$g$h$i$j$k$ ", +" [ l$m$n$o$p$q$r$s$t$u$v$w$x$y$z$A$B$C$M#p@~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.;$D$E$F$G$H$I$J$K$L$ ", +" M$N$O$P$Q$R$S$T$U$V$W$X$Y$Z$`$ %.%+%@%<+{.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.#%$%%%p@&%*%=%-%;%>%,% ", +" '%)%!%~%{%]%^%/%(%_%:%<%[%}%|%1%2%3%-$T@~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.4%5%U p@6%7%8%9%0%a%y ", +" b%c%d%e%f%g%h%i%G.[#j%k%l%m%n%o%p%@%q%{.~.~.~.~.~.~.~.~.~.~.~.~.~.~.{.~.~.~.~.~.~.V G.}@r%s%t%u%v%w%M.x%y%z%A% ", +" B%C%D%E%F%G%H%I%V o.<@J%K%L%M%N%O%P%p@~.~.~.~.~.~.~.~.~.U ~.~.U 9.Q%{.~.~.~.~.~.{.%%U {.~.~.{.v@R%S%T%U%V%W% X%$ ", +" Y%Z%`% &.&+&@&#&U ~.{.$&%&&&*&=&-&T@~.~.~.~.~.~.~.~.~.~.~.;&>&,&'&)&!&5+~.~.~.~.{.~&{&]&9.~.p@^&/&(&_&:& <&[&}&|& ", +" 1&2&3&4&5&6&7&8&9&l.~.{.V 0&a&b&c&~.~.~.~.~.~.~.5.d&e&f&g&h&i&j&k&l&m&n&~.~.G.~.~.~.o&p&q&r&s&t&u&v& w&x&y&z&A&B& ", +" C&2&D&E&F&G&G&H&I&J&U ~.~.U K&L&,.~.~.~.~.~.~.~.U M&N&O&P&Q&R&S&T&U&V&W&X&].{.~.~.{./#Y&Z&`& *.*+*@* (.#*$*%*&***=* ", +" -*;*>*,*'*)*!*~*{*]*^*~.5.{.5./*U ~.~.~.~.~.~.{.[#(*_*:*<*[*[*}*|*1*2*3*4*5*U ~.~.6*7*8*9*0*a*b*c*d*e*f*g*h*i*%*j*k*<%l* ", +" m*n*o*p*q*r*s*t*u*v*w*1+~.~.~.~.~.~.~.~.~.~.~.x*y*z*A*B*C*D*E*V U ~.G.~.:.F*G*l.{.R%X+H*I*J*K*L*M*N*O*P*Q*R*S*T*U*V*W*X* ", +" Y*Z*D&`* =.=+=@=#=$=%=&={.~.~.~.~.~.~.~.~.~.~.<+*===-=;=>=,='=)=[#p@!=~={=]=^=/=(=a#&%_=:=<=-#[=}=k$|=1=2=3=4=5=6=7=8=9= ", +" 0=a=b=c=d=e=f=g=h=i=j=k=l=5.~.~.~.~.~.~.~.~.~.V -$m=n===o=p=q=r=s=t=:+u=v=w=x=y=z=A=J.V U ~.V [#B=C=D=1=E=F= G=H=I= ", +" J=K=L=M=N=O=P=Q=R=S=T=U=V=5.U ~.~.~.~.~.~.~.~.~.{.x*W=X=Y=Z=`= -.-+-@-#-$-%-&-*-=---;->-9.x*)=,-'-)-c.!-~- {-]- ", +" ^-/-(-_-:-<-<-[-%.}-|-1-T@~.{.~.~.~.~.~.~.~.~.~.~.V 2-^&3-4-5-6-7-8-9-0-a-b-c-d-e-f-g-h-V@i-j-k-l-T=m-7@n- o-p- ", +" q-r-s-t-u-v-!+2*w-x-y-z-V ~.~.~.~.~.~.~.~.~.~.~.~.~.~./#A-B-C-D-E-F-G-H-I-J-K-L-<@M-W=N-O-P-Q-R-<&S-T-U-V- W- ", +" X-Y-Z-`- ;.;+;@;#;$;q+~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~./#v@W=N#%;&;*;=;-;s=-#;;>;,;';);!;~;{;];^;/;(;H+ ", +" _;:;<;[;};|;1;2;3;4;{.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.{.T@-#5;6;7;8;9;[#V <+0;a;b;c;E-d;e;f;|=g;h; ", +" i;j;V#k;F.l;m;n;o;~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.{.~.{.p@S@s=p;q;~.~.{.r;s;t;u;~$v;w;x;y;z;A; ", +" H+B;C;D;E;F;G;H;~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.{.U ~.~.V E*E*V ~.~.~.{.T@/#I;J;K;L;M;y;N;O; ", +" P;Q;R;S;T;U;~.{.~.~.~.~.~.~.~.~.l.U {.p@~.~.{.V ~.~.5+V;].~.~.~.~.{.{.p@W;X;Y;Z;`;/# >W..>+>N;@> ", +" #>$>%>&>*>G.~.~.~.~.~.~.~.~.{.`.=>V=->;>~.n##&>>T@,>'>].~.~.~.~.~.)>!>i$~>{>]>^>/>(>_>:><>[>}> |>1> ", +" 2>3>4>5>U@U ~.~.~.~.~.~.~.{.6>7>8>9>0>a#a>b>c>d>e>f>~.~.~.V ~.~.g>h>i>1=j>,%k>l>m>n>o>p>q>r>s>t>u>v>w> ", +" x>y>z>A>B>C>5+D>E>~.~.~.~.{.%&F>G>3;s%{.H>I>J>K>L>M>~.V N>O>P>x*Q>R>S>T>U> X%V>W>X>Y>Z>P-`> ,.,+, ", +" @,#,$,%,&,1.*,=,-,;,{.p@V {.X@>,,,Z;V ~.5.`;',),!,~,~.{,],^,/,/&-$F$(,_, :,<,[,},<@|,1,2, ", +" B&3,4, 5,6,7,8,9,0,`;a,b,B+c,d,s=<+~.~.~.a#e,f,g,h,V -#9$i,j,k,l,m,n, o,p,q,r,s,t,u,v, ", +" w,x, y,z,A,B,C,D,E,o@F,G,<+~.~.~.~.~.;;P>j%}@p@H,]#I,J,K,L,M,=+ N,O,P,Q,R,S, ", +" T,U,V,W,X,Y,Z,`, '.'+'x*~.{.O+@%@'#'$'%'a#&'*'='-' ~;;'>' ,''')'!' ", +" ~'{']'^'/'('_'_':'<'['}'{.V |'1'2'3'4'5'}@6'7' 8'K; ", +" v&9'0'a' b'c'd'e'f'1@g'h'G.i'j'k'l'm'n'o'p' y ", +" q'r's' t'u'H+ v'w'x'y' z'A'B' ", +" C'D' E'F' G'H' I'J' ", +" K'L' M' N'O' P'Q' ", +" R' S' ", +" ", +" ", +" ", +" "}; diff --git a/minilibx-linux/test/open24.xpm b/minilibx-linux/test/open24.xpm new file mode 100644 index 0000000..f363254 --- /dev/null +++ b/minilibx-linux/test/open24.xpm @@ -0,0 +1,230 @@ +/* XPM */ +static char *open[] = { +/* width height num_colors chars_per_pixel */ +" 45 55 168 2", +/* colors */ +".. s None c None", +".# c #450304", +".a c #ce7e7c", +".b c #b94344", +".c c #b65254", +".d c #780204", +".e c #b04c4c", +".f c #b00204", +".g c #8a8a64", +".h c #969a24", +".i c #b6b60c", +".j c #cac614", +".k c #cece34", +".l c #cace54", +".m c #caca94", +".n c #c24e4c", +".o c #aa0204", +".p c #9e4244", +".q c #bc0204", +".r c #a40204", +".s c #9e262c", +".t c #8c3a3c", +".u c #5c1414", +".v c #5b0204", +".w c #700204", +".x c #722214", +".y c #b52624", +".z c #8e3234", +".A c #b60204", +".B c #c20204", +".C c #860204", +".D c #560304", +".E c #800204", +".F c #9e0204", +".G c #920204", +".H c #620204", +".I c #a41314", +".J c #996a6c", +".K c #920d09", +".L c #c80204", +".M c #690204", +".N c #980204", +".O c #984c4c", +".P c #e2dedc", +".Q c #ae5e5c", +".R c #bc6a6c", +".S c #a21a1c", +".T c #8a0a04", +".U c #671e1c", +".V c #941b1c", +".W c #b8b4b4", +".X c #e8e6e4", +".Y c #ccb4b4", +".Z c #c07c7c", +".0 c #f3f2eb", +".1 c #b49696", +".2 c #521614", +".3 c #9e5a5c", +".4 c #d4d4d4", +".5 c #a7a5a1", +".6 c #dec4c4", +".7 c #e4d6d4", +".8 c #f4f2f4", +".9 c #cccac4", +"#. c #9a161c", +"## c #8c0204", +"#a c #862c2c", +"#b c #7e5e5c", +"#c c #a39694", +"#d c #6b6667", +"#e c #322624", +"#f c #b09e9c", +"#g c #b23234", +"#h c #500304", +"#i c #222224", +"#j c #2e322c", +"#k c #925c5c", +"#l c #721a1c", +"#m c #6e6e6c", +"#n c #0a0a0c", +"#o c #b2b2b4", +"#p c #8e6264", +"#q c #884444", +"#r c #8c5c5c", +"#s c #121214", +"#t c #b2aeac", +"#u c #c21e1c", +"#v c #6e0e0c", +"#w c #623e3c", +"#x c #b64e4c", +"#y c #bc3634", +"#z c #624e1c", +"#A c #6e727c", +"#B c #824e4c", +"#C c #8b8d87", +"#D c #a09674", +"#E c #766844", +"#F c #7a663c", +"#G c #828c90", +"#H c #beb6a4", +"#I c #3a0204", +"#J c #8e9298", +"#K c #562529", +"#L c #7c3838", +"#M c #bab294", +"#N c #7e4644", +"#O c #929a9c", +"#P c #762a2c", +"#Q c #a60e0c", +"#R c #ae1e1c", +"#S c #460a0c", +"#T c #a6aaa4", +"#U c #6a4a4c", +"#V c #784c50", +"#W c #761214", +"#X c #9e1e1c", +"#Y c #988c90", +"#Z c #821e1c", +"#0 c #7a1618", +"#1 c #7a6e74", +"#2 c #7e7a77", +"#3 c #808688", +"#4 c #828284", +"#5 c #828279", +"#6 c #827a64", +"#7 c #7e765c", +"#8 c #864a34", +"#9 c #825a44", +"a. c #766e54", +"a# c #7e7e74", +"aa c #806464", +"ab c #7e724c", +"ac c #766634", +"ad c #765a2c", +"ae c #8e7e54", +"af c #a69e8c", +"ag c #c7c2ac", +"ah c #9a2a1c", +"ai c #aa3a3c", +"aj c #979894", +"ak c #70684c", +"al c #62522c", +"am c #6e5e3c", +"an c #92866c", +"ao c #968e6c", +"ap c #826e54", +"aq c #84765c", +"ar c #86522c", +"as c #7e4624", +"at c #7e3614", +"au c #6e5254", +"av c #712e2c", +"aw c #7a5654", +"ax c #82727c", +"ay c #a63634", +"az c #8a6a6c", +"aA c #863534", +"aB c #5c1a18", +"aC c #6a2c2c", +"aD c #5e0e14", +"aE c #868684", +"aF c #922624", +"aG c #901614", +"aH c #c21614", +"aI c #520e0c", +"aJ c #805654", +"aK c #b00c0c", +"aL c #c2221c", +/* pixels */ +"..........................................................................................", +"..........................................................................................", +".....................................#.a.#................................................", +"...................................#.b.c.#.#.#.#...........#.d............................", +".................................#.e.f.f.#.g.h.i.j.k.l.m...f.n............................", +".................................d.f.o.f.#.#.#.d.d.#.#.#...f.f.d..........................", +".................................p.q.q.r.s.t.u.v.w.x.d.d.#.d.r.y.d........................", +".................................z.A.B.q.C.D.E.F.G.E.H.E.I.F.q.A.d........................", +".................................J.G.f.G.w.K.f.L.B.B.r.M.f.B.L.A.d........................", +".................................d.w.N.M.O.P.Q.B.B.o.R.S.E.q.q.T.d........................", +".................................d.U.M.V.W.X.Y.q.B.Z.0.1.E.r.N.d..........................", +".................................d.2.r.3.4.5.6.A.f.7.8.9#.###a.#..........................", +"................................#b.d.L#c#d#e#f.N.V.5#d.4#g.E.d............................", +"...............................d#h.r.L#f#i#j#k.M#l#m#n#o.b.r.d............................", +"...............................d#h##.q#g#p#q##.q.N#r#s#t#u.q#v.#..........................", +"..............#j................#w.w.C.r.q##.r.B.f.T#x#y.L.r.M.d..........................", +"............#j#z#j#A#A#j.........d.D.r.M.C.f.r.r.r.q.B.C.N.E#B............................", +"..........#j#C#D#E#z#F#G#j.......d.d.#.G##.w.M.M.C.C.d.G.r.u.d............................", +"....................#E#H#C#j.........d#I.w.F.f.o.o.o.N.M.#.d..............................", +"......................#E#j#J#j......#K.M.#.#.v.w.M.v.##h.H#L.d............................", +"..........................#M#j.......v.F.q.r.d.w.w.C.E.M.v.M#N.d..........................", +"..........................#E#O#j#j#K##.f.L.L.L.B.q.f##.M.v.w.w#P.d.#...d.d................", +"............................#C#E.#.v.o.B.L.L.q.q.q.q.N.M.D#h.M.N.r#Q#R#S.H.J.#............", +"............................#j#T#U.C.q.q.o.G.F.f.q.A.N.d.v.v##.o.q.L.r.C.A###k............", +"..............................#C#V.N.A.N.f.q.F.C.E.f.F.E.H#n#W.K.I#X#a.z.V.q.d#p.d........", +"................................#Y.r.K#Z.K.q.A.G.w#0#b#1#2#3#4#5#5#6#6#7#8.q.G#9..........", +"..................#j#oa..5#j..#J#Ja##4#4aa.o.A##.E.xabacadae#Daf#M#Magah.r.qai.#..........", +"................aja#akalamanaoapaqaaarasat.r.o.E.w.T.T.E.H.#...........#.d.d.#............", +"...........E....#j#j#C#M#j#n#naa#V.O.f.N.F.q.G.d.w.r.C.d.H.#...............#..............", +"...........#.F.F.J#n#n#n#n#n#nauav#p.q.N.d.d.w.M.F.F.E.d.U................................", +".........E.F.E.E.d.z#n.d#n#n#naw.Uax.r##.d.w.D.M.r.N.E.w.d................................", +".........E.F.......d.Fay.E.F#naz.2#A.D#h.r.f.w##.r##.d.H.M................................", +".........F.#...........E.E.F.baAaB#A.#.E.f.r.w.N.N.E.waC.#................................", +".........F.#...............d.F.E#K#d.H.G.F.G.w.N##.d.D.#..................................", +".........F.#....................#Aau.v.E##.w.E.E.w.H.d.......d..av.d......................", +".........E.#..................#j#GaC.M.H.M.d.d.w.H.#.d.d.#aC.w.C##.E.d....................", +"...........F.................5#O...#aD.w.d.w.H.D.M######.G.F.o.f.o.N.3....................", +"...........F.E...........5aEakak.....#.##h#h.v.N.o.f.q.L.L.L.L.L.q.faF....................", +"...........E.E......#E#C.5aq#j.....#.v.N.F.d.N.r.F.r.F#Q.I.o.q.L.L.L.y....................", +".............E.....................#.E.B.qaG.d.d.d.....#.#.....d#x.b......................", +".............E.F...................E.w.L.LaG.#............................................", +"...............E.E.................EaA.q.qaG.#............................................", +"...............E.F.E.................E.r.r#Z.#............................................", +".................E.F.E...............E.G.NaA..............................................", +".................E#uaH.................w.dav..............................................", +"...................E.E.............EaI.M.w.v.#............................................", +"...................................E.D.d.E.waJ............................................", +".....................................C.N.N##.M............................................", +"..................................#W.f.q.A.f.G#q..........................................", +".....................................q.L.L.L.q.V.#........................................", +"...................................#.daK.q.qaL.d..........................................", +".......................................#.#.#..............................................", +"..........................................................................................", +"..........................................................................................", +".........................................................................................." +}; diff --git a/minilibx-linux/test/open30.xpm b/minilibx-linux/test/open30.xpm new file mode 100644 index 0000000..87be371 --- /dev/null +++ b/minilibx-linux/test/open30.xpm @@ -0,0 +1,1439 @@ +/* XPM */ +static char * open30_2_xpm[] = { +"64 64 1372 2", +" c None", +". c #08090D", +"+ c #1A1E23", +"@ c #1F2124", +"# c #060809", +"$ c #1A1E21", +"% c #4F606C", +"& c #3D4145", +"* c #868D93", +"= c #454E56", +"- c #627481", +"; c #667C8A", +"> c #2D3031", +", c #D7E1E7", +"' c #4D5157", +") c #8997A5", +"! c #282E31", +"~ c #333B41", +"{ c #A5C6DB", +"] c #718C9B", +"^ c #000000", +"/ c #181B1F", +"( c #262828", +"_ c #D2DEE7", +": c #B8C5D0", +"< c #151719", +"[ c #08090B", +"} c #272B30", +"| c #2D3037", +"1 c #26282C", +"2 c #1A1D1F", +"3 c #B1CADB", +"4 c #56646E", +"5 c #080809", +"6 c #080A0C", +"7 c #1E2126", +"8 c #98B7C9", +"9 c #A2CAE2", +"0 c #7FA1B5", +"a c #06080A", +"b c #252729", +"c c #A7ADB2", +"d c #272B2E", +"e c #1E2023", +"f c #C8D8E5", +"g c #C9DDED", +"h c #8996A3", +"i c #6B7782", +"j c #C7DFF0", +"k c #CCE0F0", +"l c #AFC1CF", +"m c #47535B", +"n c #B0D3E8", +"o c #7E99A9", +"p c #738493", +"q c #97B4C7", +"r c #53606A", +"s c #6E8996", +"t c #A1CBE3", +"u c #9CC6DE", +"v c #90B5CB", +"w c #171D22", +"x c #1E2629", +"y c #020202", +"z c #ABB3BA", +"A c #BBC4C8", +"B c #222323", +"C c #141617", +"D c #5D6164", +"E c #ACB5BC", +"F c #676D74", +"G c #BDD4E5", +"H c #B3D1E7", +"I c #B0D1E7", +"J c #728A99", +"K c #94AEBF", +"L c #B1D1E7", +"M c #505C64", +"N c #7B98A9", +"O c #A1CBE0", +"P c #99C3D9", +"Q c #475863", +"R c #A0C9DE", +"S c #9CC6DA", +"T c #9ECAE1", +"U c #9CC5DD", +"V c #9AC4DC", +"W c #263137", +"X c #3C4A55", +"Y c #658190", +"Z c #66686B", +"` c #7D8085", +" . c #363839", +".. c #797E81", +"+. c #D2DBE1", +"@. c #DDE9F4", +"#. c #CADEEF", +"$. c #778593", +"%. c #AED0E5", +"&. c #9EC9DE", +"*. c #9EC8DF", +"=. c #9BC1D8", +"-. c #9EC8DE", +";. c #6B8596", +">. c #9BC5DC", +",. c #9BC6DF", +"'. c #9CC5DC", +"). c #688595", +"!. c #6B8698", +"~. c #9CC4DC", +"{. c #9BC4DC", +"]. c #9DC5DD", +"^. c #647D8C", +"/. c #485864", +"(. c #161A1D", +"_. c #36444C", +":. c #95BDD5", +"<. c #566E7E", +"[. c #A4AAAD", +"}. c #E9F2F7", +"|. c #DEEAF6", +"1. c #B5D4E9", +"2. c #A9CFE3", +"3. c #90B3C9", +"4. c #9FCAE1", +"5. c #9BC4DD", +"6. c #7490A2", +"7. c #99C2DB", +"8. c #81A5BA", +"9. c #9CC5DE", +"0. c #98C1DA", +"a. c #5F7889", +"b. c #96BFD8", +"c. c #44545F", +"d. c #565A5E", +"e. c #DFE6EC", +"f. c #E6EEF7", +"g. c #D6E4F2", +"h. c #BFD6E9", +"i. c #A9CCE3", +"j. c #9FC8DD", +"k. c #9DC6DD", +"l. c #9CC4DD", +"m. c #7D9FB0", +"n. c #98C0D6", +"o. c #9AC5DD", +"p. c #97BFD8", +"q. c #9BC5DF", +"r. c #2D3840", +"s. c #626567", +"t. c #E7ECF5", +"u. c #E1EAF5", +"v. c #CEE3F3", +"w. c #B7D6EA", +"x. c #A4CBE0", +"y. c #8AAFC5", +"z. c #647F90", +"A. c #648092", +"B. c #89B0C7", +"C. c #9CC6DF", +"D. c #5D7486", +"E. c #7B9BAF", +"F. c #84A8BF", +"G. c #9BC5DD", +"H. c #96BED5", +"I. c #4B5D69", +"J. c #9BC5DE", +"K. c #536B77", +"L. c #2E3B41", +"M. c #1B2124", +"N. c #3F4F58", +"O. c #4D5152", +"P. c #E7EEF3", +"Q. c #E2EAF5", +"R. c #CEE2F2", +"S. c #BAD5E9", +"T. c #9DC2D7", +"U. c #5C7281", +"V. c #232A31", +"W. c #08090A", +"X. c #121418", +"Y. c #131619", +"Z. c #131719", +"`. c #87ACC3", +" + c #7B9BAE", +".+ c #87ADC3", +"++ c #8FB5CB", +"@+ c #678295", +"#+ c #96C0D8", +"$+ c #607787", +"%+ c #6B8595", +"&+ c #96C1DB", +"*+ c #6A8595", +"=+ c #35424A", +"-+ c #7090A1", +";+ c #15191C", +">+ c #2D3033", +",+ c #DDE5EB", +"'+ c #D2E3F1", +")+ c #BAD7EB", +"!+ c #A9CFE5", +"~+ c #272F35", +"{+ c #1C2227", +"]+ c #4F697B", +"^+ c #6B8FA9", +"/+ c #759CB6", +"(+ c #7BA0BB", +"_+ c #80A5BC", +":+ c #88B0C8", +"<+ c #96C3DB", +"[+ c #8FB6CD", +"}+ c #80A1B3", +"|+ c #556876", +"1+ c #96BFD7", +"2+ c #566B77", +"3+ c #93B8CD", +"4+ c #637A8D", +"5+ c #9DC6DE", +"6+ c #8FB4CA", +"7+ c #55697A", +"8+ c #6F8F9F", +"9+ c #91BDD5", +"0+ c #283239", +"a+ c #050406", +"b+ c #767B80", +"c+ c #BDC6CE", +"d+ c #D4E5F3", +"e+ c #C1D7EA", +"f+ c #A7CDE4", +"g+ c #9FC9DE", +"h+ c #668596", +"i+ c #6D90AA", +"j+ c #5C7994", +"k+ c #60849F", +"l+ c #6286A1", +"m+ c #688CA8", +"n+ c #7298B2", +"o+ c #82A8C2", +"p+ c #8FBAD5", +"q+ c #96C2DB", +"r+ c #89ADC4", +"s+ c #96BED6", +"t+ c #99C2DA", +"u+ c #6C899A", +"v+ c #92BBD2", +"w+ c #9AC4DD", +"x+ c #5B717D", +"y+ c #9EC6DE", +"z+ c #8BB1C9", +"A+ c #718EA0", +"B+ c #94C3DB", +"C+ c #536B78", +"D+ c #3E505F", +"E+ c #4E6373", +"F+ c #2C333C", +"G+ c #070708", +"H+ c #040404", +"I+ c #1A1C1E", +"J+ c #202326", +"K+ c #050606", +"L+ c #23292E", +"M+ c #A1C0D4", +"N+ c #9FC9DD", +"O+ c #97C2DB", +"P+ c #80A8C1", +"Q+ c #668AA6", +"R+ c #4B5D72", +"S+ c #4C647A", +"T+ c #5F80A0", +"U+ c #60859E", +"V+ c #678AA6", +"W+ c #739BB5", +"X+ c #85AEC7", +"Y+ c #92BDD7", +"Z+ c #96BFD5", +"`+ c #627B8A", +" @ c #89B1C9", +".@ c #2B353C", +"+@ c #7597B2", +"@@ c #779CB8", +"#@ c #52697C", +"$@ c #1D2328", +"%@ c #445663", +"&@ c #5E7A8D", +"*@ c #252F37", +"=@ c #090909", +"-@ c #859BB2", +";@ c #859DB8", +">@ c #6E8396", +",@ c #252C33", +"'@ c #9CC4D7", +")@ c #92C0D9", +"!@ c #79A0BA", +"~@ c #6487A3", +"{@ c #566979", +"]@ c #8CB0C2", +"^@ c #51697C", +"/@ c #60849D", +"(@ c #6D8EAC", +"_@ c #7BA0BC", +":@ c #8AB4CE", +"<@ c #95C2DB", +"[@ c #9AC5DC", +"}@ c #95C1DA", +"|@ c #607B8C", +"1@ c #597488", +"2@ c #7EA6BF", +"3@ c #597587", +"4@ c #455664", +"5@ c #668598", +"6@ c #82A9C4", +"7@ c #617F92", +"8@ c #1A2328", +"9@ c #2B3137", +"0@ c #728FAC", +"a@ c #51657B", +"b@ c #6B8AA8", +"c@ c #8EAEC7", +"d@ c #A8C8E2", +"e@ c #92BDD6", +"f@ c #769DBA", +"g@ c #526E87", +"h@ c #7490A0", +"i@ c #A6CDE4", +"j@ c #97BFD4", +"k@ c #55697D", +"l@ c #6286A0", +"m@ c #7399B3", +"n@ c #84ACC5", +"o@ c #92BFD9", +"p@ c #99C4DC", +"q@ c #94C0DA", +"r@ c #4F6575", +"s@ c #7DA5BF", +"t@ c #7FA2BC", +"u@ c #8FB6CE", +"v@ c #95C3DB", +"w@ c #8EB8D2", +"x@ c #6A879D", +"y@ c #111318", +"z@ c #252A30", +"A@ c #81868C", +"B@ c #A5ABAD", +"C@ c #70767C", +"D@ c #38434F", +"E@ c #637F9B", +"F@ c #516980", +"G@ c #799AB5", +"H@ c #A5C3D9", +"I@ c #93BDD6", +"J@ c #779EBA", +"K@ c #445A6B", +"L@ c #93B5C9", +"M@ c #B6D3E8", +"N@ c #AECFE4", +"O@ c #95BDD2", +"P@ c #52687A", +"Q@ c #6486A3", +"R@ c #7092B0", +"S@ c #90BCD6", +"T@ c #97C4DC", +"U@ c #A0C9E0", +"V@ c #99C5DD", +"W@ c #86AEC6", +"X@ c #8FBAD4", +"Y@ c #91BDD6", +"Z@ c #7094AC", +"`@ c #2A353E", +" # c #0B0E10", +".# c #888D90", +"+# c #787D82", +"@# c #465360", +"## c #56697F", +"$# c #A6CADD", +"%# c #5A7382", +"&# c #6C8CAA", +"*# c #A5BED3", +"=# c #A7CAE0", +"-# c #94C1DA", +";# c #7EA4BF", +"># c #415160", +",# c #9DC3D5", +"'# c #B3CFE1", +")# c #AAC3D4", +"!# c #A8CDE4", +"~# c #89ACBE", +"{# c #567088", +"]# c #6C91AC", +"^# c #81A7C2", +"/# c #96C4DC", +"(# c #85A9BD", +"_# c #708C9B", +":# c #5A6E7B", +"<# c #6C8695", +"[# c #97C3DB", +"}# c #8BB5CE", +"|# c #425461", +"1# c #63819E", +"2# c #415465", +"3# c #0B0D0E", +"4# c #607387", +"5# c #687D8C", +"6# c #B8D6E9", +"7# c #7893A2", +"8# c #576F85", +"9# c #A7BACF", +"0# c #B0CEE5", +"a# c #98C4DC", +"b# c #88B1CA", +"c# c #36444E", +"d# c #8FA0AD", +"e# c #73818D", +"f# c #596D81", +"g# c #B4D0E4", +"h# c #A3CDE2", +"i# c #658296", +"j# c #6A8DAB", +"k# c #7BA5C0", +"l# c #94BAD2", +"m# c #6D899B", +"n# c #99C3DC", +"o# c #8EB9D2", +"p# c #7AA0BA", +"q# c #6C8FAB", +"r# c #6484A1", +"s# c #1F252C", +"t# c #121619", +"u# c #7E96B0", +"v# c #7A8A96", +"w# c #BCD7EA", +"x# c #A0C5D9", +"y# c #3C4B57", +"z# c #A9BACD", +"A# c #BCD5E8", +"B# c #84A6BA", +"C# c #8EA1AE", +"D# c #CFD1D4", +"E# c #ECF6FA", +"F# c #ABB7C2", +"G# c #556F84", +"H# c #57626A", +"I# c #5C7078", +"J# c #6C8AA7", +"K# c #80A6C0", +"L# c #91B8D0", +"M# c #94BFD8", +"N# c #87B0CA", +"O# c #7CA2BB", +"P# c #7097AF", +"Q# c #495E6F", +"R# c #0C0E11", +"S# c #3A3F43", +"T# c #8AA3BB", +"U# c #778592", +"V# c #C0D8EB", +"W# c #B3D5E9", +"X# c #404A53", +"Y# c #B2C2D3", +"Z# c #96A1AC", +"`# c #9DB2C3", +" $ c #AEBECE", +".$ c #EDEFF3", +"+$ c #F7FAFC", +"@$ c #B6BFC7", +"#$ c #556E85", +"$$ c #121314", +"%$ c #2B2E2F", +"&$ c #555A5E", +"*$ c #3B4C5B", +"=$ c #6F8EA4", +"-$ c #92BED8", +";$ c #9DC7DF", +">$ c #87ACC1", +",$ c #546A78", +"'$ c #516874", +")$ c #4E6570", +"!$ c #4D6271", +"~$ c #4C6271", +"{$ c #4E677A", +"]$ c #38454E", +"^$ c #6C7278", +"/$ c #86A1B6", +"($ c #5C656C", +"_$ c #A4B0BA", +":$ c #555D64", +"<$ c #657178", +"[$ c #A6B0B5", +"}$ c #939CA1", +"|$ c #D4E4F1", +"1$ c #A0BACE", +"2$ c #B9C7D7", +"3$ c #F6F7F9", +"4$ c #C6CED1", +"5$ c #506A7C", +"6$ c #060607", +"7$ c #676A6B", +"8$ c #91999F", +"9$ c #7CA3BE", +"0$ c #96BCD4", +"a$ c #5B717E", +"b$ c #4B5F6C", +"c$ c #455864", +"d$ c #5B717F", +"e$ c #81A5B9", +"f$ c #98C4DD", +"g$ c #93BFD8", +"h$ c #87B1CA", +"i$ c #7BA1BC", +"j$ c #5A7489", +"k$ c #222A33", +"l$ c #838A92", +"m$ c #9DADBC", +"n$ c #ECF0F5", +"o$ c #F1F9FB", +"p$ c #818A8D", +"q$ c #4A5155", +"r$ c #6A6F72", +"s$ c #7E898F", +"t$ c #E6F1F7", +"u$ c #CADCED", +"v$ c #A0B7CC", +"w$ c #C6D1DF", +"x$ c #AFB3B4", +"y$ c #5F707D", +"z$ c #CBCFD1", +"A$ c #F4F5F6", +"B$ c #66737F", +"C$ c #87B2CB", +"D$ c #90B7CD", +"E$ c #596E7B", +"F$ c #586F7E", +"G$ c #8BB0C8", +"H$ c #91BED6", +"I$ c #83ADC7", +"J$ c #6D8EA7", +"K$ c #3F5161", +"L$ c #2D3A45", +"M$ c #1F2020", +"N$ c #BDC5CC", +"O$ c #E0EDF5", +"P$ c #BBCAD8", +"Q$ c #E1E4E7", +"R$ c #5E6368", +"S$ c #5B5F62", +"T$ c #D9E7F3", +"U$ c #A4C3D6", +"V$ c #89A3B3", +"W$ c #7B91A1", +"X$ c #627990", +"Y$ c #42505A", +"Z$ c #CACCCE", +"`$ c #F9F9F9", +" % c #FDFDFD", +".% c #BCBEC0", +"+% c #5C7689", +"@% c #8DB9D3", +"#% c #8FB5CC", +"$% c #536471", +"%% c #98C1D9", +"&% c #91BED7", +"*% c #81AAC5", +"=% c #597386", +"-% c #41535F", +";% c #6486A2", +">% c #4D667D", +",% c #070809", +"'% c #44484E", +")% c #BEC8D0", +"!% c #8096A6", +"~% c #516473", +"{% c #A9ACAF", +"]% c #8B8F91", +"^% c #A8B3BD", +"/% c #C5DAEB", +"(% c #9FC8E1", +"_% c #8FBCD6", +":% c #81A8C2", +"<% c #6C90AC", +"[% c #56728C", +"}% c #585B5F", +"|% c #CBCDCD", +"1% c #C1C3C6", +"2% c #4F565F", +"3% c #82ABC3", +"4% c #93BCD3", +"5% c #95BED7", +"6% c #8EB9D3", +"7% c #5B788B", +"8% c #627E91", +"9% c #7FA7C1", +"0% c #6C91AB", +"a% c #546F87", +"b% c #6F7376", +"c% c #D5E2EF", +"d% c #A9C4D8", +"e% c #81A1BA", +"f% c #333940", +"g% c #5F6B76", +"h% c #C0D5E8", +"i% c #AACCE2", +"j% c #8EB8D3", +"k% c #7FA5BF", +"l% c #7095B0", +"m% c #4E697E", +"n% c #07090A", +"o% c #0D0F10", +"p% c #7193A6", +"q% c #96C3DC", +"r% c #8EBCD7", +"s% c #91BDD7", +"t% c #8FBBD6", +"u% c #7699AD", +"v% c #4D626F", +"w% c #252D33", +"x% c #101215", +"y% c #0C0D0E", +"z% c #0A0C0E", +"A% c #06090A", +"B% c #7F8488", +"C% c #D7E3F1", +"D% c #B6D0E4", +"E% c #A3C2D7", +"F% c #596872", +"G% c #A9BED0", +"H% c #B4D0E5", +"I% c #9EC8DC", +"J% c #8FB9D4", +"K% c #85ADC7", +"L% c #7FA4BE", +"M% c #4B606F", +"N% c #4E6372", +"O% c #89B6D0", +"P% c #92C1DA", +"Q% c #9DC7DD", +"R% c #95C0DA", +"S% c #94BED8", +"T% c #8BB8D1", +"U% c #7AA0B9", +"V% c #4E667A", +"W% c #344151", +"X% c #0C0D0F", +"Y% c #8A8F92", +"Z% c #D4E6F5", +"`% c #BCD5E9", +" & c #8599A5", +".& c #939DA6", +"+& c #C4DAEB", +"@& c #89A6B9", +"#& c #7D9FB5", +"$& c #98C3DC", +"%& c #95C0D9", +"&& c #7CA2B9", +"*& c #7697AE", +"=& c #698498", +"-& c #7394A8", +";& c #9EC7DF", +">& c #8DB1C4", +",& c #6B8594", +"'& c #50636C", +")& c #50626C", +"!& c #7F9FB1", +"~& c #93B8D0", +"{& c #627A88", +"]& c #90B6CC", +"^& c #93BDD7", +"/& c #87AFC9", +"(& c #7291A7", +"_& c #384651", +":& c #121618", +"<& c #12171B", +"[& c #4F6986", +"}& c #597998", +"|& c #324052", +"1& c #969CA1", +"2& c #D6E6F5", +"3& c #C6DCEE", +"4& c #505A64", +"5& c #82929F", +"6& c #99ABBB", +"7& c #A1B9CA", +"8& c #87A0B0", +"9& c #718EA1", +"0& c #8DB2C9", +"a& c #8BAEC4", +"b& c #586D7D", +"c& c #97C0D9", +"d& c #8DB3C9", +"e& c #95B8CD", +"f& c #9DC0D6", +"g& c #6F8B9C", +"h& c #354249", +"i& c #464E54", +"j& c #8A98A5", +"k& c #AABAC7", +"l& c #86939E", +"m& c #41494F", +"n& c #4A5861", +"o& c #97C1DA", +"p& c #5E7888", +"q& c #5C7482", +"r& c #88ACC2", +"s& c #91BFD7", +"t& c #799CB5", +"u& c #47596A", +"v& c #0D0F12", +"w& c #1A2127", +"x& c #56778D", +"y& c #688BA9", +"z& c #5D7F9E", +"A& c #547391", +"B& c #0E1013", +"C& c #9DA6AB", +"D& c #C8DCED", +"E& c #7A8996", +"F& c #B5CEE0", +"G& c #BCDBEC", +"H& c #B9D5EA", +"I& c #8BA2B2", +"J& c #6C8A9D", +"K& c #97BFD7", +"L& c #3E4E59", +"M& c #92B5CB", +"N& c #535F68", +"O& c #454F56", +"P& c #6F7C87", +"Q& c #ABC0D1", +"R& c #C7DCEE", +"S& c #C5DBED", +"T& c #C2D7EA", +"U& c #BFD8EA", +"V& c #BCD7EB", +"W& c #62717B", +"X& c #5B6F7B", +"Y& c #95C3DC", +"Z& c #8BB2C9", +"`& c #485761", +" * c #42525F", +".* c #6686A1", +"+* c #587896", +"@* c #1B2129", +"#* c #5C7A94", +"$* c #7DA2BD", +"%* c #84AEC7", +"&* c #749BB5", +"** c #5C7E9C", +"=* c #27343F", +"-* c #A4A9B2", +";* c #D9E7F4", +">* c #C8DBEC", +",* c #B1C8DA", +"'* c #5D6C76", +")* c #A8C5D8", +"!* c #A6BDD0", +"~* c #B9D6EA", +"{* c #B9D4E9", +"]* c #8198A8", +"^* c #8AADC3", +"/* c #8CB1CA", +"(* c #96C2D8", +"_* c #A3C7DF", +":* c #ADCDE3", +"<* c #ABD0E4", +"[* c #ADCFE3", +"}* c #AACEE4", +"|* c #A4CDE3", +"1* c #A1CBE1", +"2* c #A3CCE3", +"3* c #A2C9DF", +"4* c #41515A", +"5* c #81A2B5", +"6* c #94C0D7", +"7* c #5E7789", +"8* c #526777", +"9* c #516777", +"0* c #6B8CA5", +"a* c #759CBA", +"b* c #658AA5", +"c* c #587798", +"d* c #1B242B", +"e* c #0E1110", +"f* c #101214", +"g* c #202931", +"h* c #59758E", +"i* c #799FBB", +"j* c #84B1CA", +"k* c #86ACC6", +"l* c #354758", +"m* c #A0A6AE", +"n* c #DAE6F2", +"o* c #C4DCEE", +"p* c #B4D2E8", +"q* c #3E4A53", +"r* c #698091", +"s* c #5D7581", +"t* c #A3CAE0", +"u* c #A6CFE5", +"v* c #A5CCE5", +"w* c #718A9C", +"x* c #98C3DB", +"y* c #83ABC7", +"z* c #2E3B46", +"A* c #33414A", +"B* c #678398", +"C* c #8AB3CE", +"D* c #93BED7", +"E* c #97C4DB", +"F* c #42525E", +"G* c #88ACC0", +"H* c #789EB9", +"I* c #7A9FBB", +"J* c #7EA2BD", +"K* c #779DB5", +"L* c #577081", +"M* c #5B7B9B", +"N* c #1D2229", +"O* c #547390", +"P* c #54728D", +"Q* c #6082A0", +"R* c #688EA9", +"S* c #6689A7", +"T* c #6086A0", +"U* c #6285A1", +"V* c #6B8DAA", +"W* c #718FAB", +"X* c #3E5568", +"Y* c #969DA1", +"Z* c #DBE8F4", +"`* c #95ACBD", +" = c #758B9A", +".= c #A4C9DE", +"+= c #698190", +"@= c #667E8A", +"#= c #7D99AA", +"$= c #7B9BAD", +"%= c #6F8C9A", +"&= c #536976", +"*= c #84ADC6", +"== c #6D92AD", +"-= c #62829E", +";= c #43576A", +">= c #2F3B46", +",= c #5C788A", +"'= c #86AFC8", +")= c #93BED8", +"!= c #93BAD5", +"~= c #93BAD2", +"{= c #92BCD4", +"]= c #7EA2B6", +"^= c #3D4D56", +"/= c #485B67", +"(= c #7596A9", +"_= c #8CBBD4", +":= c #90BCD5", +"<= c #91BFD9", +"[= c #789BAD", +"}= c #465B6A", +"|= c #59789A", +"1= c #5D7F9D", +"2= c #5E839C", +"3= c #59799A", +"4= c #415569", +"5= c #2D3A46", +"6= c #2E3B49", +"7= c #4A647C", +"8= c #587690", +"9= c #39485A", +"0= c #7F8589", +"a= c #D9E8F5", +"b= c #CCDEEE", +"c= c #8597A5", +"d= c #B3D2E3", +"e= c #9BB3C4", +"f= c #B2CEE1", +"g= c #B2D1E7", +"h= c #ABCFE6", +"i= c #94B7CB", +"j= c #495C6A", +"k= c #688498", +"l= c #617B8A", +"m= c #85ADC8", +"n= c #78A0B9", +"o= c #62819B", +"p= c #2E3843", +"q= c #485A6C", +"r= c #67889C", +"s= c #8AB5CF", +"t= c #8EB9D1", +"u= c #6C899B", +"v= c #6E91A7", +"w= c #678399", +"x= c #6888A1", +"y= c #323E48", +"z= c #5B7585", +"A= c #98C5DD", +"B= c #83ACC1", +"C= c #2D373F", +"D= c #4B637C", +"E= c #567694", +"F= c #26313C", +"G= c #15191F", +"H= c #4D647A", +"I= c #252F39", +"J= c #5D6163", +"K= c #DDE9F5", +"L= c #CEDFEE", +"M= c #8898A5", +"N= c #B0CBDC", +"O= c #BFDAEC", +"P= c #BFDBEC", +"Q= c #BBDAEC", +"R= c #BAD7EA", +"S= c #6B808F", +"T= c #7297B0", +"U= c #8CB8D1", +"V= c #95C1D9", +"W= c #91BCD6", +"X= c #86AEC8", +"Y= c #7496B3", +"Z= c #6587A2", +"`= c #384958", +" - c #323F4B", +".- c #546A7C", +"+- c #6C88A1", +"@- c #779AB1", +"#- c #658297", +"$- c #3B4A58", +"%- c #33404B", +"&- c #202830", +"*- c #577287", +"=- c #86B1CC", +"-- c #86ACC0", +";- c #6E8797", +">- c #9CC7DF", +",- c #92BCD5", +"'- c #91BCD5", +")- c #8EB6CE", +"!- c #344453", +"~- c #263039", +"{- c #364452", +"]- c #2B3643", +"^- c #2A2D2E", +"/- c #E1EBF4", +"(- c #D2E4F3", +"_- c #A0B2C3", +":- c #8094A1", +"<- c #BAD8EB", +"[- c #B8D6EA", +"}- c #485A6A", +"|- c #789FB9", +"1- c #90BBD3", +"2- c #94C4DC", +"3- c #88B3CD", +"4- c #7A9EB9", +"5- c #698BA8", +"6- c #4D677C", +"7- c #151A1E", +"8- c #1A2125", +"9- c #171C21", +"0- c #1D2329", +"a- c #1D262E", +"b- c #486073", +"c- c #6A8CAA", +"d- c #7CA2BE", +"e- c #90BDD7", +"f- c #9AC5DE", +"g- c #7493A2", +"h- c #708B99", +"i- c #8CB7D1", +"j- c #7494AB", +"k- c #68889F", +"l- c #6A8FA5", +"m- c #7BA2BC", +"n- c #171D21", +"o- c #1D262F", +"p- c #212B36", +"q- c #09090B", +"r- c #BBC2C9", +"s- c #D4E4F2", +"t- c #C1D9EB", +"u- c #44515A", +"v- c #92B5C9", +"w- c #6B8795", +"x- c #4E687E", +"y- c #7EA6C0", +"z- c #91BED8", +"A- c #93BFD9", +"B- c #8CB5D0", +"C- c #7DA4BE", +"D- c #6F92AE", +"E- c #6687A5", +"F- c #526C85", +"G- c #415669", +"H- c #384655", +"I- c #6589A4", +"J- c #6E92AE", +"K- c #80A8C2", +"L- c #92BCD6", +"M- c #91BFD8", +"N- c #799AAF", +"O- c #6A8796", +"P- c #81AAC3", +"Q- c #577187", +"R- c #1F2930", +"S- c #192027", +"T- c #1B2227", +"U- c #0D1010", +"V- c #0E1012", +"W- c #070709", +"X- c #5C6062", +"Y- c #DCE8F3", +"Z- c #C4DCEF", +"`- c #9BB3C6", +" ; c #3A424F", +".; c #313A44", +"+; c #35424C", +"@; c #374655", +"#; c #6E91AD", +"$; c #87B2CC", +"%; c #799EBA", +"&; c #618298", +"*; c #7095AF", +"=; c #435663", +"-; c #80A7C0", +";; c #95C4DC", +">; c #779CB3", +",; c #526D7E", +"'; c #516A7A", +"); c #526B7B", +"!; c #465764", +"~; c #34414E", +"{; c #5C7E9A", +"]; c #2B3741", +"^; c #4B657F", +"/; c #5C7D9C", +"(; c #557088", +"_; c #0F0F10", +":; c #B9C2CA", +"<; c #CCDFEF", +"[; c #B4CDE1", +"}; c #8DAEC8", +"|; c #6F93AE", +"1; c #678CA6", +"2; c #6E92AF", +"3; c #81A8C1", +"4; c #8FBBD5", +"5; c #8DB9D2", +"6; c #6D8FA2", +"7; c #586F82", +"8; c #394851", +"9; c #86B0C6", +"0; c #85AFC8", +"a; c #6F94AF", +"b; c #698DA8", +"c; c #6889A7", +"d; c #5E7E9F", +"e; c #475D75", +"f; c #2E3C4A", +"g; c #5D7E9D", +"h; c #405465", +"i; c #36393B", +"j; c #D7E5F1", +"k; c #A4C5DC", +"l; c #668496", +"m; c #7595AB", +"n; c #7798AE", +"o; c #97C2DA", +"p; c #789DB3", +"q; c #8BB1C8", +"r; c #93C0D9", +"s; c #8BB5CF", +"t; c #85AFC9", +"u; c #82AAC6", +"v; c #5F7C95", +"w; c #1E252C", +"x; c #54728E", +"y; c #587899", +"z; c #5A7B9B", +"A; c #2D3843", +"B; c #798086", +"C; c #D1E3F1", +"D; c #B7D3E8", +"E; c #7E98AB", +"F; c #181C1F", +"G; c #46525F", +"H; c #80A1B8", +"I; c #99C3DB", +"J; c #85ACC2", +"K; c #21272D", +"L; c #0A0B0D", +"M; c #53718C", +"N; c #577797", +"O; c #1B2229", +"P; c #0D0E0F", +"Q; c #B3BDC4", +"R; c #CADDED", +"S; c #B4D3E7", +"T; c #2B3339", +"U; c #2F3840", +"V; c #7899AC", +"W; c #93C1D9", +"X; c #8FBCD5", +"Y; c #8BB6D1", +"Z; c #8DB8D2", +"`; c #92BFD8", +" > c #678092", +".> c #547089", +"+> c #5C7F9B", +"@> c #1F262E", +"#> c #202223", +"$> c #B1BECB", +"%> c #C3D9EB", +"&> c #7B8D99", +"*> c #708B9A", +"=> c #85ABC1", +"-> c #7FA3BA", +";> c #92BBD3", +">> c #7CA0B4", +",> c #97BDD4", +"'> c #657E8F", +")> c #93BDD4", +"!> c #88ADC7", +"~> c #6F94AE", +"{> c #526A7E", +"]> c #65849B", +"^> c #799DBB", +"/> c #84AFC9", +"(> c #8FB9D2", +"_> c #323C45", +":> c #516C84", +"<> c #658AA4", +"[> c #5B7C9B", +"}> c #2E3A49", +"|> c #2A3038", +"1> c #252D3A", +"2> c #1B1E20", +"3> c #ADBFCF", +"4> c #C0D6E7", +"5> c #B0CDE2", +"6> c #8EB3C9", +"7> c #526975", +"8> c #6B899D", +"9> c #597183", +"0> c #90BAD5", +"a> c #94C2DA", +"b> c #82ABC5", +"c> c #495E6E", +"d> c #82A8C3", +"e> c #81A4BA", +"f> c #7594A5", +"g> c #87ABC3", +"h> c #4D6573", +"i> c #6689A6", +"j> c #526E85", +"k> c #243037", +"l> c #607B96", +"m> c #7699B6", +"n> c #789EB5", +"o> c #303D48", +"p> c #7498B4", +"q> c #7094AF", +"r> c #597792", +"s> c #242F39", +"t> c #1A1D25", +"u> c #374553", +"v> c #4D677D", +"w> c #14191E", +"x> c #040505", +"y> c #171A1D", +"z> c #8A9FAD", +"A> c #BCD9EC", +"B> c #B5D3E7", +"C> c #A2CAE1", +"D> c #9DC7DE", +"E> c #9EC7DD", +"F> c #3B4A57", +"G> c #455867", +"H> c #98C2DB", +"I> c #85B0CC", +"J> c #7496B2", +"K> c #4C606F", +"L> c #6E8EA3", +"M> c #7EA0B6", +"N> c #91BBD3", +"O> c #8DB7D1", +"P> c #90BAD4", +"Q> c #96C1DA", +"R> c #3B4853", +"S> c #688AA5", +"T> c #4C657A", +"U> c #1B2026", +"V> c #2B3C44", +"W> c #5F7A90", +"X> c #587284", +"Y> c #536978", +"Z> c #88B1CC", +"`> c #759AB8", +" , c #617E9A", +"., c #556F85", +"+, c #20272E", +"@, c #323D48", +"#, c #333E4A", +"$, c #060707", +"%, c #4A5159", +"&, c #ACC3D5", +"*, c #ACCFE5", +"=, c #5A6874", +"-, c #AACDE1", +";, c #9CC6DC", +">, c #35414C", +",, c #769AB2", +"', c #80AAC5", +"), c #6F92AB", +"!, c #38464F", +"~, c #7EA4B9", +"{, c #97C3DC", +"], c #7A9FB6", +"^, c #3F505C", +"/, c #6D8DA6", +"(, c #1E282E", +"_, c #080909", +":, c #090A0C", +"<, c #344452", +"[, c #3B4857", +"}, c #7799AE", +"|, c #8DB6D1", +"1, c #66869E", +"2, c #3D4957", +"3, c #536C84", +"4, c #353F4C", +"5, c #111215", +"6, c #65727E", +"7, c #A6BCCD", +"8, c #5D6972", +"9, c #AED0E6", +"0, c #99C5DC", +"a, c #8DB5D0", +"b, c #8DB5CE", +"c, c #90BBD5", +"d, c #84AAC5", +"e, c #8EBBD5", +"f, c #80A7C1", +"g, c #6C8DA2", +"h, c #85AFC6", +"i, c #61839B", +"j, c #374352", +"k, c #576D83", +"l, c #80A6C1", +"m, c #81A4BB", +"n, c #111315", +"o, c #111418", +"p, c #4C6378", +"q, c #33424C", +"r, c #37454D", +"s, c #8DB4CF", +"t, c #7397B3", +"u, c #3A495A", +"v, c #0D0F13", +"w, c #27303A", +"x, c #272E36", +"y, c #0F1012", +"z, c #90A4B2", +"A, c #A8CBE2", +"B, c #91BCD4", +"C, c #80ABC3", +"D, c #567083", +"E, c #67899D", +"F, c #94C2DB", +"G, c #95C1DB", +"H, c #779CB2", +"I, c #60849E", +"J, c #64849F", +"K, c #1A1F22", +"L, c #405061", +"M, c #79A1BD", +"N, c #324051", +"O, c #6183A1", +"P, c #6B8FAD", +"Q, c #6485A2", +"R, c #34444F", +"S, c #060606", +"T, c #2D3339", +"U, c #B2CBDF", +"V, c #94BCD5", +"W, c #7DA2BA", +"X, c #3F5264", +"Y, c #5A7991", +"Z, c #7195B3", +"`, c #7BA5BD", +" ' c #81AAC6", +".' c #88B2CC", +"+' c #8EBBD4", +"@' c #8AB2CC", +"#' c #82ADC7", +"$' c #7092A5", +"%' c #95C2DA", +"&' c #41525F", +"*' c #6387A3", +"=' c #475F72", +"-' c #21282F", +";' c #5B7288", +">' c #0D0F11", +",' c #0B0E11", +"'' c #212C36", +")' c #26323C", +"!' c #161B20", +"~' c #55616D", +"{' c #9BB9D0", +"]' c #799EB6", +"^' c #27313A", +"/' c #1A222B", +"(' c #5D7E99", +"_' c #6587A4", +":' c #6789A6", +"<' c #6B8EAB", +"[' c #628097", +"}' c #6D8B9D", +"|' c #769AAF", +"1' c #6E91A9", +"2' c #6C8EAD", +"3' c #6E91AF", +"4' c #3C4D59", +"5' c #8BB1CB", +"6' c #232D32", +"7' c #13171B", +"8' c #232B32", +"9' c #839AAF", +"0' c #789BB3", +"a' c #283138", +"b' c #0C0E0F", +"c' c #242B33", +"d' c #3D4D5B", +"e' c #435768", +"f' c #4B6176", +"g' c #283137", +"h' c #8DB4CC", +"i' c #41535E", +"j' c #405362", +"k' c #3C4F60", +"l' c #3C4E5B", +"m' c #2B353E", +"n' c #526876", +"o' c #92BAD3", +"p' c #1B1F23", +"q' c #31383F", +"r' c #7F9CB6", +"s' c #21292F", +"t' c #29333F", +"u' c #1F252E", +"v' c #090A0E", +"w' c #4D626E", +"x' c #96BDD3", +"y' c #191D20", +"z' c #13181B", +"A' c #80A4BC", +"B' c #1B2027", +"C' c #5D7182", +"D' c #2C383F", +"E' c #364857", +"F' c #1A2028", +"G' c #333F49", +"H' c #7FA2B5", +"I' c #4A5E6E", +"J' c #232E35", +"K' c #252D35", +"L' c #2F3A41", +"M' c #0A0B0E", +"N' c #14191D", +"O' c #5A717F", +"P' c #212931", +"Q' c #222B34", +"R' c #101216", +"S' c #21272B", +" ", +" ", +" ", +" . ", +" + ", +" @ # $ % ", +" & * = - ; ", +" > , ' ) ! ~ { ] ", +" ^ / ( _ : < [ } | 1 2 3 4 5 6 7 8 9 0 a ", +" b c d e f g h i j k l m n o p q r s t u v w x ", +" y z A B C D E F G H I J K L M N O P Q R S T U U V W X Y ", +" Z ` ...+.@.#.$.%.O &.*.=.-.;.>.,.'.).!.~.~.~.{.].^./.(._.:.<. ", +" b [.}.|.#.1.2.3.4.{.~.~.~.~.5.6.5.~.7.8.{.~.~.~.~.9.0.a.b.].c. ", +" d.e.f.g.h.i.j.k.{.~.~.~.~.l.~.m.% n.~.o.{.{.~.~.~.~.p.V 9.~.q.r. ", +" s.t.u.v.w.x.u y.z.A.B.5.~.~.5.C.D.E.F.~.~.G.~.~.~.G.H.I.J.~.~.J.K.L. M.N. ", +" O.P.Q.R.S.T.U.V.W.X.Y.Z.`.~.~.5. +.+++@+U ~.~.~.~.~.#+$+%+,.~.~.G.&+*+=+-+;+ ", +" >+,+Q.'+)+!+~+{+]+^+/+(+_+:+<+~.[+}+U 9.|+5.~.~.~.~.1+2+3+4+5+~.].6+7+8+9+0+ ", +" a+b+c+d+e+f+g+h+i+j+k+l+m+n+o+p+q+5.U ~.U r+s+~.~.~.t+u+v+w+x+y+~.z+A+t+B+C+D+E+ F+G+ ", +" H+I+J+K+L+M+N+O+P+Q+R+S+T+U+V+W+X+Y+V ~.~.~.~.U ~.~.~.o.9.{.Z+`+9.~.~.~.V @.@+@@@#@ $@%@&@*@ ", +" =@-@;@>@,@'@'.)@!@~@{@]@^@/@l+(@_@:@<@~.~.~.U {.~.~.~.{.~.~.{.[@~.~.~.~.}@|@1@2@3@4@5@6@7@8@ ", +" 9@0@a@b@c@d@-.e@f@g@h@i@j@k@l@V+m@n@o@p@~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.{.q@r@s@t@u@v@w@x@y@ ", +"z@A@B@C@D@E@X F@G@H@R I@J@K@L@M@N@O@P@Q@R@o+S@T@~.~.~.~.~.~.~.~.~.~.~.~.~.~.9.U@V@W@X@<+V Y@Z@`@ # ", +" .#+#@###$#%#&#*#=#-#;#>#,#'#)#!#~#{#]#^#S@/#~.~.~.~.~.~.~.~.~.~.~.~.~.U (#_#:#<#p@{.[#}#|#1#2# ", +" 3#4#5#6#7#8#9#0#a#b#c#d#e#f#g#h#i#j#k#S@/#~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.l#m#9.{.~.n#o#p#q#r#s# ", +" t#u#v#w#x#y#z#A#B#C#D#E#F#G#H#I#% J#K#S@T@~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.L#0.l.~.~.{.M#N#O#P#Q#R# ", +" S#T#U#V#W#X#Y#Z#`# $.$+$@$#$$$%$&$*$=$-$a#~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.o.o.;$9.G.~.>$,$'$)$!$~${$]$ ", +" ^$/$($_$:$<$[$}$|$1$2$3$4$5$6$7$8$9$:+<+~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.G.0$a$b$c$d$e$f$g$h$i$j$k$ ", +" [ l$m$n$o$p$q$r$s$t$u$v$w$x$y$z$A$B$C$M#p@~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.;$D$E$F$G$H$I$J$K$L$ ", +" M$N$O$P$Q$R$S$T$U$V$W$X$Y$Z$`$ %.%+%@%<+{.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.#%$%%%p@&%*%=%-%;%>%,% ", +" '%)%!%~%{%]%^%/%(%_%:%<%[%}%|%1%2%3%-$T@~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.4%5%U p@6%7%8%9%0%a%y ", +" b%c%d%e%f%g%h%i%G.[#j%k%l%m%n%o%p%@%q%{.~.~.~.~.~.~.~.~.~.~.~.~.~.~.{.~.~.~.~.~.~.V G.}@r%s%t%u%v%w%M.x%y%z%A% ", +" B%C%D%E%F%G%H%I%V o.<@J%K%L%M%N%O%P%p@~.~.~.~.~.~.~.~.~.U ~.~.U 9.Q%{.~.~.~.~.~.{.%%U {.~.~.{.v@R%S%T%U%V%W% X%$ ", +" Y%Z%`% &.&+&@&#&U ~.{.$&%&&&*&=&-&T@~.~.~.~.~.~.~.~.~.~.~.;&>&,&'&)&!&5+~.~.~.~.{.~&{&]&9.~.p@^&/&(&_&:& <&[&}&|& ", +" 1&2&3&4&5&6&7&8&9&l.~.{.V 0&a&b&c&~.~.~.~.~.~.~.5.d&e&f&g&h&i&j&k&l&m&n&~.~.G.~.~.~.o&p&q&r&s&t&u&v& w&x&y&z&A&B& ", +" C&2&D&E&F&G&G&H&I&J&U ~.~.U K&L&,.~.~.~.~.~.~.~.U M&N&O&P&Q&R&S&T&U&V&W&X&].{.~.~.{./#Y&Z&`& *.*+*@* (.#*$*%*&***=* ", +" -*;*>*,*'*)*!*~*{*]*^*~.5.{.5./*U ~.~.~.~.~.~.{.[#(*_*:*<*[*[*}*|*1*2*3*4*5*U ~.~.6*7*8*9*0*a*b*c*d*e*f*g*h*i*%*j*k*<%l* ", +" m*n*o*p*q*r*s*t*u*v*w*1+~.~.~.~.~.~.~.~.~.~.~.x*y*z*A*B*C*D*E*V U ~.G.~.:.F*G*l.{.R%X+H*I*J*K*L*M*N*O*P*Q*R*S*T*U*V*W*X* ", +" Y*Z*D&`* =.=+=@=#=$=%=&={.~.~.~.~.~.~.~.~.~.~.<+*===-=;=>=,='=)=[#p@!=~={=]=^=/=(=a#&%_=:=<=-#[=}=k$|=1=2=3=4=5=6=7=8=9= ", +" 0=a=b=c=d=e=f=g=h=i=j=k=l=5.~.~.~.~.~.~.~.~.~.V -$m=n===o=p=q=r=s=t=:+u=v=w=x=y=z=A=J.V U ~.V [#B=C=D=1=E=F= G=H=I= ", +" J=K=L=M=N=O=P=Q=R=S=T=U=V=5.U ~.~.~.~.~.~.~.~.~.{.x*W=X=Y=Z=`= -.-+-@-#-$-%-&-*-=---;->-9.x*)=,-'-)-c.!-~- {-]- ", +" ^-/-(-_-:-<-<-[-%.}-|-1-T@~.{.~.~.~.~.~.~.~.~.~.~.V 2-^&3-4-5-6-7-8-9-0-a-b-c-d-e-f-g-h-V@i-j-k-l-T=m-7@n- o-p- ", +" q-r-s-t-u-v-!+2*w-x-y-z-V ~.~.~.~.~.~.~.~.~.~.~.~.~.~./#A-B-C-D-E-F-G-H-I-J-K-L-<@M-W=N-O-P-Q-R-<&S-T-U-V- W- ", +" X-Y-Z-`- ;.;+;@;#;$;q+~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~./#v@W=N#%;&;*;=;-;s=-#;;>;,;';);!;~;{;];^;/;(;H+ ", +" _;:;<;[;};|;1;2;3;4;{.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.{.T@-#5;6;7;8;9;[#V <+0;a;b;c;E-d;e;f;|=g;h; ", +" i;j;V#k;F.l;m;n;o;~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.{.~.{.p@S@s=p;q;~.~.{.r;s;t;u;~$v;w;x;y;z;A; ", +" H+B;C;D;E;F;G;H;~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.{.U ~.~.V E*E*V ~.~.~.{.T@/#I;J;K;L;M;y;N;O; ", +" P;Q;R;S;T;U;~.{.~.~.~.~.~.~.~.~.l.U {.p@~.~.{.V ~.~.5+V;].~.~.~.~.{.{.p@W;X;Y;Z;`;/# >W..>+>N;@> ", +" #>$>%>&>*>G.~.~.~.~.~.~.~.~.{.`.=>V=->;>~.n##&>>T@,>'>].~.~.~.~.~.)>!>i$~>{>]>^>/>(>_>:><>[>}> |>1> ", +" 2>3>4>5>U@U ~.~.~.~.~.~.~.{.6>7>8>9>0>a#a>b>c>d>e>f>~.~.~.V ~.~.g>h>i>1=j>,%k>l>m>n>o>p>q>r>s>t>u>v>w> ", +" x>y>z>A>B>C>5+D>E>~.~.~.~.{.%&F>G>3;s%{.H>I>J>K>L>M>~.V N>O>P>x*Q>R>S>T>U> X%V>W>X>Y>Z>P-`> ,.,+, ", +" @,#,$,%,&,1.*,=,-,;,{.p@V {.X@>,,,Z;V ~.5.`;',),!,~,~.{,],^,/,/&-$F$(,_, :,<,[,},<@|,1,2, ", +" B&3,4, 5,6,7,8,9,0,`;a,b,B+c,d,s=<+~.~.~.a#e,f,g,h,V -#9$i,j,k,l,m,n, o,p,q,r,s,t,u,v, ", +" w,x, y,z,A,B,C,D,E,o@F,G,<+~.~.~.~.~.;;P>j%}@p@H,]#I,J,K,L,M,=+ N,O,P,Q,R,S, ", +" T,U,V,W,X,Y,Z,`, '.'+'x*~.{.O+@%@'#'$'%'a#&'*'='-' ~;;'>' ,''')'!' ", +" ~'{']'^'/'('_'_':'<'['}'{.V |'1'2'3'4'5'}@6'7' 8'K; ", +" v&9'0'a' b'c'd'e'f'1@g'h'G.i'j'k'l'm'n'o'p' y ", +" q'r's' t'u'H+ v'w'x'y' z'A'B' ", +" C'D' E'F' G'H' I'J' ", +" K'L' M' N'O' P'Q' ", +" R' S' ", +" ", +" ", +" ", +" "}; diff --git a/minilibx-linux/test/run_tests.sh b/minilibx-linux/test/run_tests.sh new file mode 100755 index 0000000..d33cd5e --- /dev/null +++ b/minilibx-linux/test/run_tests.sh @@ -0,0 +1,94 @@ +#!/usr/bin/env sh + +# This very basic script simulate user inputs for the CI +# Feel free to update, improve or remove it if proper +# intergration tests and/or unit tests are added. + +set -e + +BOLD="\033[1m" +RESET="\033[0m" +LIGHT_RED="\033[91m" +LIGHT_GREEN="\033[92m" +LIGHT_CYAN="\033[96m" + +logging(){ + local type=$1; shift + printf "${LIGHT_CYAN}${BOLD}run_tests${RESET} [%b] : %b\n" "$type" "$*" +} +log_info(){ + logging "${LIGHT_GREEN}info${RESET}" "$@" +} +log_error(){ + logging "${LIGHT_RED}error${RESET}" "$@" >&2 + exit 1 +} + + +PID="" + +# to properly kill child process executed in background on exit +at_exit() { + status=$? + [ $status -eq 0 ] && log_info "Seem all went well" && exit 0 + # Code for non-zero exit: + if ! kill -s TERM "$PID" 2>/dev/null || ! wait "$PID" ; then + log_error "Pid [$PID] died with status $status " + fi + log_error "Something went wrong. Pid [$PID] has been killed. Status code $status" +} +# to properly quit from ctrl+c (SIGINT Signal) +sigint_handler(){ + kill -s TERM "$PID" + wait + log_info "Tests abort" + exit 1 +} + +# look at test/main.c and run ./mlx-test to understand what this function does +test_default_main(){ + ${MAKE} -f Makefile.gen all + ./mlx-test & + PID="$!" + log_info "./mlx-test running in background, pid:" $PID + + i=25 # waiting 25s mlx-test to be ready for inputs. + while [ $i -gt 0 ]; do + if ! ps -p $PID > /dev/null ; then + wait $PID + fi + log_info "countdown" $i + sleep 1 + i=$((i - 1)) + done + log_info "Ready to \"just play\" using xdotool" + wid1=$(xdotool search --name Title1) + wid2=$(xdotool search --name Title2) + wid3=$(xdotool search --name Title3) + + xdotool windowfocus $wid3 + log_info "Focus Win3: Testing move mouse 100 100" + xdotool mousemove 100 100 + log_info "Focus Win3: Testing move mouse 200 200" + xdotool mousemove 200 200 + log_info "Focus Win3: Pressing escape to destroy window \"Win3\"" + xdotool key Escape + + log_info "Focus Win2: Pressing escape to stop program" + xdotool windowfocus $wid2 + xdotool key Escape +} + +main(){ + case $(uname) in + FreeBSD) MAKE=gmake ;; + *) MAKE=make ;; + esac + cd $(dirname $0) + trap at_exit EXIT + trap sigint_handler INT + + test_default_main +} + +main "$@" diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..b6b0be7 --- /dev/null +++ b/readme.md @@ -0,0 +1,56 @@ +# so_long 🎮 + +A simple 2D game created with MinilibX. Player must collect all objects and reach the exit! 🎯 + +## Description 📝 + +so_long is a small 2D game where you navigate through a map, collect items, and reach the exit using MinilibX graphics library. A perfect first game project! ✨ + +## Features 🚀 + +- Character movement with WASD or arrow keys 🎹 +- Item collection 💎 +- Move counter 🔢 +- Collision detection 💥 +- Sprite display 🖼️ +- Map validation ✅ + +## Prerequisites 📋 + +- gcc or clang 🛠️ +- make 🔧 +- MinilibX 🎨 +- Compatible operating system (Linux/MacOS) 💻 + +## Installation ⚙️ + +```bash +git clone [REPO_URL] +cd so_long +make +``` + +## Usage 🎯 + +```bash +./so_long [MAP_PATH] +``` + +Example: +```bash +./so_long maps/map1.ber +``` + +## Map Format 🗺️ + +Maps must be .ber files and follow these rules: +- 1 for walls 🧱 +- 0 for floor ⬜ +- P for player 🧍 +- E for exit 🚪 +- C for collectibles 💎 + +## Controls 🎮 + +- WASD or Arrows: Movement 🔄 +- ESC: Quit game ❌ diff --git a/srcs/main.c b/srcs/main.c new file mode 100644 index 0000000..021241e --- /dev/null +++ b/srcs/main.c @@ -0,0 +1,70 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* main.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lfirmin +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/11/12 11:00:04 by lfirmin #+# #+# */ +/* Updated: 2024/11/12 15:53:59 by lfirmin ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "../include/so_long.h" + +int get_map_dimensions(t_data *data, int *width, int *height) +{ + *height = 0; + while (data->map[*height]) + { + if (*height == 0) + *width = ft_strlen(data->map[0]); + else if ((int)ft_strlen(data->map[*height]) != *width) + return (1); + (*height)++; + } + return (0); +} + +int launch_game(t_data *data) +{ + t_game *game; + int width; + int height; + + if (get_map_dimensions(data, &width, &height)) + return (ft_printf_fd(2, "Error : Invalid map dimensions\n"), 1); + game = malloc(sizeof(t_game)); + if (!game) + return (1); + init_struct(game); + game->map = data->map; + game->map_width = width; + game->map_height = height; + game->collectibles = data->colect; + game->moves = 0; + game->data = data; + if (init_game(game)) + return (free(game), 1); + mlx_hook(game->win, 2, 1L << 0, key_hook, game); + mlx_hook(game->win, 17, 1L << 17, close_game, game); + draw_map(game); + mlx_loop(game->mlx); + return (0); +} + +int main(int ac, char **av) +{ + t_data *data; + + if (ac != 2) + return (ft_printf_fd(2, "Error : Usage: ./so_long map.ber\n"), 1); + data = init_data(); + if (!data) + return (ft_printf_fd(2, "Error : Init failed\n"), 1); + if (pars_map(data, av[1]) == 1) + return (1); + if (launch_game(data)) + return (clean_data(data), 1); + return (0); +} diff --git a/srcs/pars_map.c b/srcs/pars_map.c new file mode 100644 index 0000000..45020c3 --- /dev/null +++ b/srcs/pars_map.c @@ -0,0 +1,129 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* pars_map.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lfirmin +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/11/12 16:16:49 by lfirmin #+# #+# */ +/* Updated: 2024/11/16 18:41:22 by lfirmin ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "../include/so_long.h" + +int ft_count_lines(char *file) +{ + char c; + int fd; + int ret; + int count; + int last; + + fd = open(file, O_RDONLY); + if (fd < 0) + return (-1); + count = 0; + last = '\n'; + ret = read(fd, &c, 1); + while (ret > 0) + { + if (c == '\n') + count++; + last = c; + ret = read(fd, &c, 1); + } + if (last != '\n') + count++; + return (close(fd), count); +} + +char *add_newline_if_needed(char *line) +{ + size_t len; + char *new_line; + + if (!line) + return (NULL); + len = strlen(line); + if (len > 0 && line[len - 1] != '\n') + { + new_line = malloc(len + 2); + if (!new_line) + return (NULL); + strcpy(new_line, line); + new_line[len] = '\n'; + new_line[len + 1] = '\0'; + free(line); + return (new_line); + } + return (line); +} + +int get_map(char *file, t_data *data) +{ + int fd; + int i; + int nb_lines; + + nb_lines = ft_count_lines(file); + if (nb_lines <= 0) + return (ft_printf_fd(2, "Error : The map is empty\n"), 1); + data->map = malloc(sizeof(char *) * (nb_lines + 1)); + if (!data->map) + return (1); + i = 0; + fd = open(file, O_RDONLY); + if (fd == -1) + return (ft_printf_fd(2, "Error : opening file %s\n", file), 1); + if (get_map_2(i, nb_lines, data, fd) == 1) + return (close(fd), 1); + return (close(fd), 0); +} + +int check_close(t_data *data) +{ + int i; + int j; + + i = 1; + if (check_first_last_lines(data, 0) == 1) + return (1); + while (data->map[i + 1]) + { + j = 1; + if (data->map[i][0] != '1') + return (ft_printf_fd(2, "Error : Map not closed\n"), 1); + while (data->map[i][j + 1]) + j++; + if (data->map[i][j - 1] != '1') + return (ft_printf_fd(2, "Error : Map not closed\n"), 1); + i++; + } + return (check_first_last_lines(data, i)); +} + +int check_first_last_lines(t_data *data, int i) +{ + int j; + + j = 0; + while (data->map[0][j + 1] && data->map[0][j + 1] != '\n') + { + if (data->map[0][j] != '1') + return (ft_printf_fd(2, "Error : Map not closed\n"), 1); + j++; + } + if (data->map[0][j] != '1') + return (ft_printf_fd(2, "Error : Map not closed\n"), 1); + j = 0; + while (data->map[i][j + 1] && data->map[i][j + 1] != '\n') + { + if (data->map[i][j] != '1') + return (ft_printf_fd(2, "Error : Map not closed\n"), 1); + j++; + } + if (data->map[i][j] != '1') + return (ft_printf_fd(2, "Error : Map not closeds\n"), 1); + return (0); +} diff --git a/srcs/pars_map_2.c b/srcs/pars_map_2.c new file mode 100644 index 0000000..58e2537 --- /dev/null +++ b/srcs/pars_map_2.c @@ -0,0 +1,106 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* pars_map_2.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lfirmin +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/11/12 17:51:27 by lfirmin #+# #+# */ +/* Updated: 2024/11/12 17:51:27 by lfirmin ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "../include/so_long.h" + +char **copy_map(char **original) +{ + char **copy; + int i; + int height; + + height = 0; + while (original[height]) + height++; + copy = malloc(sizeof(char *) * (height + 1)); + if (!copy) + return (NULL); + i = 0; + while (original[i]) + { + copy[i] = ft_strdup(original[i]); + if (!copy[i]) + { + while (i > 0) + free(copy[--i]); + free(copy); + return (NULL); + } + i++; + } + copy[i] = NULL; + return (copy); +} + +int is_playable(t_data *data, int x, int y) +{ + char **tmp_map; + + tmp_map = copy_map(data->map); + if (!tmp_map) + return (clean_data(data), 1); + if (play_check(tmp_map, x, y) == 0) + return (free_map(tmp_map), 0); + return (free_map(tmp_map), 1); +} + +int play_check(char **map, int x, int y) +{ + if (map[y][x] == 'P') + return (0); + if (map[y][x] != '0' && map[y][x] != 'C' && map[y][x] != 'E') + return (2); + map[y][x] = '1'; + if (play_check(map, x + 1, y) == 0) + return (0); + if (play_check(map, x - 1, y) == 0) + return (0); + if (play_check(map, x, y + 1) == 0) + return (0); + if (play_check(map, x, y - 1) == 0) + return (0); + return (1); +} + +void free_map(char **map) +{ + int i; + + i = 0; + while (map[i]) + free(map[i++]); + free(map); +} + +int check_playable(t_data *data) +{ + int i; + int j; + + i = 1; + j = 1; + while (data->map[i + 1]) + { + j = 1; + while (data->map[i][j + 1]) + { + if (data->map[i][j] == 'C' || data->map[i][j] == 'E') + { + if (is_playable(data, j, i) == 1) + return (1); + } + j++; + } + i++; + } + return (0); +} diff --git a/srcs/pars_map_3.c b/srcs/pars_map_3.c new file mode 100644 index 0000000..f81dc94 --- /dev/null +++ b/srcs/pars_map_3.c @@ -0,0 +1,124 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* pars_map_3.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lfirmin +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/11/12 20:07:42 by lfirmin #+# #+# */ +/* Updated: 2024/11/12 20:07:42 by lfirmin ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "../include/so_long.h" + +int have_require_item(t_data *data) +{ + int i; + int j; + + i = 1; + while (data->map[i]) + { + j = 1; + while (data->map[i][j]) + { + if (data->map[i][j] == 'E') + data->e++; + if (data->map[i][j] == 'P') + data->p++; + if (data->map[i][j] == 'C') + data->colect++; + j++; + } + i++; + } + if (data->e != 1 || data->p != 1) + return (ft_printf_fd(2, "Error : The number of E/P is invalid\n"), 1); + if (data->colect < 1) + return (ft_printf_fd(2, \ + "Error : There are no collectables\n"), 1); + return (0); +} + +int pars_map(t_data *data, char *file) +{ + if (is_ber(file) == 1) + return (clean_data(data), 1); + if (get_map(file, data) == 1) + return (clean_data(data), 1); + if (check_char(data) == 1) + return (clean_data(data), 1); + if (check_rectangle(data) == 1) + return (clean_data(data), 1); + if (check_close(data) == 1) + return (clean_data(data), 1); + if (have_require_item(data) == 1) + return (clean_data(data), 1); + if (check_playable(data) == 1) + return (ft_printf_fd(2, \ + "Error : Map not playable\n"), clean_data(data), 1); + return (0); +} + +int check_rectangle(t_data *data) +{ + size_t len; + int i; + + len = ft_strlen(data->map[0]); + i = 1; + while (data->map[i]) + { + if (ft_strlen(data->map[i]) != len) + return (ft_printf_fd(2, "Error : Invalid map format\n"), 1); + i++; + } + return (0); +} + +int is_ber(char *file) +{ + size_t len; + char *ext; + int i; + + ext = ".ber"; + if (!file) + return (ft_printf_fd(2, "Error: No file provided\n"), 1); + len = ft_strlen(file); + if (len < 4) + return (ft_printf_fd(2, "Error: Invalid file name\n"), 1); + i = 0; + while (i < 4) + { + if (file[len - 4 + i] != ext[i]) + return (ft_printf_fd(2, "Error: File type isn't .ber\n"), 1); + i++; + } + return (0); +} + +int check_char(t_data *data) +{ + int i; + int j; + char c; + + i = 0; + c = 0; + while (data->map[i]) + { + j = 0; + while (data->map[i][j] && data->map[i][j] != '\n') + { + c = data->map[i][j]; + if (c != 'E' && c != 'P' && c != 'C' && c != '0' && c != '1') + return (ft_printf_fd(2, \ + "Error : invalid char -> '%c'\n", c), 1); + j++; + } + i++; + } + return (0); +} diff --git a/srcs/utils.c b/srcs/utils.c new file mode 100644 index 0000000..eab3f9b --- /dev/null +++ b/srcs/utils.c @@ -0,0 +1,108 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* utils.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lfirmin +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/11/12 16:24:49 by lfirmin #+# #+# */ +/* Updated: 2024/11/17 13:04:59 by lfirmin ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "../include/so_long.h" + +t_data *init_data(void) +{ + t_data *data; + + data = malloc(sizeof(t_data)); + if (!data) + return (NULL); + data->map = NULL; + data->colect = 0; + data->p = 0; + data->e = 0; + return (data); +} + +void clean_data(t_data *data) +{ + int i; + + if (!data) + return ; + if (data->map) + { + i = 0; + while (data->map[i]) + { + free(data->map[i]); + i++; + } + free(data->map); + } + free(data); +} + +int init_window(t_game *game) +{ + int screen_width; + int screen_height; + + game->mlx = mlx_init(); + if (!game->mlx) + return (1); + game->win = mlx_new_window(game->mlx, + game->map_width * 32 - 32, + game->map_height * 32, + "so_long"); + mlx_get_screen_size(game->mlx, &screen_width, &screen_height); + if (screen_width < (game->map_width * 32 - 32)) + return (ft_printf_fd(2, "Error : Map too big in width\n"), \ + close_game(game), 1); + if (screen_height < (game->map_height * 32)) + return (ft_printf_fd(2, "Error : Map too big in height\n"), \ + close_game(game), 1); + if (!game->win) + return (ft_printf_fd(2, "Error\nMLX initialization failed\n"), \ + close_game(game), 1); + return (0); +} + +int init_images(t_game *game) +{ + int img_width; + int img_height; + + game->img_floor = mlx_xpm_file_to_image(game->mlx, + "assets/floor.xpm", &img_width, &img_height); + game->img_wall = mlx_xpm_file_to_image(game->mlx, + "assets/wall.xpm", &img_width, &img_height); + game->img_player = mlx_xpm_file_to_image(game->mlx, + "assets/player.xpm", &img_width, &img_height); + game->img_collect = mlx_xpm_file_to_image(game->mlx, + "assets/collectible.xpm", &img_width, &img_height); + game->img_exit = mlx_xpm_file_to_image(game->mlx, + "assets/exit.xpm", &img_width, &img_height); + if (!game->img_floor || !game->img_wall || !game->img_player + || !game->img_collect || !game->img_exit) + { + ft_printf_fd(2, "Error : Image not found\n"); + close_game(game); + return (1); + } + return (0); +} + +int init_game(t_game *game) +{ + if (init_window(game)) + return (1); + if (init_images(game)) + return (1); + game->moves = 0; + find_player_pos(game); + find_exit_pos(game); + return (0); +} diff --git a/srcs/utils_2.c b/srcs/utils_2.c new file mode 100644 index 0000000..395de79 --- /dev/null +++ b/srcs/utils_2.c @@ -0,0 +1,93 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* utils_2.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lfirmin +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/11/13 12:34:24 by lfirmin #+# #+# */ +/* Updated: 2024/11/13 12:34:24 by lfirmin ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "../include/so_long.h" + +int close_game(t_game *game) +{ + if (!game) + return (0); + if (game->img_floor) + mlx_destroy_image(game->mlx, game->img_floor); + if (game->img_wall) + mlx_destroy_image(game->mlx, game->img_wall); + if (game->img_player) + mlx_destroy_image(game->mlx, game->img_player); + if (game->img_collect) + mlx_destroy_image(game->mlx, game->img_collect); + if (game->img_exit) + mlx_destroy_image(game->mlx, game->img_exit); + if (game->win) + mlx_destroy_window(game->mlx, game->win); + if (game->mlx) + { + mlx_destroy_display(game->mlx); + free(game->mlx); + } + clean_data(game->data); + free(game); + return (exit(0), 0); +} + +void update_player_position(t_game *game, int x, int y) +{ + int old_x; + int old_y; + + old_x = game->player_x; + old_y = game->player_y; + game->map[old_y][old_x] = '0'; + if (old_x == game->exit_x && old_y == game->exit_y) + game->map[old_y][old_x] = 'E'; + draw_tile(game, game->map[old_y][old_x], old_x, old_y); + game->map[y][x] = 'P'; + draw_tile(game, 'P', x, y); + game->player_x = x; + game->player_y = y; + game->moves++; + printf("Moves: %d\n", game->moves); +} + +void move_player(t_game *game, int new_x, int new_y) +{ + char current_pos; + + current_pos = game->map[new_y][new_x]; + if (current_pos == 'E' && game->collectibles == 0) + { + ft_printf_fd(1, "Congratulations! You won in %d moves!\n", \ + game->moves + 1); + close_game(game); + } + if (current_pos == 'C') + { + game->collectibles--; + if (game->collectibles == 0) + draw_tile(game, 'E', game->exit_x, game->exit_y); + } + update_player_position(game, new_x, new_y); +} + +int is_valid_move(t_game *game, int x, int y) +{ + if (x < 0 || x >= game->map_width || y < 0 || y >= game->map_height) + return (0); + if (game->map[y][x] == '1') + return (0); + if (game->map[y][x] == 'E') + { + if (game->collectibles == 0) + return (1); + return (1); + } + return (1); +} diff --git a/srcs/utils_3.c b/srcs/utils_3.c new file mode 100644 index 0000000..02df2ec --- /dev/null +++ b/srcs/utils_3.c @@ -0,0 +1,111 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* utils_3.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lfirmin +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/11/13 16:51:15 by lfirmin #+# #+# */ +/* Updated: 2024/11/13 16:51:15 by lfirmin ### ########.fr */ +/* */ +/* ************************************************************************** */ +#include "../include/so_long.h" + +void draw_tile(t_game *game, char current, int x, int y) +{ + mlx_put_image_to_window(game->mlx, game->win, + game->img_floor, x * 32, y * 32); + if (current == '1') + mlx_put_image_to_window(game->mlx, game->win, + game->img_wall, x * 32, y * 32); + else if (current == 'P') + mlx_put_image_to_window(game->mlx, game->win, + game->img_player, x * 32, y * 32); + else if (current == 'C') + mlx_put_image_to_window(game->mlx, game->win, + game->img_collect, x * 32, y * 32); + else if (current == 'E' && game->collectibles == 0) + mlx_put_image_to_window(game->mlx, game->win, + game->img_exit, x * 32, y * 32); +} + +void draw_map(t_game *game) +{ + int x; + int y; + char current; + + y = 0; + while (y < game->map_height) + { + x = 0; + while (x < game->map_width) + { + current = game->map[y][x]; + if (current != '\n') + draw_tile(game, current, x, y); + x++; + } + y++; + } +} + +int check_player(t_game *game, int x, int y, int *found) +{ + if (game->map[y][x] == 'P') + { + game->player_x = x; + game->player_y = y; + *found = 1; + } + return (0); +} + +int find_player_pos(t_game *game) +{ + int x; + int y; + int found; + + if (!game || !game->map) + return (1); + y = 0; + found = 0; + while (y < game->map_height) + { + x = 0; + while (x < game->map_width) + { + check_player(game, x, y, &found); + x++; + } + y++; + } + if (!found) + return (ft_printf_fd(2, "Error: Player position not found\n"), 1); + return (0); +} + +int key_hook(int keycode, t_game *game) +{ + int new_x; + int new_y; + + new_x = game->player_x; + new_y = game->player_y; + if (keycode == KEY_ESC) + close_game(game); + else if (keycode == KEY_W || keycode == KEY_UP) + new_y--; + else if (keycode == KEY_S || keycode == KEY_DOWN) + new_y++; + else if (keycode == KEY_A || keycode == KEY_LEFT) + new_x--; + else if (keycode == KEY_D || keycode == KEY_RIGHT) + new_x++; + else + return (0); + if (is_valid_move(game, new_x, new_y)) + move_player(game, new_x, new_y); + return (0); +} diff --git a/srcs/utils_4.c b/srcs/utils_4.c new file mode 100644 index 0000000..62f28f0 --- /dev/null +++ b/srcs/utils_4.c @@ -0,0 +1,75 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* utils_4.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lfirmin +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/11/17 13:04:09 by lfirmin #+# #+# */ +/* Updated: 2024/11/17 13:04:09 by lfirmin ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "../include/so_long.h" + +void init_struct(t_game *game) +{ + game->mlx = NULL; + game->win = NULL; + game->img_floor = NULL; + game->img_wall = NULL; + game->img_player = NULL; + game->img_collect = NULL; + game->img_exit = NULL; + game->player_x = 0; + game->player_y = 0; + game->moves = 0; + game->collectibles = 0; + game->map = NULL; + game->map_width = 0; + game->map_height = 0; + game->exit_x = 0; + game->exit_y = 0; + game->data = NULL; +} + +int get_map_2(int i, int nb_lines, t_data *data, int fd) +{ + char *line; + + line = get_next_line(fd); + while (line != NULL && i < nb_lines) + { + if (i == nb_lines - 1) + line = add_newline_if_needed(line); + if (!line) + return (1); + data->map[i++] = line; + line = get_next_line(fd); + } + data->map[i] = NULL; + return (0); +} + +void find_exit_pos(t_game *game) +{ + int x; + int y; + + y = 0; + while (y < game->map_height) + { + x = 0; + while (x < game->map_width) + { + if (game->map[y][x] == 'E') + { + game->exit_x = x; + game->exit_y = y; + return ; + } + x++; + } + y++; + } +}