Tile mode for background image stretch #4463

Open
opened 2026-01-30 23:48:23 +00:00 by claunia · 2 comments
Owner

Originally created by @StrScr on GitHub (Oct 14, 2019).

Description of the new feature/enhancement

I'm trying to use a patterned GIF as a background image, but didn't find an option to tile it. A new option for setting the stretch mode to tile the image would be great. It would be a nice option as images like these simply don't look good under other modes or require extra effort to make them work, such as editing them and tiling them manually.

Here's the GIF I'm trying to use:
pmttyd

Proposed technical implementation details (optional)

Allow setting the "backgroundImageStretchMode" setting in the profiles to something like "tile". This would display the image at its native resolution from the top-left corner, repeating the image across the background until it's entirely covered.

Originally created by @StrScr on GitHub (Oct 14, 2019). # Description of the new feature/enhancement I'm trying to use a patterned GIF as a background image, but didn't find an option to tile it. A new option for setting the stretch mode to tile the image would be great. It would be a nice option as images like these simply don't look good under other modes or require extra effort to make them work, such as editing them and tiling them manually. Here's the GIF I'm trying to use: ![pmttyd](https://user-images.githubusercontent.com/12767988/66777197-891dbf80-ee85-11e9-9c19-63f7bb475656.gif) # Proposed technical implementation details (optional) Allow setting the `"backgroundImageStretchMode"` setting in the profiles to something like `"tile"`. This would display the image at its native resolution from the top-left corner, repeating the image across the background until it's entirely covered.
Author
Owner

@DHowett-MSFT commented on GitHub (Oct 14, 2019):

(I love this idea.)

@DHowett-MSFT commented on GitHub (Oct 14, 2019): (I love this idea.)
Author
Owner

@carlos-zamora commented on GitHub (May 15, 2020):

Got a chance to work on this a bit. Uploaded my branch to dev/cazamor/tile-background.

I was able to add the tile setting to backgroundImageStretchMode. I had to create a new enum which wasn't too bad.

The real problem here is that WUX::Controls::Image does not have a tile setting.

I was able to remove the Image control, and instead have the background image appear as the Background property for the Grid we're using in the Terminal Control (Grid.Background docs). The difference here, though, is that Grid.Background uses a Brush (or, in our case, an ImageBrush).

So, this gets us closer, but the big problem here is we need to create something like a TileImageBrush to extend an ImageBrush. And this TileImageBrush would just do the following:

  • get the size of the canvas it's trying to fill
  • get the size of the image it's trying to draw
  • repeatedly use the ImageBrush to draw the image in a tile format (doable with the two things above)

I'll probably be working on this as a side project, but if anybody has any thoughts on a different approach, or would like to take a stab at it, I've uploaded my branch to dev/cazamor/tile-background for you to try out. 😊

@carlos-zamora commented on GitHub (May 15, 2020): Got a chance to work on this a bit. Uploaded my branch to `dev/cazamor/tile-background`. I was able to add the `tile` setting to `backgroundImageStretchMode`. I had to create a new enum which wasn't too bad. The _real_ problem here is that [WUX::Controls::Image](https://docs.microsoft.com/en-us/uwp/api/Windows.UI.Xaml.Controls.Image?view=winrt-19041) does not have a tile setting. I was able to remove the `Image` control, and instead have the background image appear as the `Background` property for the `Grid` we're using in the Terminal Control ([Grid.Background docs](https://docs.microsoft.com/en-us/uwp/api/windows.ui.xaml.controls.panel.background?view=winrt-19041#Windows_UI_Xaml_Controls_Panel_Background)). The difference here, though, is that `Grid.Background` uses a `Brush` (or, in our case, an [`ImageBrush`](https://docs.microsoft.com/en-us/uwp/api/windows.ui.xaml.media.imagebrush?view=winrt-19041)). So, this gets us closer, but the big problem here is we need to create something like a `TileImageBrush` to extend an `ImageBrush`. And this `TileImageBrush` would just do the following: - get the size of the canvas it's trying to fill - get the size of the image it's trying to draw - repeatedly use the `ImageBrush` to draw the image in a tile format (doable with the two things above) I'll probably be working on this as a side project, but if anybody has any thoughts on a different approach, or would like to take a stab at it, I've uploaded my branch to `dev/cazamor/tile-background` for you to try out. 😊
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#4463