From b396c3365fe7a0c9d29c33985116d31a39888603 Mon Sep 17 00:00:00 2001 From: Sarp Eren EGILMEZ <2348.sarp.egilmez.2006@gmail.com> Date: Sat, 23 Sep 2023 20:58:10 +0300 Subject: [PATCH] Added cli option to use fullscreen --- TODO.md | 2 +- src/App.cs | 27 ++++++++++++++++++++------- src/tym.py | 9 +++++++++ 3 files changed, 30 insertions(+), 8 deletions(-) diff --git a/TODO.md b/TODO.md index c340ed8..d3e0c0d 100644 --- a/TODO.md +++ b/TODO.md @@ -14,4 +14,4 @@ - [x] Starting point on screen - [ ] ~~Disable true-color and use predefined VT100 colors option~~ - [x] Resize method (fit, stretch, crop) -- [ ] Full screen option \ No newline at end of file +- [x] Full screen option \ No newline at end of file diff --git a/src/App.cs b/src/App.cs index 9d2dc03..19e9e29 100644 --- a/src/App.cs +++ b/src/App.cs @@ -50,6 +50,13 @@ public class Options [Option('m', "resize-method", Required = false, Default = "Contain", HelpText = "Resizing mode. Available options: Contain, Cover (Crop), Stretch")] public string ResizeMethod { get; set; } + + + + + [Option('f', "fullscreen", Required = false, Default = false, HelpText = "Use fullscreen. This overrides margin and size arguments!")] + public bool UseFullscreen { get; set; } + } public class App @@ -74,11 +81,11 @@ private void Run(Options CommandLineOptions) } string? ImagePath = CommandLineOptions.FilePath; - if (Path.Exists(ImagePath)) // local image + if (Path.Exists(ImagePath)) { ProcessImageFile(CommandLineOptions, ImagePath); } - else // URI + else { if (Uri.IsWellFormedUriString(ImagePath, UriKind.Absolute)) { @@ -150,7 +157,8 @@ private void ProcessImageFile(Options CommandLineOptions, string ImagePath) {"Contain", ResizeMode.Max}, {"Cover", ResizeMode.Crop}, {"Crop", ResizeMode.Crop}, - {"Stretch", ResizeMode.Stretch} + {"Stretch", ResizeMode.Stretch}, + {"Center", ResizeMode.Pad} }; if (!AvailableResizeModes.ContainsKey(CommandLineOptions.ResizeMethod)) { @@ -160,10 +168,15 @@ private void ProcessImageFile(Options CommandLineOptions, string ImagePath) ResizeMode SelectedResizeMode = AvailableResizeModes.GetValueOrDefault(CommandLineOptions.ResizeMethod); Size TermSize = new(Console.BufferWidth, Console.BufferHeight); - Size TargetSize = new( - CommandLineOptions.Width < 1 ? TermSize.Width / 2 : CommandLineOptions.Width, - CommandLineOptions.Height < 1 ? TermSize.Height : CommandLineOptions.Height - ); + Size TargetSize = CommandLineOptions.UseFullscreen + ? new( + TermSize.Width, + TermSize.Height * 2 + ) + : new( + CommandLineOptions.Width < 1 ? TermSize.Width / 2 : CommandLineOptions.Width, + CommandLineOptions.Height < 1 ? TermSize.Height : CommandLineOptions.Height + ); Image Source = Image.Load(ImagePath); Source.Mutate(x => x.Resize(new ResizeOptions() diff --git a/src/tym.py b/src/tym.py index d1dba27..b70d068 100644 --- a/src/tym.py +++ b/src/tym.py @@ -1,3 +1,12 @@ +""" +TYM Python Port +Created by Segilmez06 + +This is only contains really small amount of capabilities compared to mainstream .Net source. +This script will not be updated. +""" + + from sys import argv, stdout from os import path, get_terminal_size from PIL import Image, ImageOps