Skip to content

Commit

Permalink
Added cli option to use fullscreen
Browse files Browse the repository at this point in the history
  • Loading branch information
Segilmez06 committed Sep 23, 2023
1 parent e577168 commit b396c33
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 8 deletions.
2 changes: 1 addition & 1 deletion TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
- [x] Full screen option
27 changes: 20 additions & 7 deletions src/App.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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))
{
Expand Down Expand Up @@ -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))
{
Expand All @@ -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<Rgba32> Source = Image.Load<Rgba32>(ImagePath);
Source.Mutate(x => x.Resize(new ResizeOptions()
Expand Down
9 changes: 9 additions & 0 deletions src/tym.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit b396c33

Please sign in to comment.