winleafs / Winleafs

Winleafs: Windows application for Nanoleaf lights
GNU General Public License v3.0
85 stars 9 forks source link

Screen mirror needs horizontal flip option #126

Closed Kistaro closed 4 years ago

Kistaro commented 4 years ago

Hey Winleafs folks,

I've got a set of Aurora panels behind me as well as in front of me, and I'd rather set them both on Screen Mirror rather than having the one behind me on Ambilight (screen mirror is more dramatic!). However, the panel behind me would need to be flipped left-to-right for this to look right, since I'd like it to cast light to the same side of the room as the image on screen.

I think this can be implemented by adding two new scaling modes (Stretch-Flipped, Fit-Flipped) to the panel model and adding new ScaleTransform options in PanelLayout.GetScaledPolygons with a negative X value. But if the center point isn't 0,0, that's also going to create an offset that cheerfully throws all the regions off-screen. I'm terrible at geometry and I don't currently have a working C# compilation environment (I last wrote C# over 9 years ago), so I can't write this patch myself.

Could y'all consider this feature request?

Thanks!

StijnOostdam commented 4 years ago

Hey, great idea! I think we should add vertical flip as well, while we are at it. I think I will have some time this week.

StijnOostdam commented 4 years ago

Let me explain the basic geometry behind this, just so you can understand it: Lets say the total width and height is 100 and there is a panel with a top-left coordinate of (10, 10). To flip it horizontally, you simply need to transform each X coordinate with width - X. In this case: 100 - 10 = 90. So its new coordinate, now its top right coordinate, is (90, 10). The same idea applies to flipping it vertically.

This works since we only have positive coordinates.

StijnOostdam commented 4 years ago

Done, see the latest release: https://github.com/winleafs/Winleafs/releases

Enjoy :)

I did implement it in the PanelLayout class, see: https://github.com/winleafs/Winleafs/blob/master/Winleafs.Wpf/Api/Layouts/PanelLayout.cs#L231

Kistaro commented 4 years ago

It's working great - thanks for the update!